Version 3.0.270

This commit is contained in:
Oliver Hauff 2022-01-04 18:59:16 +01:00
parent 67999ef4ae
commit e0c75d5b37
81 changed files with 812 additions and 474 deletions

View file

@ -19,11 +19,12 @@ namespace TestTINKLib
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null,
string currentStationId = null,
string stationId = null,
string stationName = null,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
{
}
}
@ -43,7 +44,7 @@ namespace TestTINKLib
Assert.AreEqual(WheelType.Two, l_oBike.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBike.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value);
Assert.IsNull(l_oBike.CurrentStation);
Assert.IsNull(l_oBike.StationId);
l_oBike = new BikeInfoMutable(
"17",
@ -59,7 +60,7 @@ namespace TestTINKLib
Assert.AreEqual(WheelType.Mono, l_oBike.WheelType);
Assert.AreEqual(TypeOfBike.Allround, l_oBike.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value);
Assert.AreEqual("1", l_oBike.CurrentStation);
Assert.AreEqual("1", l_oBike.StationId);
}
[Test]

View file

@ -24,7 +24,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
public void TestCtorAvailable()
{
Assert.AreEqual ("12",new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").Id);
Assert.AreEqual("13", new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").CurrentStation);
Assert.AreEqual("13", new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").StationId);
Assert.AreEqual(InUseStateEnum.Disposable, new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value);
}

View file

@ -0,0 +1,18 @@
using NUnit.Framework;
using System;
using TINK.Model.Bike.BluetoothLock;
namespace TestShareeLib.Model.Bike.BluetoothLock
{
[TestFixture]
public class TestBikeInfoMutalbe
{
[Test]
public void TestCtor()
{
Assert.That(
new BikeInfoMutable(new BikeInfo("MyBikeId", 42, new Guid(), "17"), "My Station Name").StationName,
Is.EqualTo("My Station Name"));
}
}
}

View file

@ -4,9 +4,8 @@ using System.Collections.Generic;
using TINK.Model.Bike;
using TINK.Model.Bikes.Bike;
using TINK.Model.State;
using TINK.Model.Station;
using BikeInfo = TINK.Model.Bike.BC.BikeInfo;
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
namespace TestTINKLib
{
@ -23,11 +22,12 @@ namespace TestTINKLib
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null,
string currentStationId = null,
string stationId = null,
string stationName = null,
Uri operatorUri = null,
TariffDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
{
}
}
@ -62,7 +62,7 @@ namespace TestTINKLib
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById("20").State.Value);
Assert.Null(l_oBikeColl.GetById("33"));
l_oBikeColl.Update(null);
l_oBikeColl.Update(null, null );
// Verify modified state
Assert.Null(l_oBikeColl.GetById("63"));
@ -74,36 +74,114 @@ namespace TestTINKLib
[Test]
public void TestUpdate()
{
var l_oBikeRequested = new BikeInfoMutable("20", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround);
l_oBikeRequested.State.Load(new StateInfo(() => DateTime.Now, DateTime.Now, "john@long", "1234"));
var bikeRequested = new BikeInfoMutable("20", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround);
bikeRequested.State.Load(new StateInfo(() => DateTime.Now, DateTime.Now, "john@long", "1234"));
var l_oBikeColl = new BikeCollectionMutable
var bikeColl = new BikeCollectionMutable
{
new BikeInfoMutable("63", false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Allround),
new BikeInfoMutable("57", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo),
l_oBikeRequested,
bikeRequested,
};
// Verify initial state
Assert.NotNull(l_oBikeColl.GetById("63")); // Will be removed
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeColl.GetById("57").State.Value); // Will be requested
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById("20").State.Value); // Will be booked
Assert.Null(l_oBikeColl.GetById("33")); //
Assert.NotNull(bikeColl.GetById("63")); // Will be removed
Assert.AreEqual(InUseStateEnum.Disposable, bikeColl.GetById("57").State.Value); // Will be requested
Assert.AreEqual(InUseStateEnum.Reserved, bikeColl.GetById("20").State.Value); // Will be booked
Assert.Null(bikeColl.GetById("33")); //
var l_oBikeResponse = new List<BikeInfo>
{
new BikeInfo("57", false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7", null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
new BikeInfo("57" /* bike id*/, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
new BikeInfo("20", false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7", null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
new BikeInfo("33", "7", null /*operator uri*/, null, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround),
};
l_oBikeColl.Update(l_oBikeResponse);
bikeColl.Update(l_oBikeResponse, new List<IStation>());
// Verify modified state
Assert.Null(l_oBikeColl.GetById("63"));
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeColl.GetById("57").State.Value);
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeColl.GetById("20").State.Value);
Assert.NotNull(l_oBikeColl.GetById("33"));
Assert.Null(bikeColl.GetById("63"), "Bike not contained in response must not exist.");
Assert.AreEqual(InUseStateEnum.Booked, bikeColl.GetById("57").State.Value);
Assert.AreEqual(InUseStateEnum.Booked, bikeColl.GetById("20").State.Value);
Assert.NotNull(bikeColl.GetById("33"));
}
/// <summary>
/// Bike for which station name is updated is not contained in bike collection when calling update.
/// </summary>
[Test]
public void TestUpdate_StationName_NewBike()
{
var bikeColl = new BikeCollectionMutable();
// Verify initial state
Assert.That(bikeColl.GetById("57"), Is.Null);
var l_oBikeResponse = new List<BikeInfo>
{
new BikeInfo("57" /* bike id*/, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
};
var stations = new List<IStation>
{
new Station("7", new List<string>(), null, "My facy station")
};
bikeColl.Update(l_oBikeResponse, stations);
// Verify modified state
Assert.That(bikeColl.GetById("57").StationId, Is.EqualTo("7"));
Assert.That(bikeColl.GetById("57").StationName, Is.EqualTo("My facy station"));
}
[Test]
public void TestUpdate_StationName_UpdateExistingBike()
{
var bikeColl = new BikeCollectionMutable
{
new BikeInfoMutable("57", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo),
};
// Verify initial state
Assert.That(bikeColl.GetById("57"), Is.Not.Null);
var bikeResponse = new List<BikeInfo>
{
new BikeInfo("57" /* bike id*/, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
};
var stations = new List<IStation>
{
new Station("7", new List<string>(), null, "My facy station")
};
bikeColl.Update(bikeResponse, stations);
// Verify modified state
Assert.That(bikeColl.GetById("57").StationId, Is.Null, "Station id is only set when update creates BikeInfo object, not when updating object BikeInfo because station name does not change.");
Assert.That(bikeColl.GetById("57").StationName, Is.Null, "Station name is only set when update creates BikeInfo object, not when updating object BikeInfo because station name does not change.");
}
[Test]
public void TestUpdate_StationName_Nullstations()
{
var bikeColl = new BikeCollectionMutable();
var l_oBikeResponse = new List<BikeInfo>
{
new BikeInfo("57" /* bike id*/, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
};
bikeColl.Update(l_oBikeResponse, null);
// Verify modified state
Assert.That(bikeColl.GetById("57").StationId, Is.EqualTo("7"));
Assert.That(bikeColl.GetById("57").StationName, Is.EqualTo(""));
}
}
}

View file

@ -352,7 +352,7 @@ namespace TestTINKLib.Fixtures.Connector
Assert.That(btBikeReserved.TariffDescription.MaxFeeEuroPerDay, Is.EqualTo(10));
Assert.That(btBikeReserved.TariffDescription.Number, Is.EqualTo(5494));
Assert.That(btBikeReserved.TariffDescription.Name, Is.EqualTo("Tester Basic"));
Assert.That(btBikeReserved.CurrentStation, Is.EqualTo("FR_103"));
Assert.That(btBikeReserved.StationId, Is.EqualTo("FR_103"));
Assert.That(btBikeReserved.LockInfo.Id, Is.EqualTo(2302373));
Assert.That(btBikeReserved.OperatorUri.AbsoluteUri, Does.Contain("https://shareeapp-fr01.copri.eu"));
Assert.That(btBikeReserved.Group.Count, Is.EqualTo(1));
@ -373,7 +373,7 @@ namespace TestTINKLib.Fixtures.Connector
Assert.That(btBikeRented.TariffDescription.MaxFeeEuroPerDay, Is.EqualTo(10));
Assert.That(btBikeRented.TariffDescription.Number, Is.EqualTo(5494));
Assert.That(btBikeRented.TariffDescription.Name, Is.EqualTo("Tester Basic"));
Assert.That(btBikeRented.CurrentStation, Is.EqualTo("103"));
Assert.That(btBikeRented.StationId, Is.EqualTo("103"));
Assert.That(btBikeRented.LockInfo.Id, Is.EqualTo(2200537));
Assert.That(btBikeRented.OperatorUri.AbsoluteUri, Does.Contain("https://shareeapp-fr01.copri.eu"));
Assert.That(btBikeRented.Group.Count, Is.EqualTo(1));
@ -662,23 +662,24 @@ namespace TestTINKLib.Fixtures.Connector
{
// Construct requested bike.
var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo(
"17",
22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new [] { (byte) 1, (byte)3, (byte)4 },
new [] { (byte)11, (byte)3, (byte)1 },
new [] { (byte)12, (byte)7, (byte)4 },
DateTime.Now,
"a@b",
"1",
null,
null,
() => DateTime.Now,
false, /*isDemo*/
null, /*group*/
null, /*wheelType*/
null, /*typeOfBike*/
null /*description*/));
"17",
22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new [] { (byte) 1, (byte)3, (byte)4 },
new [] { (byte)11, (byte)3, (byte)1 },
new [] { (byte)12, (byte)7, (byte)4 },
DateTime.Now,
"a@b",
"1",
null,
null,
() => DateTime.Now,
false, /*isDemo*/
null, /*group*/
null, /*wheelType*/
null, /*typeOfBike*/
null /*description*/),
"My Station Name");
var response = JsonConvert.DeserializeObject<BikeInfoReservedOrBooked>(@"
{
@ -702,16 +703,17 @@ namespace TestTINKLib.Fixtures.Connector
{
// Construct occupied bike.
var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo(
"17",
22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new[] { (byte)1, (byte)3, (byte)4 },
new[] { (byte)11, (byte)3, (byte)1 },
new[] { (byte)12, (byte)7, (byte)4 },
DateTime.Now,
"a@b",
"1",
null /*operator uri*/));
"17",
22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new[] { (byte)1, (byte)3, (byte)4 },
new[] { (byte)11, (byte)3, (byte)1 },
new[] { (byte)12, (byte)7, (byte)4 },
DateTime.Now,
"a@b",
"1",
null /*operator uri*/),
"My Station Name");
var response = JsonConvert.DeserializeObject<BikeInfoReservedOrBooked>(@"
{
@ -735,23 +737,24 @@ namespace TestTINKLib.Fixtures.Connector
{
// Construct requested bike.
var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo(
"17",
22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new[] { (byte)1, (byte)3, (byte)4 },
new[] { (byte)11, (byte)3, (byte)1 },
new[] { (byte)12, (byte)7, (byte)4 },
DateTime.Now,
"a@b",
"1",
null,
null,
() => DateTime.Now,
false, /*isDemo*/
null, /*group*/
null, /*wheelType*/
null, /*typeOfBike*/
null /*description*/));
"17",
22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new[] { (byte)1, (byte)3, (byte)4 },
new[] { (byte)11, (byte)3, (byte)1 },
new[] { (byte)12, (byte)7, (byte)4 },
DateTime.Now,
"a@b",
"1",
null,
null,
() => DateTime.Now,
false, /*isDemo*/
null, /*group*/
null, /*wheelType*/
null, /*typeOfBike*/
null /*description*/),
"My Station Name");
Assert.AreEqual(InUseStateEnum.Reserved, bike.State.Value);

