mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-22 04:46:30 +02:00
Version 3.0.371
This commit is contained in:
parent
bdb2dec1c1
commit
6d22dbf40b
145 changed files with 2289 additions and 764 deletions
|
@ -20,7 +20,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BC
|
|||
public TestBikeInfoSubClass(
|
||||
IStateInfo stateInfo,
|
||||
TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike bike,
|
||||
Drive drive,
|
||||
DriveMutable drive,
|
||||
bool? isDemo = DEFAULTVALUEISDEMO,
|
||||
IEnumerable<string> group = null,
|
||||
string stationId = null,
|
||||
|
@ -43,7 +43,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BC
|
|||
public void TestCtorBikeNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new TestBikeInfoSubClass(new StateInfo(), null, new Drive()),
|
||||
() => new TestBikeInfoSubClass(new StateInfo(), null, new DriveMutable()),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
|||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null) : base(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike(id, lockModel, wheelType, typeOfBike, aaRideType, description),
|
||||
new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(),
|
||||
new TINK.Model.Bikes.BikeInfoNS.DriveNS.DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
isDemo,
|
||||
group,
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace TestTINKLib
|
|||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null) : base(
|
||||
new Bike(id, lockType, wheelType, typeOfBike, aaRideType, description),
|
||||
new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(),
|
||||
new TINK.Model.Bikes.BikeInfoNS.DriveNS.DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
isDemo,
|
||||
group,
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace UITest.Fixtures.ViewModel
|
|||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null) : base(
|
||||
new Bike(id, lockModel, wheelType, typeOfBike, aaRideType, description),
|
||||
new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(),
|
||||
new TINK.Model.Bikes.BikeInfoNS.DriveNS.DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
pisDemo,
|
||||
group,
|
||||
|
|
|
@ -10,6 +10,7 @@ using TINK.Model.Connector;
|
|||
using TINK.Model.Device;
|
||||
using TINK.Model.State;
|
||||
using TINK.Model.User;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Services.BluetoothLock;
|
||||
using TINK.Services.Geolocation;
|
||||
using static TINK.Model.Bikes.BikeInfoNS.BluetoothLock.Command.GetLockedLocationCommand;
|
||||
|
@ -199,5 +200,39 @@ namespace TestShareeLib.Model.Bikes.BikeInfoNS.BluetoothLock.Command
|
|||
await listener.ReportStateAsync(State.QueryLocationSucceeded, string.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Final state: Disposable closed
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestReturnClosingLockLocationAvailable()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var geolocation = Substitute.For<IGeolocationService>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var listener = Substitute.For<IGetLockedLocationCommandListener>();
|
||||
|
||||
var closingLockLocation = Substitute.For<IGeolocation>();
|
||||
closingLockLocation.Latitude.Returns(7);
|
||||
closingLockLocation.Longitude.Returns(9);
|
||||
closingLockLocation.Timestamp.Returns(DateTimeOffset.MinValue);
|
||||
|
||||
bike.LockInfo.Location.Returns((IGeolocation)closingLockLocation); // When locking bike geolocation was available.
|
||||
|
||||
var lockingLocation = await InvokeAsync<TestGetBikeLocationCommand>(
|
||||
bike,
|
||||
geolocation,
|
||||
locks,
|
||||
() => DateTime.MinValue,
|
||||
listener);
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
listener.ReportStep(Step.StartingQueryLocation);
|
||||
return;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
[Test]
|
||||
public void TestCtorAvailable()
|
||||
{
|
||||
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").Id);
|
||||
Assert.AreEqual("13", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").StationId);
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value);
|
||||
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").Id);
|
||||
Assert.AreEqual("13", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").StationId);
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -30,7 +30,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
Assert.That(
|
||||
() => new BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
5200544,
|
||||
new Guid("00000000-0000-0000-0000-000000000001"),
|
||||
|
@ -41,9 +41,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
[Test]
|
||||
public void TestCtorRequested()
|
||||
{
|
||||
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).Id);
|
||||
Assert.AreEqual(112, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Reserved, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).State.Value);
|
||||
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).Id);
|
||||
Assert.AreEqual(112, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Reserved, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).State.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -52,7 +52,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
Assert.That(
|
||||
() => new BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
112,
|
||||
new Guid(),
|
||||
|
@ -73,9 +73,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
[Test]
|
||||
public void TestCtorBooked()
|
||||
{
|
||||
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).Id);
|
||||
Assert.AreEqual(112, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Booked, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).State.Value);
|
||||
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).Id);
|
||||
Assert.AreEqual(112, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Booked, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).State.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -84,7 +84,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
Assert.That(
|
||||
() => new BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
112,
|
||||
new Guid(),
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace TestShareeLib.Model.Bike.BluetoothLock
|
|||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike(
|
||||
"MyBikeId",
|
||||
TINK.Model.Bikes.BikeInfoNS.BikeNS.LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
42,
|
||||
new Guid(),
|
||||
|
@ -52,7 +52,7 @@ namespace TestShareeLib.Model.Bike.BluetoothLock
|
|||
TINK.Model.Bikes.BikeInfoNS.BikeNS.LockModel.ILockIt,
|
||||
TINK.Model.Bikes.BikeInfoNS.BikeNS.WheelType.Trike,
|
||||
TINK.Model.Bikes.BikeInfoNS.BikeNS.TypeOfBike.Cargo),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
42,
|
||||
new Guid(),
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace TestShareeLib.Model.Bike.CopriLock
|
|||
{
|
||||
var bike = new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("bikeId", LockModel.Sigo),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
"stationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo());
|
||||
|
@ -32,7 +32,7 @@ namespace TestShareeLib.Model.Bike.CopriLock
|
|||
Assert.That(
|
||||
() => new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
"stationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()),
|
||||
|
@ -44,7 +44,7 @@ namespace TestShareeLib.Model.Bike.CopriLock
|
|||
{
|
||||
var bike = new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("bikeId", LockModel.Sigo),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
"stationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo(),
|
||||
|
@ -61,7 +61,7 @@ namespace TestShareeLib.Model.Bike.CopriLock
|
|||
Assert.That(
|
||||
() => new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
DateTime.Now,
|
||||
"a@b",
|
||||
|
@ -79,7 +79,7 @@ namespace TestShareeLib.Model.Bike.CopriLock
|
|||
Assert.That(
|
||||
() => new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
DateTime.Now,
|
||||
"a@b",
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
|
||||
namespace TestShareeLib.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestBatteryMutable
|
||||
{
|
||||
[Test]
|
||||
public void TestCurrentChargeBars()
|
||||
{
|
||||
var battery = new BatteryMutable(new Battery.Builder {
|
||||
MaxChargeBars = 5,
|
||||
CurrentChargeBars = 1,
|
||||
CurrentChargePercent = 20.0
|
||||
}.Build());
|
||||
|
||||
battery.CurrentChargeBars = 4;
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargeBars,
|
||||
Is.EqualTo(4));
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargePercent,
|
||||
Is.EqualTo(80.0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCurrentChargeBarsNull()
|
||||
{
|
||||
var battery = new BatteryMutable(new Battery.Builder
|
||||
{
|
||||
MaxChargeBars = 5,
|
||||
CurrentChargeBars = 1,
|
||||
CurrentChargePercent = 20.0
|
||||
}.Build());
|
||||
|
||||
battery.CurrentChargeBars = null;
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargePercent,
|
||||
Is.EqualTo(double.NaN));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCurrentChargeBarsInvalidStateZero()
|
||||
{
|
||||
var battery = new BatteryMutable(new Battery.Builder
|
||||
{
|
||||
MaxChargeBars = 0, // Could lead to division by zero if not handled correctly.
|
||||
CurrentChargeBars = null,
|
||||
CurrentChargePercent = 20.0
|
||||
}.Build());
|
||||
|
||||
battery.CurrentChargeBars = 4;
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargePercent,
|
||||
Is.EqualTo(20.0));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestCurrentChargeBarsInvalidStateNull()
|
||||
{
|
||||
var battery = new BatteryMutable(new Battery.Builder
|
||||
{
|
||||
MaxChargeBars = null,
|
||||
CurrentChargeBars = null,
|
||||
CurrentChargePercent = 20.0
|
||||
}.Build());
|
||||
|
||||
battery.CurrentChargeBars = 4;
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
battery.CurrentChargePercent,
|
||||
Is.EqualTo(20.0));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using NSubstitute;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS.BatteryNS;
|
||||
|
@ -12,7 +12,7 @@ namespace TestShareeLib.Model.BikeInfo.DriveNS
|
|||
[Test]
|
||||
public void TestCtorNoArgs()
|
||||
{
|
||||
var drive = new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive();
|
||||
var drive = new DriveMutable();
|
||||
Assert.That(
|
||||
drive.Type,
|
||||
Is.EqualTo(DriveType.SoleHumanPowered));
|
||||
|
@ -35,7 +35,7 @@ namespace TestShareeLib.Model.BikeInfo.DriveNS
|
|||
engine.Manufacturer.Returns("Bosch");
|
||||
battery.CurrentChargePercent.Returns(97);
|
||||
|
||||
var drive = new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(engine, battery);
|
||||
var drive = new DriveMutable(engine, battery);
|
||||
|
||||
Assert.That(
|
||||
drive.Engine.Manufacturer,
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace TestTINKLib
|
|||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null) : base(
|
||||
new Bike(id, lockType, wheelType, typeOfBike, aaRideType, description),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
isDemo,
|
||||
group,
|
||||
|
@ -132,7 +132,7 @@ namespace TestTINKLib
|
|||
{
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("57", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
DateTime.Now,
|
||||
"john@long",
|
||||
|
@ -141,7 +141,7 @@ namespace TestTINKLib
|
|||
null),
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("20", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
DateTime.Now,
|
||||
"john@long",
|
||||
|
@ -150,7 +150,7 @@ namespace TestTINKLib
|
|||
null),
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("33", LockModel.Sigo),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
"7",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()),
|
||||
|
@ -186,7 +186,7 @@ namespace TestTINKLib
|
|||
{
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("57", LockModel.Sigo),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
"7" /*station id*/,
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()),
|
||||
|
@ -226,7 +226,7 @@ namespace TestTINKLib
|
|||
{
|
||||
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
|
||||
new Bike("57" /* bike id*/, LockModel.ILockIt, WheelType.Trike, TypeOfBike.Allround, AaRideType.NoAaRide, "Test description"),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
17, /* Lock id */
|
||||
new Guid(),
|
||||
|
@ -271,7 +271,7 @@ namespace TestTINKLib
|
|||
{
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("57", LockModel.Sigo),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
"7" /*station id*/,
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo(),
|
||||
|
|
|
@ -653,7 +653,7 @@ namespace TestShareeLib.Model.Connector.Updater
|
|||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("17", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
22,
|
||||
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
||||
|
@ -699,7 +699,7 @@ namespace TestShareeLib.Model.Connector.Updater
|
|||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("17", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
22,
|
||||
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
||||
|
@ -741,7 +741,7 @@ namespace TestShareeLib.Model.Connector.Updater
|
|||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("17", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
22,
|
||||
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
|
||||
|
|
|
@ -20,21 +20,21 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
|||
{
|
||||
{"3", new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("7", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
17, /* Lock id */
|
||||
new Guid(),
|
||||
"3" /* Station id */) },
|
||||
{"7", new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
17, /* Lock id */
|
||||
new Guid(),
|
||||
"12" /* Station id */) },
|
||||
{"12",
|
||||
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
17, /* Lock id */
|
||||
new Guid(),
|
||||
|
@ -78,12 +78,12 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
|||
new Dictionary<string, BikeInfo>
|
||||
{
|
||||
{"7", new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
"12", /* Station id */
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()) },
|
||||
{"12", new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
"12", /* Station id */
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()) }
|
||||
|
@ -103,18 +103,18 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
|||
new Dictionary<string, BikeInfo>
|
||||
{
|
||||
{"7", new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("8", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
"12", /* Station id */
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()) },
|
||||
{"11", new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
5200544,
|
||||
new Guid("00000000-0000-0000-0000-000000000001"),
|
||||
"12" /* Station id */) },
|
||||
{"12", new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("33", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
DataSource.Copri,
|
||||
"12", /* Station id */
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()) }
|
||||
|
|
|
@ -20,8 +20,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.Service.LockService
|
|||
|
||||
var bikes = new BikeCollection(new Dictionary<string, TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo>()
|
||||
{
|
||||
{ "42", new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("42", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 1, new Guid(),new byte[] { 1, 4 }, new byte[] { 3, 4 }, new byte[] { 3, 4 }, DateTime.Now, "a@b", "1" , null /*operator uri*/) },
|
||||
{ "43", new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("43", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 3, new Guid(),new byte[] { 4, 4 }, new byte[] { 4, 7 }, new byte[] { 5, 4 }, DateTime.Now, "c@b", "1" , null /*operator uri*/) }
|
||||
{ "42", new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("42", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 1, new Guid(),new byte[] { 1, 4 }, new byte[] { 3, 4 }, new byte[] { 3, 4 }, DateTime.Now, "a@b", "1" , null /*operator uri*/) },
|
||||
{ "43", new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("43", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 3, new Guid(),new byte[] { 4, 4 }, new byte[] { 4, 7 }, new byte[] { 5, 4 }, DateTime.Now, "c@b", "1" , null /*operator uri*/) }
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace UITest.Fixtures.ViewModel
|
|||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null) : base(
|
||||
new Bike(id, lockModel, wheelType, typeOfBike, aaRideType, description),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
isDemo,
|
||||
group,
|
||||
|
|
|
@ -0,0 +1,212 @@
|
|||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.State;
|
||||
using TINK.Services.BluetoothLock;
|
||||
using TINK.View;
|
||||
using TINK.ViewModel;
|
||||
using TINK.ViewModel.Bikes;
|
||||
using TINK.ViewModel.Bikes.Bike.BluetoothLock;
|
||||
using TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler;
|
||||
using static TINK.Model.Bikes.BikeInfoNS.BluetoothLock.Command.CloseCommand;
|
||||
|
||||
namespace TestShareeLib.ViewModel.Bikes.Bike.BluetoothLock
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCloseLockActionViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Use case: Close lock.
|
||||
/// Final state: Occupied closed, End rental requested
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestCloseLockAndRequestEndRental()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
var command = Substitute.For<ICommand>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
||||
var viewService = Substitute.For<IViewService>();
|
||||
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
||||
var listener = Substitute.For<ICloseCommandListener>();
|
||||
|
||||
var closeLockActionViewModel = new CloseLockActionViewModel<BookedOpen>(
|
||||
bike,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
bike.CloseLockAsync(Arg.Any<ICloseCommandListener>(), Arg.Any<Task>()).Returns(x =>
|
||||
{
|
||||
// Add calls to ReportStep which IBikeInfoMutable implementation would do.
|
||||
closeLockActionViewModel.ReportStep(Step.StartStopingPolling);
|
||||
closeLockActionViewModel.ReportStep(Step.StartingQueryingLocation);
|
||||
closeLockActionViewModel.ReportStep(Step.ClosingLock);
|
||||
closeLockActionViewModel.ReportStep(Step.WaitStopPollingQueryLocation);
|
||||
closeLockActionViewModel.ReportStep(Step.QueryLocationTerminated);
|
||||
closeLockActionViewModel.ReportStep(Step.UpdateLockingState);
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Request handler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // Request handler factory queries lock state to create appropriate request handler object.
|
||||
|
||||
await closeLockActionViewModel.CloseLockAsync();
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
|
||||
bikesViewModel.StartRentalProcess(Arg.Is<IRentalProcessViewModel>(
|
||||
x => x.BikeId == "0"
|
||||
&& x.State == CurrentRentalProcess.CloseLock
|
||||
&& x.StepIndex == 1
|
||||
&& x.Result == CurrentStepStatus.None));
|
||||
|
||||
//Step.StartingQueryingLocation
|
||||
bikesViewModel.ActionText = "Start query location...";
|
||||
//Step.ClosingLock
|
||||
bikesViewModel.ActionText = "Stay with the bike until the lock is closed.";
|
||||
//Step.WaitStopPollingQueryLocation
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
//Step.UpdateLockingState
|
||||
bikesViewModel.ActionText = "Updating lock state...";
|
||||
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StartAsync(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
|
||||
bikesViewModel.RentalProcess.Result = CurrentStepStatus.Succeeded;
|
||||
|
||||
bikesViewModel.RentalProcess.StepIndex = 2;
|
||||
bikesViewModel.RentalProcess.Result = CurrentStepStatus.None;
|
||||
|
||||
//Ask whether park bike or end rental
|
||||
viewService.DisplayAlert(
|
||||
"Please choose",
|
||||
"Do you want to park the bike to continue riding later or return the bike now and end the rental?",
|
||||
"End rental",
|
||||
"Park bike"
|
||||
);
|
||||
|
||||
closeLockActionViewModel.IsEndRentalRequested = true;
|
||||
|
||||
bikesViewModel.RentalProcess.Result = CurrentStepStatus.Succeeded;
|
||||
|
||||
bikesViewModel.RentalProcess.State = CurrentRentalProcess.None;
|
||||
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
return;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: Close lock.
|
||||
/// Final state: Occupied closed, Park bike requested
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestCloseLockAndRequestParkBike()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
var command = Substitute.For<ICommand>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
||||
var viewService = Substitute.For<IViewService>();
|
||||
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
||||
var listener = Substitute.For<ICloseCommandListener>();
|
||||
|
||||
var closeLockActionViewModel = new CloseLockActionViewModel<BookedOpen>(
|
||||
bike,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
bike.CloseLockAsync(Arg.Any<ICloseCommandListener>(), Arg.Any<Task>()).Returns(x =>
|
||||
{
|
||||
// Add calls to ReportStep which IBikeInfoMutable implementation would do.
|
||||
closeLockActionViewModel.ReportStep(Step.StartStopingPolling);
|
||||
closeLockActionViewModel.ReportStep(Step.StartingQueryingLocation);
|
||||
closeLockActionViewModel.ReportStep(Step.ClosingLock);
|
||||
closeLockActionViewModel.ReportStep(Step.WaitStopPollingQueryLocation);
|
||||
closeLockActionViewModel.ReportStep(Step.QueryLocationTerminated);
|
||||
closeLockActionViewModel.ReportStep(Step.UpdateLockingState);
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Request handler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // Request handler factory queries lock state to create appropriate request handler object.
|
||||
|
||||
await closeLockActionViewModel.CloseLockAsync();
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
|
||||
bikesViewModel.StartRentalProcess(Arg.Is<IRentalProcessViewModel>(
|
||||
x => x.BikeId == "0"
|
||||
&& x.State == CurrentRentalProcess.CloseLock
|
||||
&& x.StepIndex == 1
|
||||
&& x.Result == CurrentStepStatus.None));
|
||||
|
||||
//Step.StartingQueryingLocation
|
||||
bikesViewModel.ActionText = "Start query location...";
|
||||
//Step.ClosingLock
|
||||
bikesViewModel.ActionText = "Stay with the bike until the lock is closed.";
|
||||
//Step.WaitStopPollingQueryLocation
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
//Step.UpdateLockingState
|
||||
bikesViewModel.ActionText = "Updating lock state...";
|
||||
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StartAsync(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
|
||||
bikesViewModel.RentalProcess.Result = CurrentStepStatus.Succeeded;
|
||||
|
||||
bikesViewModel.RentalProcess.StepIndex = 2;
|
||||
bikesViewModel.RentalProcess.Result = CurrentStepStatus.None;
|
||||
|
||||
//Ask whether park bike or end rental
|
||||
viewService.DisplayAlert(
|
||||
"Please choose",
|
||||
"Do you want to park the bike to continue riding later or return the bike now and end the rental?",
|
||||
"End rental",
|
||||
"Park bike"
|
||||
);
|
||||
|
||||
closeLockActionViewModel.IsEndRentalRequested = false;
|
||||
|
||||
bikesViewModel.RentalProcess.Result = CurrentStepStatus.Succeeded;
|
||||
|
||||
//Show confirmation
|
||||
viewService.DisplayAlert(
|
||||
"Lock is closed",
|
||||
"Bike is parked. Your chargeable rental continues!",
|
||||
"OK"
|
||||
);
|
||||
|
||||
bikesViewModel.RentalProcess.State = CurrentRentalProcess.None;
|
||||
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
return;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,490 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using NSubstitute;
|
||||
using NSubstitute.ExceptionExtensions;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.State;
|
||||
using TINK.Model.User;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Repository.Response;
|
||||
using TINK.Services.BluetoothLock;
|
||||
using TINK.Services.Geolocation;
|
||||
using TINK.View;
|
||||
using TINK.ViewModel;
|
||||
using TINK.ViewModel.Bikes;
|
||||
using TINK.ViewModel.Bikes.Bike.BluetoothLock;
|
||||
using TINK.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler;
|
||||
using static TINK.Model.Bikes.BikeInfoNS.BluetoothLock.Command.GetLockedLocationCommand;
|
||||
|
||||
namespace TestShareeLib.ViewModel.Bikes.Bike.BluetoothLock
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestEndRentalActionViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Initial state: No LastGeolocation from CloseLock, Lock currently out of reach
|
||||
/// Final state: Booked, lock state unknown.
|
||||
/// </summary>
|
||||
/// <remarks> Replaces test TestReturnOutOfReach which was removed for sharee.bike version ~3.0.362. </remarks>
|
||||
[Test]
|
||||
public async Task TestReturnLastGeolocatonNullLockOutOfReach()
|
||||
{
|
||||
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 returnBikeActionViewModel = new EndRentalActionViewModel<BookedClosed>(
|
||||
bike,
|
||||
() => true, // isConnectedDelegate
|
||||
(isConnexted) => connector,
|
||||
locks,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
bike.GetLockedBikeLocationAsync(Arg.Any<IGetLockedLocationCommandListener>()).Throws((x) =>
|
||||
{
|
||||
returnBikeActionViewModel.ReportStep(Step.StartingQueryLocation);
|
||||
returnBikeActionViewModel.ReportStateAsync(State.DisconnetedNoLocationError, "").Wait();
|
||||
returnBikeActionViewModel.ReportStep(Step.DisconnectingLockOnDisconnectedNoLocationError);
|
||||
returnBikeActionViewModel.ReportStateAsync(State.QueryLocationSucceeded, "").Wait();
|
||||
throw new Exception();
|
||||
});
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked);
|
||||
|
||||
await returnBikeActionViewModel.EndRentalAsync();
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
viewService.DisplayAlert(
|
||||
"Rental could not be terminated!",
|
||||
"We could not assign the bike to any station. For this we need your location information while you are standing right next to the bike. Only then your rental can be terminated!\r\n\r\nApproach the bike lock, turn on Bluetooth and Location services and try again.",
|
||||
"OK");
|
||||
bikesViewModel.ActionText = "Disconnecting lock...";
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
|
||||
// Verify state after action
|
||||
Assert.That(
|
||||
bike.LockInfo.State,
|
||||
Is.EqualTo(LockingState.UnknownDisconnected));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Initial state: No LastGeolocation from CloseLock, Location services not reachable
|
||||
/// Final state: Booked, lock state unknown.
|
||||
/// </summary>
|
||||
/// <remarks>Replaces test TestReturnLockInReachNoGeolocation which was removed for sharee.bike older ~ 3.0.362.</remarks>
|
||||
[Test]
|
||||
public void TestReturnStartGetGeolocationException()
|
||||
{
|
||||
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 EndRentalActionViewModel<BookedClosed>(
|
||||
bike,
|
||||
() => true, // isConnectedDelegate
|
||||
(isConnexted) => connector,
|
||||
locks,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
bike.GetLockedBikeLocationAsync(Arg.Any<IGetLockedLocationCommandListener>()).Throws((x) =>
|
||||
{
|
||||
handler.ReportStep(Step.StartingQueryLocation);
|
||||
handler.ReportStateAsync(State.QueryLocationFailed, "Ups...").Wait();
|
||||
throw new Exception();
|
||||
});
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state does not change.
|
||||
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // Locking state does not change.
|
||||
|
||||
var subsequent = handler.EndRentalAsync();
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(async () =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
await viewService.DisplayAlert(
|
||||
"Rental could not be terminated!",
|
||||
"Grant Location permission, activate Location services and try again.",
|
||||
"OK");
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Initial state: No LastGeolocation from CloseLock, Lock currently in reach
|
||||
/// Final state: Disposable closed
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestReturnLockInReach()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
var command = Substitute.For<ICommand>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
||||
var viewService = Substitute.For<IViewService>();
|
||||
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
||||
var listener = Substitute.For<IGetLockedLocationCommandListener>();
|
||||
|
||||
var returnBikeActionViewModel = new EndRentalActionViewModel<BookedClosed>(
|
||||
bike,
|
||||
() => true, // isConnectedDelegate
|
||||
(isConnexted) => connector,
|
||||
locks,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
bike.GetLockedBikeLocationAsync(Arg.Any<IGetLockedLocationCommandListener>()).Returns((x) =>
|
||||
{
|
||||
returnBikeActionViewModel.ReportStep(Step.StartingQueryLocation);
|
||||
returnBikeActionViewModel.ReportStateAsync(State.QueryLocationSucceeded, string.Empty).Wait();
|
||||
return Task.FromResult(new LocationDto.Builder().Build());
|
||||
});
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Disposable); // Request handler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // Request handler factory queries lock state to create appropriate request handler object.
|
||||
|
||||
await returnBikeActionViewModel.EndRentalAsync();
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
connector.Command.DoReturn(bike, Arg.Is<LocationDto>(x => x != null));
|
||||
bikesViewModel.ActionText = "Disconnecting lock...";
|
||||
locks.DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
pollingManager.StartAsync(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Final state: Same as initial state.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestReturnReturnFailsWebConnectFailureException()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
var command = Substitute.For<ICommand>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
||||
var viewService = Substitute.For<IViewService>();
|
||||
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
||||
|
||||
var handler = new EndRentalActionViewModel<BookedClosed>(
|
||||
bike,
|
||||
() => true, // isConnectedDelegate
|
||||
(isConnexted) => connector,
|
||||
locks,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x => throw new WebConnectFailureException("Context info", new Exception("hoppla")));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // RequestHandler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // RequestHandler factory queries lock state to create appropriate request handler object.
|
||||
|
||||
await handler.EndRentalAsync();
|
||||
|
||||
await locks.DidNotReceive().DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
||||
await locks.DidNotReceive().DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
viewService.DisplayAlert(
|
||||
"Rental could not be terminated!",
|
||||
"A stable Internet connection is required. Connect to WIFI or to mobile network and activate mobile data. Try again.",
|
||||
"OK");
|
||||
pollingManager.StartAsync(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Final state: Same as initial state.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestReturnReturnFailsNotAtStationException()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
var command = Substitute.For<ICommand>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
||||
var viewService = Substitute.For<IViewService>();
|
||||
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
||||
|
||||
var handler = new EndRentalActionViewModel<BookedClosed>(
|
||||
bike,
|
||||
() => true, // isConnectedDelegate
|
||||
(isConnexted) => connector,
|
||||
locks,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
NotAtStationException.IsNotAtStation("Failure 2178: bike 1545 out of GEO fencing. 15986 meter distance to next station 42. OK: bike 1545 locked confirmed", out NotAtStationException notAtStationException);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x =>
|
||||
throw notAtStationException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // RequestHandler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // RequestHandler factory queries lock state to create appropriate request handler object.
|
||||
|
||||
await handler.EndRentalAsync();
|
||||
|
||||
await locks.DidNotReceive().DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
viewService.DisplayAlert("Rental could not be terminated!", "End rental outside or at wrong station is not possible. Distance to next suitable station 42 is 15986 m.", "OK");
|
||||
pollingManager.StartAsync(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Initial state: Copri reports that no GPS data available
|
||||
/// Final state: Same as initial state.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestReturnReturnFailsNoGPSDataException()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
var command = Substitute.For<ICommand>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
||||
var viewService = Substitute.For<IViewService>();
|
||||
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
||||
|
||||
var handler = new EndRentalActionViewModel<BookedClosed>(
|
||||
bike,
|
||||
() => true, // isConnectedDelegate
|
||||
(isConnexted) => connector,
|
||||
locks,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
NoGPSDataException.IsNoGPSData("Failure 2245: No GPS data, state change forbidden.", out NoGPSDataException noGPSDataException);
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x =>
|
||||
throw noGPSDataException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // RequestHandler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // RequestHandler factory queries lock state to create appropriate request handler object.
|
||||
|
||||
await handler.EndRentalAsync();
|
||||
|
||||
await locks.DidNotReceive().DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
viewService.DisplayAlert("Rental could not be terminated!", "End rental at an unknown location is not possible.\r\nRental can be ended if\r\n- location information is available when closing lock\r\n- bike is in reach and location information is available when pressing button \"End rental\"", "OK");
|
||||
pollingManager.StartAsync(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Final state: Same as initial state.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestReturnReturnFailsResponseException()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
var command = Substitute.For<ICommand>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
||||
var viewService = Substitute.For<IViewService>();
|
||||
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
||||
|
||||
var handler = new EndRentalActionViewModel<BookedClosed>(
|
||||
bike,
|
||||
() => true, // isConnectedDelegate
|
||||
(isConnexted) => connector,
|
||||
locks,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x =>
|
||||
throw new ReturnBikeException(JsonConvert.DeserializeObject<DoReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // RequestHandler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // RequestHandler factory queries lock state to create appropriate request handler object.
|
||||
|
||||
await handler.EndRentalAsync();
|
||||
|
||||
await locks.DidNotReceive().DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
viewService.DisplayAdvancedAlert("Rental could not be terminated!", "Outer message.", "Some invalid data received!", "OK");
|
||||
pollingManager.StartAsync(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use case: End rental.
|
||||
/// Final state: Same as initial state.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestReturnReturnFailsException()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
var command = Substitute.For<ICommand>();
|
||||
var locks = Substitute.For<ILocksService>();
|
||||
var pollingManager = Substitute.For<IPollingUpdateTaskManager>();
|
||||
var viewService = Substitute.For<IViewService>();
|
||||
var bikesViewModel = Substitute.For<IBikesViewModel>();
|
||||
|
||||
var returnBikeActionViewModel = new EndRentalActionViewModel<BookedClosed>(
|
||||
bike,
|
||||
() => true, // isConnectedDelegate
|
||||
(isConnexted) => connector,
|
||||
locks,
|
||||
() => pollingManager,
|
||||
viewService,
|
||||
bikesViewModel);
|
||||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x => throw new Exception("Exception message."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Request handler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // Request handler factory queries lock state to create appropriate request handler object.
|
||||
|
||||
await returnBikeActionViewModel.EndRentalAsync();
|
||||
|
||||
await locks.DidNotReceive().DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
||||
// Verify behavior
|
||||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
viewService.DisplayAlert(
|
||||
"Rental could not be terminated!",
|
||||
"Exception message.",
|
||||
"OK"
|
||||
);
|
||||
pollingManager.StartAsync(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
() => false /* not connected */,
|
||||
(_) => Substitute.For<IConnector>(),
|
||||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "12"),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "12"),
|
||||
"My Station Name");
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, bike.State.Value);
|
||||
Assert.AreEqual(LockingState.UnknownDisconnected, bike.LockInfo.State);
|
||||
|
@ -61,7 +61,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
() => false /* not connected */,
|
||||
(_) => Substitute.For<IConnector>(),
|
||||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id */, new Guid(), /*K User*/ null, /*K Admin*/ null, /*K Seed*/ null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>()),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id */, new Guid(), /*K User*/ null, /*K Admin*/ null, /*K Seed*/ null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>()),
|
||||
"My Station Name");
|
||||
Assert.AreEqual(
|
||||
typeof(ReservedDisconnected),
|
||||
|
@ -84,7 +84,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
() => false /* not connected */,
|
||||
(_) => Substitute.For<IConnector>(),
|
||||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>()),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>()),
|
||||
"My Station Name");
|
||||
bike.LockInfo.State = LockingState.Closed;
|
||||
Assert.AreEqual(
|
||||
|
@ -108,7 +108,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
() => false /* not connected */,
|
||||
(_) => Substitute.For<IConnector>(),
|
||||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null /* user key */, null, null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>()),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null /* user key */, null, null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>()),
|
||||
"My Station Name");
|
||||
bike.LockInfo.State = LockingState.Open;
|
||||
Assert.AreEqual(
|
||||
|
@ -132,7 +132,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
() => false /* not connected */,
|
||||
(_) => Substitute.For<IConnector>(),
|
||||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>()),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>()),
|
||||
"My Station Name");
|
||||
bike.LockInfo.State = LockingState.Closed;
|
||||
Assert.AreEqual(
|
||||
|
@ -156,7 +156,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
() => false /* not connected */,
|
||||
(_) => Substitute.For<IConnector>(),
|
||||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>()),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>()),
|
||||
"My Station Name");
|
||||
bike.LockInfo.State = LockingState.Open;
|
||||
Assert.AreEqual(
|
||||
|
@ -180,7 +180,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
() => false /* not connected */,
|
||||
(_) => Substitute.For<IConnector>(),
|
||||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>()),
|
||||
new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.ILockIt, WheelType.Mono, TypeOfBike.Allround), new DriveMutable(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>()),
|
||||
"My Station Name");
|
||||
|
||||
Assert.AreEqual(
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace TestShareeLib.ViewModel.Bikes.Bike.CopriLock.RequestHandler
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
viewService.DisplayUserFeedbackPopup(Arg.Any<IBattery>(), Arg.Any<string>());
|
||||
viewService.DisplayUserFeedbackPopup(Arg.Any<IBatteryMutable>(), Arg.Any<string>());
|
||||
bikesViewModel.ActionText = "Submitting feedback...";
|
||||
connector.Command.DoSubmitFeedback(Arg.Any<TINK.Model.Connector.IUserFeedback>(), Arg.Any<Uri>()); // Booking must be performed
|
||||
bikesViewModel.ActionText = string.Empty;
|
||||
|
@ -117,7 +117,7 @@ namespace TestShareeLib.ViewModel.Bikes.Bike.CopriLock.RequestHandler
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
viewService.DisplayUserFeedbackPopup(Arg.Any<IBattery>(), Arg.Any<string>());
|
||||
viewService.DisplayUserFeedbackPopup(Arg.Any<IBatteryMutable>(), Arg.Any<string>());
|
||||
bikesViewModel.ActionText = "Submitting feedback...";
|
||||
connector.Command.DoSubmitFeedback(Arg.Any<TINK.Model.Connector.IUserFeedback>(), Arg.Any<Uri>()); // Booking must be performed
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
|
@ -176,7 +176,7 @@ namespace TestShareeLib.ViewModel.Bikes.Bike.CopriLock.RequestHandler
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopAsync(); // Polling must be stopped before any COPR and lock service action
|
||||
viewService.DisplayUserFeedbackPopup(Arg.Any<IBattery>(), Arg.Any<string>());
|
||||
viewService.DisplayUserFeedbackPopup(Arg.Any<IBatteryMutable>(), Arg.Any<string>());
|
||||
bikesViewModel.ActionText = "Submitting feedback...";
|
||||
connector.Command.DoSubmitFeedback(Arg.Any<TINK.Model.Connector.IUserFeedback>(), Arg.Any<Uri>()); // Booking must be performed
|
||||
viewService.PushModalAsync(ViewTypes.MiniSurvey);
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
|
|||
() => false /* not connected */,
|
||||
(_) => Substitute.For<IConnector>(),
|
||||
() => Substitute.For<IPollingUpdateTaskManager>(),
|
||||
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"),
|
||||
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("42", LockModel.ILockIt), new DriveMutable(), DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42"), "My Station Name"),
|
||||
Substitute.For<IUser>(), // user
|
||||
null /*ViewContext*/,
|
||||
Substitute.For<IInUseStateInfoProvider>(),
|
||||
|
@ -83,7 +83,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
|
|||
null, // viewUpdateManager
|
||||
NSubstitute.Substitute.For<ISmartDevice>(),
|
||||
null, // viewService
|
||||
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"),
|
||||
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 DriveMutable(), 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"),
|
||||
NSubstitute.Substitute.For<IUser>(), // user
|
||||
new ViewContext(PageContext.BikesAtStation, "FR1012"), // Context does not matter for this test.
|
||||
NSubstitute.Substitute.For<IInUseStateInfoProvider>(),
|
||||
|
@ -104,7 +104,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
|
|||
null, // viewUpdateManager
|
||||
NSubstitute.Substitute.For<ISmartDevice>(),
|
||||
null, // viewService
|
||||
new BikeInfoMutableUnsupported(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"),
|
||||
new BikeInfoMutableUnsupported(new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("42", TINK.Model.Bikes.BikeInfoNS.BikeNS.LockModel.ILockIt), new DriveMutable(), DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42"), "My Station Name"),
|
||||
NSubstitute.Substitute.For<IUser>(), // user
|
||||
new ViewContext(PageContext.BikesAtStation, "FR1012"), // Context does not matter for this test.
|
||||
NSubstitute.Substitute.For<IInUseStateInfoProvider>(),
|
||||
|
|
|
@ -614,7 +614,7 @@ namespace TestShareeLib.UseCases.Startup
|
|||
// Add a reserved bike to station "FR101"
|
||||
new BikeInfo(
|
||||
new Bike("Id1", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
123, // Lock id
|
||||
new Guid(),
|
||||
|
@ -653,7 +653,7 @@ namespace TestShareeLib.UseCases.Startup
|
|||
// Add a reserved bike to station "FR101"
|
||||
new BikeInfo(
|
||||
new Bike("Id1", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
new DriveMutable(),
|
||||
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
|
||||
123, // Lock id
|
||||
new Guid(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue