sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModelFactory.cs
2022-04-25 22:15:15 +02:00

81 lines
3.8 KiB
C#

using NUnit.Framework;
using Rhino.Mocks;
using System;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.BluetoothLock;
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]
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
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"),
MockRepository.GenerateStub<IUser>(), // user
MockRepository.GenerateStub<IInUseStateInfoProvider>(),
MockRepository.GenerateStub<IBikesViewModel>(),
url => { }).GetType()); // stateInfoProvider
}
[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
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"),
MockRepository.GenerateStub<IUser>(), // user
MockRepository.GenerateStub<IInUseStateInfoProvider>(),
MockRepository.GenerateStub<IBikesViewModel>(),
url => { }).GetType()); // stateInfoProvider
}
[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);
}
}
}