View file

@ -13,6 +13,7 @@ using Plugin.Permissions.Abstractions;
using TestShareeLib.Repository;
using TestFramework.Repository;
using TINK.Repository;
namespace TestTINKLib.Fixtures.UseCases.Logout
{
@ -42,8 +43,9 @@ namespace TestTINKLib.Fixtures.UseCases.Logout
activeUri: new Uri(CopriServerUriList.TINK_DEVEL)),
accountStore,
(isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie)
? new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001())
: new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001())
: new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(),
locksService,
device,

View file

@ -12,6 +12,7 @@ using TINK.Model.User.Account;
using Plugin.Permissions.Abstractions;
using System.Threading.Tasks;
using TestFramework.Repository;
using TINK.Repository;
namespace TestShareeLib.UseCases.Login
{
@ -28,15 +29,16 @@ namespace TestShareeLib.UseCases.Login
var permissions = Substitute.For<IPermissions>();
// No user logged in is initial state to verify.
var l_oTinkApp = new TinkApp(
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
activeLockService: locksService.GetType().FullName,
activeGeolocationService: "NotRelevantActiveGeoloactionServiceName",
activeUri: new Uri(CopriServerUriList.TINK_DEVEL)),
accountStore,
(isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie)
? new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001()) as IConnector
: new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001())
: new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(),
locksService,
device,
@ -47,31 +49,32 @@ namespace TestShareeLib.UseCases.Login
currentVersion: new Version(3, 2, 0, 115),
lastVersion: new Version(3, 0, 173) /* Current app version. Must be larger or equal 3.0.173 to lastVersion*/);
Assert.IsFalse(l_oTinkApp.ActiveUser.IsLoggedIn);
// Verifiy initial state.
Assert.IsFalse(tinkApp.ActiveUser.IsLoggedIn);
Assert.AreEqual(
8,
l_oTinkApp.GetConnector(true).Query.GetBikesAsync().Result.Response.Count,
tinkApp.GetConnector(true).Query.GetBikesAsync().Result.Response.Count,
"Sum of bikes is 6 occupied, no one occupied because no user is logged in");
Assert.AreEqual(
0,
l_oTinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count,
tinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count,
"If no user is logged in no occupied bikes are shown.");
Assert.IsNull(l_oTinkApp.GetConnector(true).Command.SessionCookie);
Assert.IsNull(tinkApp.GetConnector(true).Command.SessionCookie);
// Log user out.
var l_oAccount = l_oTinkApp.GetConnector(true).Command.DoLogin("javaminister@gmail.com", "*********", "HwId1000000000000").Result;
await l_oTinkApp.ActiveUser.Login(l_oAccount);
// Log in user.
var account = tinkApp.GetConnector(true).Command.DoLogin("javaminister@gmail.com", "*********", "HwId1000000000000").Result;
await tinkApp.ActiveUser.Login(account);
Assert.IsTrue(l_oTinkApp.ActiveUser.IsLoggedIn);
Assert.IsTrue(tinkApp.ActiveUser.IsLoggedIn);
Assert.AreEqual(
10,
l_oTinkApp.GetConnector(true).Query.GetBikesAsync().Result.Response.Count,
tinkApp.GetConnector(true).Query.GetBikesAsync().Result.Response.Count,
"Sum of bikes is 6 occupied plus 2 occupied.");
Assert.AreEqual(
2,
l_oTinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count,
tinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count,
"Javaminster occupies 2 bikes.");
Assert.AreEqual("6103_112e96b36ba33de245943c5ffaf369cd_", l_oTinkApp.GetConnector(true).Command.SessionCookie);
Assert.AreEqual("6103_112e96b36ba33de245943c5ffaf369cd_oiF2kahH", tinkApp.GetConnector(true).Command.SessionCookie);
}
}
}