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
{
///
/// Test construction of object.
///
[Test]
public void Testctor()
{
var handler = new BookedDisconnected(
Substitute.For(),
() => true, // isConnectedDelegate
(isConnected) => Substitute.For(),
Substitute.For(),
Substitute.For(),
() => Substitute.For(),
Substitute.For(),
Substitute.For(),
Substitute.For(),
Substitute.For());
// 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();
var connector = Substitute.For();
var command = Substitute.For();
var geolocation = Substitute.For();
var locks = Substitute.For();
var pollingManager = Substitute.For();
var viewService = Substitute.For();
var bikesViewModel = Substitute.For();
var activeUser = Substitute.For();
var handler = new BookedDisconnected(
bike,
() => true, // isConnectedDelegate
(isConnected) => connector,
geolocation,
locks,
() => pollingManager,
Substitute.For(),
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);
}
}
}