mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-19 11:37:28 +02:00
Version 3.0.360
This commit is contained in:
parent
5c0b2e70c9
commit
faf68061f4
160 changed files with 2114 additions and 1932 deletions
105
TestShareeLib/Services/CopriApi/TestPolling.cs
Normal file
105
TestShareeLib/Services/CopriApi/TestPolling.cs
Normal file
|
@ -0,0 +1,105 @@
|
|||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.CopriLock;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Services.CopriApi;
|
||||
using TINK.Repository.Request;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Repository.Response;
|
||||
using TINK.Repository;
|
||||
|
||||
namespace TestShareeLib.Services.CopriApi
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestPolling
|
||||
{
|
||||
[Test]
|
||||
public async Task TestOpenAyncLockStateUnknownDisconnected()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
|
||||
bike.Id.Returns("XY19");
|
||||
bike.OperatorUri.Returns(new System.Uri("https://1.2.3.4"));
|
||||
|
||||
|
||||
await Polling.OpenAync(server, bike);
|
||||
|
||||
Received.InOrder(
|
||||
() =>
|
||||
{
|
||||
server.UpdateLockingStateAsync(
|
||||
"XY19",
|
||||
lock_state.unlocking,
|
||||
new System.Uri("https://1.2.3.4"));
|
||||
|
||||
bike.LockInfo.State = LockingState.UnknownDisconnected;
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestOpenAyncLock()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
var bike = Substitute.For<IBikeInfoMutable>();
|
||||
|
||||
bike.Id.Returns("XY19");
|
||||
bike.OperatorUri.Returns(new System.Uri("https://1.2.3.4"));
|
||||
|
||||
server.GetBikesOccupied(false).Returns(
|
||||
new Result<BikesReservedOccupiedResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
JsonConvertRethrow.DeserializeObject<BikesReservedOccupiedResponse>(@"
|
||||
{
|
||||
""bikes_occupied"": {
|
||||
""FR1005"": {
|
||||
""lock_state"": ""occupied"",
|
||||
""system"": ""Sigo"",
|
||||
""state"": ""occupied"",
|
||||
""bike"": ""XY19"",
|
||||
""station"": ""REN0"",
|
||||
""lock_state"" : ""locked""
|
||||
}
|
||||
},
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}"),
|
||||
new GeneralData()),
|
||||
new Result<BikesReservedOccupiedResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
JsonConvertRethrow.DeserializeObject<BikesReservedOccupiedResponse>(@"
|
||||
{
|
||||
""bikes_occupied"": {
|
||||
""FR1005"": {
|
||||
""lock_state"": ""occupied"",
|
||||
""system"": ""Sigo"",
|
||||
""state"": ""occupied"",
|
||||
""bike"": ""XY19"",
|
||||
""station"": ""REN0"",
|
||||
""lock_state"" : ""unlocked""
|
||||
}
|
||||
},
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}"),
|
||||
new GeneralData()));
|
||||
|
||||
|
||||
await Polling.OpenAync(server, bike);
|
||||
|
||||
Received.InOrder(
|
||||
() =>
|
||||
{
|
||||
server.UpdateLockingStateAsync(
|
||||
"XY19",
|
||||
lock_state.unlocking,
|
||||
new System.Uri("https://1.2.3.4"));
|
||||
|
||||
server.GetBikesOccupied(false);
|
||||
server.GetBikesOccupied(false);
|
||||
|
||||
bike.LockInfo.State = LockingState.Open;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue