sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModelFactory.cs

81 lines
3.8 KiB
C#
Raw Normal View History

2021-07-12 21:31:46 +02:00
using NUnit.Framework;
using Rhino.Mocks;
using System;
2021-11-14 23:27:29 +01:00
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.BluetoothLock;
2021-07-12 21:31:46 +02:00
using TINK.Model.Device;
using TINK.Model.User;
using TINK.ViewModel;
using TINK.ViewModel.Bikes;
using TINK.ViewModel.Bikes.Bike;
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
{
[TestFixture]
public class TestBikeViewModelFactory
{
[Test]
2022-04-25 22:15:15 +02:00
public void TestCreateBluetoothLock()
2021-07-12 21:31:46 +02:00
{
Assert.AreEqual(
2022-04-25 22:15:15 +02:00
typeof(TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel),
2021-07-12 21:31:46 +02:00
BikeViewModelFactory.Create(
() => false, // Is connected delegate,
(isconnected) => null, // connectorFactory
new GeolocationMock(), // geolocation
new LocksServiceMock(), // lock service
(index) => { }, // bikeRemoveDelegate
null, // viewUpdateManager
NSubstitute.Substitute.For<ISmartDevice>(),
null, // viewService
2022-04-25 22:15:15 +02:00
new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new TINK.Model.Bike.BluetoothLock.BikeInfo("42", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42"), "My Station Name"),
2021-07-12 21:31:46 +02:00
MockRepository.GenerateStub<IUser>(), // user
MockRepository.GenerateStub<IInUseStateInfoProvider>(),
2022-01-22 18:30:23 +01:00
MockRepository.GenerateStub<IBikesViewModel>(),
url => { }).GetType()); // stateInfoProvider
2022-04-25 22:15:15 +02:00
}
2021-07-12 21:31:46 +02:00
2022-04-25 22:15:15 +02:00
[Test]
public void TestCreateCopri()
{
2021-07-12 21:31:46 +02:00
Assert.AreEqual(
2022-04-25 22:15:15 +02:00
typeof(TINK.ViewModel.Bikes.Bike.CopriLock.BikeViewModel),
2021-07-12 21:31:46 +02:00
BikeViewModelFactory.Create(
() => false, // Is connected delegate,
(isconnected) => null, // connectorFactory
new GeolocationMock(), // geolocation
new LocksServiceMock(), // lock service
(index) => { }, // bikeRemoveDelegate
null, // viewUpdateManager
NSubstitute.Substitute.For<ISmartDevice>(),
null, // viewService
2022-04-25 22:15:15 +02:00
new TINK.Model.Bike.CopriLock.BikeInfoMutable(new TINK.Model.Bike.CopriLock.BikeInfo("42", "17", new TINK.Model.Bikes.Bike.CopriLock.LockInfo.Builder { State = TINK.Model.Bikes.Bike.CopriLock.LockingState.Closed}.Build()), "My Station Name"),
2021-07-12 21:31:46 +02:00
MockRepository.GenerateStub<IUser>(), // user
MockRepository.GenerateStub<IInUseStateInfoProvider>(),
2022-01-22 18:30:23 +01:00
MockRepository.GenerateStub<IBikesViewModel>(),
url => { }).GetType()); // stateInfoProvider
2021-07-12 21:31:46 +02:00
}
2022-04-25 22:15:15 +02:00
[Test]
public void TestCreateUnsupported()
{
Assert.That(
BikeViewModelFactory.Create(
() => false, // Is connected delegate,
(isconnected) => null, // connectorFactory
new GeolocationMock(), // geolocation
new LocksServiceMock(), // lock service
(index) => { }, // bikeRemoveDelegate
null, // viewUpdateManager
NSubstitute.Substitute.For<ISmartDevice>(),
null, // viewService
new TINK.Model.Bike.BC.BikeInfoMutable(new TINK.Model.Bike.BluetoothLock.BikeInfo("42", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42"), "My Station Name"),
MockRepository.GenerateStub<IUser>(), // user
MockRepository.GenerateStub<IInUseStateInfoProvider>(),
MockRepository.GenerateStub<IBikesViewModel>(),
url => { }),
Is.Null);
}
2021-07-12 21:31:46 +02:00
}
}