mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 18:46:30 +01:00
78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock;
|
|
using ShareeBike.Model.Connector;
|
|
using ShareeBike.Model.Device;
|
|
using ShareeBike.Model.User;
|
|
using ShareeBike.Services.BluetoothLock;
|
|
using ShareeBike.Services.Geolocation;
|
|
using ShareeBike.View;
|
|
using ShareeBike.ViewModel;
|
|
using ShareeBike.ViewModel.Bikes;
|
|
using ShareeBike.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler;
|
|
|
|
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
|
{
|
|
[TestFixture]
|
|
public class TestBookedDisconnected
|
|
{
|
|
/// <summary>
|
|
/// Test construction of object.
|
|
/// </summary>
|
|
[Test]
|
|
public void Testctor()
|
|
{
|
|
var handler = new BookedDisconnected(
|
|
Substitute.For<IBikeInfoMutable>(),
|
|
() => true, // isConnectedDelegate
|
|
(isConnected) => Substitute.For<IConnector>(),
|
|
Substitute.For<IGeolocationService>(),
|
|
Substitute.For<ILocksService>(),
|
|
() => Substitute.For<IPollingUpdateTaskManager>(),
|
|
Substitute.For<ISmartDevice>(),
|
|
Substitute.For<IViewService>(),
|
|
Substitute.For<IBikesViewModel>(),
|
|
Substitute.For<IUser>());
|
|
|
|
// Verify prerequisites.
|
|
Assert.That(handler.ButtonText, Is.EqualTo("Connect lock"));
|
|
Assert.That(handler.IsButtonVisible, Is.True);
|
|
Assert.That(handler.LockitButtonText, Is.EqualTo("BookedDisconnected"));
|
|
Assert.That(handler.IsLockitButtonVisible, Is.False);
|
|
}
|
|
|
|
[Test]
|
|
public void TestNotSupported()
|
|
{
|
|
var bike = Substitute.For<IBikeInfoMutable>();
|
|
var connector = Substitute.For<IConnector>();
|
|
var command = Substitute.For<ICommand>();
|
|
var geolocation = Substitute.For<IGeolocationService>();
|
|
var locks = Substitute.For<ILocksService>();
|
|
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
|
var viewService = Substitute.For<IViewService>();
|
|
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
|
var activeUser = Substitute.For<IUser>();
|
|
|
|
var handler = new BookedDisconnected(
|
|
bike,
|
|
() => true, // isConnectedDelegate
|
|
(isConnected) => connector,
|
|
geolocation,
|
|
locks,
|
|
() => pollingManager,
|
|
Substitute.For<ISmartDevice>(),
|
|
viewService,
|
|
bikesViewModel,
|
|
activeUser);
|
|
|
|
var subsequent = handler.HandleRequestOption2().Result;
|
|
|
|
// Verify that nothing happened because request is not supported.
|
|
Assert.That(subsequent.ButtonText, Is.EqualTo("Connect lock"));
|
|
Assert.That(subsequent.IsButtonVisible, Is.True);
|
|
Assert.That(subsequent.LockitButtonText, Is.EqualTo("BookedDisconnected"));
|
|
Assert.That(subsequent.IsLockitButtonVisible, Is.False);
|
|
}
|
|
}
|
|
}
|