mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 20:46:28 +02:00
Mini survey added.
Minor fiexes.
This commit is contained in:
parent
ddfea49ea6
commit
e321764119
73 changed files with 1628 additions and 185 deletions
|
@ -1,70 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Repository.Request;
|
||||
|
||||
namespace UITest.Fixtures.ObjectTests.Connector.Request
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestRequestBuilder
|
||||
{
|
||||
[Test]
|
||||
public void TestDoAuthorize()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=authorization&merchant_id=123&user_id=abc%40cde&user_pw=%2B%3F&hw_id=789",
|
||||
new RequestBuilder("123").DoAuthorization("abc@cde", "+?", "789"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoAuthout()
|
||||
{
|
||||
Assert.Throws<CallNotRequiredException>(() =>
|
||||
new RequestBuilder("123").DoAuthout());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetBikesAvailable()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=bikes_available&system=all&authcookie=123",
|
||||
new RequestBuilder("123").GetBikesAvailable());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetBikesOccupied()
|
||||
{
|
||||
Assert.Throws< NotSupportedException>(() =>
|
||||
new RequestBuilder("123").GetBikesOccupied());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetStations()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=stations_available&authcookie=123",
|
||||
new RequestBuilder("123").GetStations());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoReserve()
|
||||
{
|
||||
Assert.Throws<NotSupportedException>(() =>
|
||||
new RequestBuilder("123").DoReserve("42"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoCancelReservation()
|
||||
{
|
||||
Assert.Throws<NotSupportedException>(() =>
|
||||
new RequestBuilder("123").DoCancelReservation("42"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoSubmitFeedback()
|
||||
{
|
||||
Assert.Throws<NotSupportedException>(() =>
|
||||
new RequestBuilder("123").DoSubmitFeedback("bike3", "Hi", false));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Repository.Request;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Connector.Request
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestRequestBuilderLoggedIn
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void TestDoAuthorize()
|
||||
{
|
||||
Assert.Throws <CallNotRequiredException>(() =>new RequestBuilderLoggedIn("123", "456").DoAuthorization("abc@cde", "+?", "789"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoAuthout()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=authout&authcookie=456123",
|
||||
new RequestBuilderLoggedIn ("123", "456").DoAuthout());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetBikesAvailable()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=bikes_available&system=all&authcookie=456123",
|
||||
new RequestBuilderLoggedIn("123", "456").GetBikesAvailable());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetBikesAvailable_Null()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
new RequestBuilderLoggedIn("123", null).GetBikesAvailable());
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
new RequestBuilderLoggedIn("123", string.Empty).GetBikesAvailable());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetBikesOccupied()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=user_bikes_occupied&system=all&genkey=1&authcookie=456123",
|
||||
new RequestBuilderLoggedIn("123", "456").GetBikesOccupied());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetBikesOccupied_Null()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
new RequestBuilderLoggedIn("123", null).GetBikesOccupied());
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
new RequestBuilderLoggedIn("123", "").GetBikesOccupied());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetStations()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=stations_available&authcookie=456123",
|
||||
new RequestBuilderLoggedIn("123", "456").GetStations());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetStations_Null()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
new RequestBuilderLoggedIn("123", string.Empty).GetStations());
|
||||
|
||||
Assert.Throws<ArgumentException>(() =>
|
||||
new RequestBuilderLoggedIn("123", null).GetStations());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoReserve()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=booking_request&bike=42&authcookie=456123",
|
||||
new RequestBuilderLoggedIn("123", "456").DoReserve("42"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoCancelReservation()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=booking_cancel&bike=42&authcookie=456123",
|
||||
new RequestBuilderLoggedIn("123", "456").DoCancelReservation("42"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoBook()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=booking_update&bike=42&authcookie=456123&Ilockit_GUID=0000f00d-1212-efde-1523-785fef13d123&state=occupied&lock_state=unlocked&voltage=33.21",
|
||||
new RequestBuilderLoggedIn("123", "456").DoBook("42", new Guid("0000f00d-1212-efde-1523-785fef13d123"),33.21));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDoBookNoBatery()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
"request=booking_update&bike=42&authcookie=456123&Ilockit_GUID=0000f00d-1212-efde-1523-785fef13d123&state=occupied&lock_state=unlocked",
|
||||
new RequestBuilderLoggedIn("123", "456").DoBook("42", new Guid("0000f00d-1212-efde-1523-785fef13d123"), double.NaN));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ using TINK.Repository.Request;
|
|||
using TINK.Repository.Response;
|
||||
using Newtonsoft.Json;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -337,7 +338,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(x => throw new WebConnectFailureException("Context info", new Exception("hoppla")));
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(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.
|
||||
|
@ -408,7 +409,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(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x =>
|
||||
throw notAtStationException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
|
@ -478,7 +479,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(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x =>
|
||||
throw noGPSDataException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
|
@ -546,7 +547,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(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(x =>
|
||||
throw new ReturnBikeException(JsonConvert.DeserializeObject<ReservationCancelReturnResponse>(@"{ ""response_text"" : ""Some invalid data received!""}"), "Outer message."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Reqesthandler factory queries state to create appropriate request handler object.
|
||||
|
@ -614,7 +615,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(x => throw new Exception("Exception message."));
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>()).Returns<MiniSurveyModel>(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.
|
||||
|
|
|
@ -21,6 +21,7 @@ using TINK.Repository.Request;
|
|||
using Newtonsoft.Json;
|
||||
using TINK.Repository.Response;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.MiniSurvey;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel.Bikes.Bike.BluetoothLock.RequestHandler
|
||||
{
|
||||
|
@ -472,7 +473,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(x => throw new WebConnectFailureException("Context info", new System.Exception("hoppla")));
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x => throw new WebConnectFailureException("Context info", new System.Exception("hoppla")));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
||||
|
@ -541,7 +542,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(x => throw new System.Exception("Exception message."));
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x => throw new System.Exception("Exception message."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
||||
|
@ -612,7 +613,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(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x =>
|
||||
throw notAtStationException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
@ -684,7 +685,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(x =>
|
||||
connector.Command.DoReturn(bike, Arg.Any<LocationDto>(), Arg.Any<ISmartDevice>()).Returns<MiniSurveyModel>(x =>
|
||||
throw noGPSDataException);
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
@ -754,7 +755,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(x =>
|
||||
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."));
|
||||
|
||||
bike.State.Value.Returns(InUseStateEnum.Booked); // Booking state remains unchanged if closing fails.
|
||||
|
|
|
@ -6,6 +6,7 @@ using TINK.Repository.Response;
|
|||
using static TINK.Repository.CopriCallsMemory;
|
||||
using TINK.Repository.Request;
|
||||
using TINK.Model.Device;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TestTINKLib.Mocks.Connector
|
||||
{
|
||||
|
@ -88,6 +89,11 @@ namespace TestTINKLib.Mocks.Connector
|
|||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
{
|
||||
return server.GetBikesAvailableAsync();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
|
@ -64,6 +65,11 @@ namespace TestTINKLib.Mocks.Connector
|
|||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetBikesAvailableAsync)}.");
|
||||
|
|
|
@ -70,8 +70,6 @@
|
|||
<Compile Include="Fixtures\ObjectTests\Connector\TestConnectorCache.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestCopriCallsHttps.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestCopriCallsStatic.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\Request\TestRequestBuilder.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\Request\TestRequestBuilderLoggedIn.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\Response\TestResponseHelper.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestCommandLoggedIn.cs" />
|
||||
<Compile Include="Fixtures\ObjectTests\Connector\TestConnector.cs" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue