mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 03:27:29 +02:00
Closing lock and returning bike speeded up.
This commit is contained in:
parent
e4adeb908c
commit
db9c288584
70 changed files with 933 additions and 902 deletions
|
@ -21,6 +21,7 @@ using TINK.Repository.Response;
|
|||
using Newtonsoft.Json;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
using System.Threading;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -84,7 +85,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(false));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(false));
|
||||
|
||||
var subsequent = handler.HandleRequestOption1().Result;
|
||||
|
||||
|
@ -94,7 +95,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein");
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No");
|
||||
bikesViewModel.Received(1).IsIdle = true; // GUI must be unlocked
|
||||
});
|
||||
|
||||
|
@ -136,7 +137,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Disconnected); // Simulate bike out of reach.
|
||||
|
||||
|
@ -150,7 +151,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Is<LocationDto>(x => x == null));
|
||||
bikesViewModel.ActionText = "Disconnecting lock...";
|
||||
locks.DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
@ -198,11 +199,11 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
geolocation.GetAsync(Arg.Any<DateTime>()).Returns(Task.FromResult(
|
||||
geolocation.GetAsync(Arg.Any< CancellationToken?>(), Arg.Any<DateTime>()).Returns(Task.FromResult(
|
||||
new Xamarin.Essentials.Location(7, 9)
|
||||
));
|
||||
|
||||
|
@ -215,11 +216,11 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
geolocation.GetAsync(Arg.Any<CancellationToken?>(), Arg.Any<DateTime>());
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
geolocation.GetAsync(Arg.Any<DateTime>());
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Is<LocationDto>(x => x != null));
|
||||
bikesViewModel.ActionText = "Disconnecting lock...";
|
||||
locks.DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
@ -267,11 +268,11 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
geolocation.GetAsync(Arg.Any<DateTime>()).Returns<Xamarin.Essentials.Location>(x => throw new Exception());
|
||||
geolocation.GetAsync(Arg.Any<CancellationToken?>(), Arg.Any<DateTime>()).Returns<Xamarin.Essentials.Location>(x => throw new Exception());
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Disposable); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
bike.LockInfo.State.Returns(LockingState.Closed); // Requsthandler factory queries lock state to create appropriate request handler object.
|
||||
|
@ -282,11 +283,11 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
geolocation.GetAsync(Arg.Any<CancellationToken?>(), Arg.Any<DateTime>());
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
geolocation.GetAsync(Arg.Any<DateTime>());
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Is<LocationDto>(x => x == null));
|
||||
bikesViewModel.ActionText = "Disconnecting lock...";
|
||||
locks.DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
@ -334,7 +335,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
|
@ -355,10 +356,14 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Verbingungsfehler beim Zurückgeben des Rads!", "Internet muss erreichbar sein zum Zurückgeben des Rads.\r\nContext info\r\nIst WLAN verfügbar/ Mobilfunknetz vefügbar und mobile Daten aktiviert / ... ?", "OK");
|
||||
viewService.DisplayAdvancedAlert(
|
||||
"Connection error when returning the bike!",
|
||||
"Internet must be available when returning the bike.\r\nIst WLAN verfügbar/ Mobilfunknetz vefügbar und mobile Daten aktiviert / ... ?",
|
||||
"Context info",
|
||||
"OK");
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
pollingManager.StartUpdateAyncPeridically(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = "";
|
||||
|
@ -403,7 +408,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
|
@ -425,7 +430,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Error returning bike!", "Returning bike outside of station is not possible. Distance to station 42 is 15986 m.", "OK");
|
||||
|
@ -473,7 +478,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
|
@ -495,7 +500,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Error returning bike!", "Returning bike at an unknown location is not possible.\r\nBike can be returned if\r\n- location information is available when closing lock\r\n- bike is in reach and location information is available when pressing button \"Return bike\"", "OK");
|
||||
|
@ -543,7 +548,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
|
@ -563,7 +568,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAdvancedAlert("Statusfehler beim Zurückgeben des Rads!", "Outer message.", "Some invalid data received!", "OK");
|
||||
|
@ -611,7 +616,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].GetDeviceState().Returns(DeviceState.Connected); // Simulate bike in reach. If bike is out of reach bluetooth state changes to unknown.
|
||||
|
||||
|
@ -630,7 +635,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>());
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Fehler beim Zurückgeben des Rads!", "Exception message.", "OK");
|
||||
|
|
|
@ -22,6 +22,7 @@ using Newtonsoft.Json;
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
using System.Threading;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -84,7 +85,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
bikesViewModel,
|
||||
activeUser);
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 Allround Mono abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(false));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0 Allround Mono?", "Yes", "No").Returns(Task.FromResult(false));
|
||||
|
||||
var subsequent = handler.HandleRequestOption1().Result;
|
||||
|
||||
|
@ -134,12 +135,12 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns(Task.FromResult((LockitLockingState?)LockitLockingState.Closed)); // Return lock state indicating success
|
||||
|
||||
geolocation.GetAsync(Arg.Any<DateTime>()).Returns(Task.FromResult(new Location(1, 2)));
|
||||
geolocation.GetAsync(Arg.Any<CancellationToken?>(), Arg.Any<DateTime>()).Returns(Task.FromResult(new Location(1, 2)));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Disposable); // Return call leads to setting of state to disposable.
|
||||
|
||||
|
@ -149,13 +150,13 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
Received.InOrder(() =>
|
||||
{
|
||||
bikesViewModel.Received(1).IsIdle = false; // GUI must be locked
|
||||
geolocation.GetAsync(Arg.Any<CancellationToken?>(), Arg.Any<DateTime>()); // Geolocation must be retrieved
|
||||
bikesViewModel.ActionText = "One moment please...";
|
||||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Closing lock...";
|
||||
locks.Received()[0].CloseAsync(); // Lock must be closed
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
geolocation.GetAsync(Arg.Any<DateTime>()); // Geolocation must be retrieved
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
connector.Command.DoReturn(bike, Arg.Is<LocationDto>(x => x.Latitude == 1 && x.Longitude ==2), Arg.Any<ISmartDevice>()); // Booking must be performed
|
||||
bikesViewModel.ActionText = "Disconnecting lock...";
|
||||
locks.DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
@ -203,7 +204,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns< LockitLockingState?>(x => throw new OutOfReachException());
|
||||
|
@ -269,7 +270,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns<LockitLockingState?>(x => throw new System.Exception("Blu"));
|
||||
|
@ -335,7 +336,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Open);
|
||||
|
@ -374,7 +375,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
/// Final state: Booked locked.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCloseAndReturnGetGeolocationFailsException()
|
||||
public async Task TestCloseAndReturnGetGeolocationFailsException()
|
||||
{
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
var connector = Substitute.For<IConnector>();
|
||||
|
@ -400,18 +401,18 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
||||
geolocation.GetAsync(Arg.Any<DateTime>()).Returns<Location>(x => throw new System.Exception("noloc"));
|
||||
geolocation.GetAsync(Arg.Any<CancellationToken?>(), Arg.Any<DateTime>()).Returns(Task.FromException<Location>(new Exception("noloc")));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
||||
var subsequent = handler.HandleRequestOption1().Result;
|
||||
var subsequent = await handler.HandleRequestOption1();
|
||||
|
||||
locks.DidNotReceive().DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
await locks.DidNotReceive().DisconnectAsync(Arg.Any<int>(), Arg.Any<Guid>());
|
||||
|
||||
// Verify behaviour
|
||||
Received.InOrder(() =>
|
||||
|
@ -421,9 +422,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Closing lock...";
|
||||
locks.Received()[0].CloseAsync(); // Lock must be closed
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Fehler bei Standortabfrage!", "Schloss schließen und Miete beenden ist nicht möglich.\r\nnoloc", "OK");
|
||||
viewService.DisplayAdvancedAlert("Error Query Location!", "Closing the lock and ending the rental is not possible.", "noloc", "OK");
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
pollingManager.StartUpdateAyncPeridically(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = "";
|
||||
|
@ -468,7 +469,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
@ -489,10 +490,14 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Closing lock...";
|
||||
locks.Received()[0].CloseAsync(); // Lock must be closed
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Verbingungsfehler beim Zurückgeben des Rads!", "Internet muss erreichbar sein beim Zurückgeben des Rads.\r\nContext info\r\nIst WLAN verfügbar/ Mobilfunknetz vefügbar und mobile Daten aktiviert / ... ?", "OK");
|
||||
viewService.DisplayAdvancedAlert(
|
||||
"Connection error when returning the bike!",
|
||||
"Internet must be available when returning the bike.\r\nIst WLAN verfügbar/ Mobilfunknetz vefügbar und mobile Daten aktiviert / ... ?",
|
||||
"Context info",
|
||||
"OK");
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
pollingManager.StartUpdateAyncPeridically(); // polling must be restarted again
|
||||
bikesViewModel.ActionText = "";
|
||||
|
@ -537,7 +542,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
@ -558,8 +563,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Closing lock...";
|
||||
locks.Received()[0].CloseAsync(); // Lock must be closed
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Fehler beim Zurückgeben des Rads!", "Exception message.", "OK");
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
|
@ -606,7 +611,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
@ -630,8 +635,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Closing lock...";
|
||||
locks.Received()[0].CloseAsync(); // Lock must be closed
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Error returning bike!", "Returning bike outside of station is not possible. Distance to station 77 is 15986 m.", "OK");
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
|
@ -678,7 +683,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
@ -702,8 +707,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Closing lock...";
|
||||
locks.Received()[0].CloseAsync(); // Lock must be closed
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAlert("Error returning bike!", "Returning bike at an unknown location is not possible.\r\nBike can only be returned if bike is in reach and location information is available.", "OK");
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
|
@ -750,7 +755,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
|
||||
bike.Id.Returns("0");
|
||||
|
||||
viewService.DisplayAlert(string.Empty, "Fahrrad Nr. 0 abschließen und zurückgeben?", "Ja", "Nein").Returns(Task.FromResult(true));
|
||||
viewService.DisplayAlert(string.Empty, "Close lock and return bike Nr. 0?", "Yes", "No").Returns(Task.FromResult(true));
|
||||
|
||||
locks[0].CloseAsync()
|
||||
.Returns(LockitLockingState.Closed);
|
||||
|
@ -772,8 +777,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
|
|||
pollingManager.StopUpdatePeridically(); // Polling must be stopped before any COPR and lock service action
|
||||
bikesViewModel.ActionText = "Closing lock...";
|
||||
locks.Received()[0].CloseAsync(); // Lock must be closed
|
||||
bikesViewModel.ActionText = "Abfrage Standort...";
|
||||
bikesViewModel.ActionText = "Gebe Rad zurück...";
|
||||
bikesViewModel.ActionText = "Query location...";
|
||||
bikesViewModel.ActionText = "Returning bike...";
|
||||
bikesViewModel.ActionText = "";
|
||||
viewService.DisplayAdvancedAlert("Statusfehler beim Zurückgeben des Rads!", "Outer message.", "Some invalid data received!", "OK");
|
||||
bikesViewModel.ActionText = "Updating...";
|
||||
|
|
|
@ -487,7 +487,10 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
|
|||
"OK");
|
||||
});
|
||||
|
||||
Assert.IsEmpty(myBikes.StatusInfoText);
|
||||
Assert.That(
|
||||
myBikes.StatusInfoText,
|
||||
Is.Empty,
|
||||
"Status info text must be empty.");
|
||||
|
||||
Assert.AreEqual(2, myBikes.Count);
|
||||
Assert.IsTrue(myBikes.IsIdle);
|
||||
|
@ -501,7 +504,10 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
|
|||
Assert.AreEqual("Search lock", bike1537.LockitButtonText);
|
||||
|
||||
Assert.IsFalse(myBikes.IsNoBikesOccupiedVisible);
|
||||
Assert.IsEmpty(myBikes.NoBikesOccupiedText);
|
||||
Assert.That(
|
||||
myBikes.NoBikesOccupiedText,
|
||||
Is.Empty,
|
||||
"Label which informs that no bikes are reserved/ rented must be empty.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue