sharee.bike-App/TestShareeLib/ViewModel/Bikes/Bike/TestBikeViewModelFactory.cs

83 lines
3.5 KiB
C#
Raw Normal View History

2023-01-18 14:22:51 +01:00
using System;
2022-08-30 15:42:25 +02:00
using NUnit.Framework;
2021-11-14 23:27:29 +01:00
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.BluetoothLock;
2023-01-18 14:22:51 +01:00
using TINK.Model.Bikes.BikeInfoNS.BC;
2022-08-30 15:42:25 +02:00
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
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
{
2022-09-06 16:08:19 +02:00
[TestFixture]
public class TestBikeViewModelFactory
{
[Test]
public void TestCreateBluetoothLock()
{
Assert.AreEqual(
typeof(TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel),
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
2023-01-18 14:22:51 +01:00
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable(new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("42", LockModel.ILockIt), new Drive(), DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42"), "My Station Name"),
2023-03-08 13:18:54 +01:00
NSubstitute.Substitute.For<IUser>(), // user
NSubstitute.Substitute.For<IInUseStateInfoProvider>(),
NSubstitute.Substitute.For<IBikesViewModel>(),
2022-09-06 16:08:19 +02:00
url => { }).GetType()); // stateInfoProvider
}
2021-07-12 21:31:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCreateCopri()
{
Assert.AreEqual(
typeof(TINK.ViewModel.Bikes.Bike.CopriLock.BikeViewModel),
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
2023-01-18 14:22:51 +01:00
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfoMutable(new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("42", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, "17", new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo.Builder { State = TINK.Model.Bikes.BikeInfoNS.CopriLock.LockingState.Closed }.Build()), "My Station Name"),
2023-03-08 13:18:54 +01:00
NSubstitute.Substitute.For<IUser>(), // user
NSubstitute.Substitute.For<IInUseStateInfoProvider>(),
NSubstitute.Substitute.For<IBikesViewModel>(),
2022-09-06 16:08:19 +02:00
url => { }).GetType()); // stateInfoProvider
}
2022-04-25 22:15:15 +02:00
2022-09-06 16:08:19 +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
2023-01-18 14:22:51 +01:00
new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("42", TINK.Model.Bikes.BikeInfoNS.BikeNS.LockModel.ILockIt), new Drive(), DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42"), "My Station Name"),
2023-03-08 13:18:54 +01:00
NSubstitute.Substitute.For<IUser>(), // user
NSubstitute.Substitute.For<IInUseStateInfoProvider>(),
NSubstitute.Substitute.For<IBikesViewModel>(),
2022-09-06 16:08:19 +02:00
url => { }),
Is.Null);
}
}
2021-07-12 21:31:46 +02:00
}