Manually merged.

This commit is contained in:
Oliver Hauff 2021-12-08 17:57:30 +01:00
parent d5832e010e
commit c7c9f252af
112 changed files with 1127 additions and 352 deletions

View file

@ -23,6 +23,7 @@ using TestFramework.Repository;
using TestFramework.Model.User.Account;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.BluetoothLock;
using TestFramework.Services.Permissions;
using TestFramework.Services.CopriApi.Connector;
namespace TestTINKLib.Fixtures.ObjectTests.Account

View file

@ -20,8 +20,8 @@ using TINK.Repository.Request;
using TINK.Repository.Response;
using Newtonsoft.Json;
using TINK.Model.Device;
using TINK.Model.MiniSurvey;
using System.Threading;
using TINK.Model;
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
{
@ -339,7 +339,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
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<MiniSurveyModel>(x => throw new WebConnectFailureException("Context info", new Exception("hoppla")));
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x => throw new WebConnectFailureException("Context info", new Exception("hoppla")));
bike.State.Value.Returns(InUseStateEnum.Booked); // 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.
@ -414,7 +414,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
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<MiniSurveyModel>(x =>
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x =>
throw notAtStationException);
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
@ -484,7 +484,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
NoGPSDataException.IsNoGPSData("Failure 2245: No GPS data, state change forbidden.", out NoGPSDataException noGPSDataException);
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x =>
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x =>
throw noGPSDataException);
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
@ -552,8 +552,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
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<MiniSurveyModel>(x =>
throw new ReturnBikeException(JsonConvert.DeserializeObject<ReservationCancelReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
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); // 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.
@ -620,7 +620,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
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<MiniSurveyModel>(x => throw new Exception("Exception message."));
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<BookingFinishedModel>(x => throw new Exception("Exception message."));
bike.State.Value.Returns(InUseStateEnum.Booked); // 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.
@ -1305,7 +1305,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
.Returns(LockitLockingState.Open);
connector.Command.UpdateLockingStateAsync(bike, Arg.Any<LocationDto>()).Returns(x =>
throw new ReturnBikeException(JsonConvert.DeserializeObject<ReservationCancelReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
throw new ReturnBikeException(JsonConvert.DeserializeObject<DoReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
bike.State.Value.Returns(InUseStateEnum.Booked);
bike.LockInfo.State.Returns(LockingState.Open);

View file

@ -21,8 +21,8 @@ using TINK.Repository.Request;
using Newtonsoft.Json;
using TINK.Repository.Response;
using TINK.Model.Device;
using TINK.Model.MiniSurvey;
using System.Threading;
using TINK.Model;
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
{
@ -474,7 +474,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
locks[0].CloseAsync()
.Returns(LockitLockingState.Closed);
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x => throw new WebConnectFailureException("Context info", new System.Exception("hoppla")));
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<BookingFinishedModel>(x => throw new WebConnectFailureException("Context info", new System.Exception("hoppla")));
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
@ -547,7 +547,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
locks[0].CloseAsync()
.Returns(LockitLockingState.Closed);
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x => throw new System.Exception("Exception message."));
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<BookingFinishedModel>(x => throw new System.Exception("Exception message."));
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
@ -618,7 +618,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
NotAtStationException.IsNotAtStation("Failure 2178: bike 1545 out of GEO fencing. 15986 meter distance to next station 77. OK: bike 1545 locked confirmed", out NotAtStationException notAtStationException);
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x =>
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<BookingFinishedModel>(x =>
throw notAtStationException);
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
@ -690,7 +690,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
NoGPSDataException.IsNoGPSData("Failure 2245: No GPS data, state change forbidden.", out NoGPSDataException noGPSDataException);
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x =>
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<BookingFinishedModel>(x =>
throw noGPSDataException);
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
@ -760,8 +760,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
locks[0].CloseAsync()
.Returns(LockitLockingState.Closed);
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x =>
throw new ReturnBikeException(JsonConvert.DeserializeObject<ReservationCancelReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<BookingFinishedModel>(x =>
throw new ReturnBikeException(JsonConvert.DeserializeObject<DoReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
@ -1130,7 +1130,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.Re
.Returns(LockitLockingState.Closed); // Return lock state indicating success
connector.Command.UpdateLockingStateAsync(bike, Arg.Any<LocationDto>()).Returns(x =>
throw new ReturnBikeException(JsonConvert.DeserializeObject<ReservationCancelReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
throw new ReturnBikeException(JsonConvert.DeserializeObject<DoReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
bike.State.Value.Returns(InUseStateEnum.Booked);

View file

@ -19,6 +19,7 @@ using TestFramework.Services.BluetoothLock;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Model.User.Account;
using TestFramework.Model.Device;
using TestFramework.Services.Permissions;
using TestFramework.Repository;
using TestFramework.Services.CopriApi.Connector;
@ -78,7 +79,7 @@ namespace TestShareeLib.UseCases.Startup
Assert.AreEqual(21, viewModel.Pins.Count); // Were 8 pins when loading from CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Green")).Tag,
Is.EqualTo("FR103"),
Is.EqualTo("FR105"),
"Station FR105 must be marked green because there is are bike.");
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Red")).Tag,

View file

@ -28,6 +28,7 @@ using TestFramework.Model.Device;
using TestFramework.Repository;
using TestFramework.Model.User.Account;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.Permissions;
using TestFramework.Services.CopriApi.Connector;
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
@ -61,6 +62,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -132,6 +134,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -208,6 +211,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -308,6 +312,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -414,6 +419,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -517,6 +523,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -618,6 +625,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version

View file

@ -28,6 +28,7 @@ using TestFramework.Model.Device;
using TestFramework.Repository;
using TestFramework.Model.User.Account;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.Permissions;
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
{
@ -76,6 +77,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -166,6 +168,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -264,6 +267,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -357,6 +361,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -448,6 +453,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions,
isConnectedFunc: () => true,
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -593,6 +599,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions
isConnectedFunc: () => false, // Offline
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version
@ -744,6 +751,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new DeviceMock(),
new SpecialFolderMock(),
null, // Cipher
null, // Permissions.
isConnectedFunc: () => false, // Offline
postAction: (d, obj) => d(obj),
currentVersion: new Version(3, 2, 0, 115), // Current app version