Version 3.0.360

This commit is contained in:
Anja 2023-02-22 14:03:35 +01:00
parent 5c0b2e70c9
commit faf68061f4
160 changed files with 2114 additions and 1932 deletions

View file

@ -1,27 +0,0 @@
using System;
using NUnit.Framework;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
namespace TestShareeLib.Model.Bike.BluetoothLock
{
[TestFixture]
public class TestBikeInfoMutalbe
{
[Test]
public void TestCtor()
{
Assert.That(
new BikeInfoMutable(new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("MyBikeId", TINK.Model.Bikes.BikeInfoNS.BikeNS.LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 42, new Guid(), "17"), "My Station Name").StationName,
Is.EqualTo("My Station Name"));
}
[Test]
public void TestCtorBikeNull()
{
Assert.That(
() => new BikeInfoMutable(null, "My Station Name"),
Throws.ArgumentNullException);
}
}
}

View file

@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using NSubstitute;
using NUnit.Framework;
using TINK.Model.Bikes.BikeInfoNS;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.State;
using IBikeInfo = TINK.Model.Bikes.BikeInfoNS.BC.IBikeInfo;
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
[TestFixture]
public class TestBikeInfoMutable
{
private class BikeInfoMutable : TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable
{
public BikeInfoMutable(
string id,
LockModel lockModel,
bool isDemo = false,
IEnumerable<string> group = null,
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null,
string stationId = null,
string stationName = null,
Uri operatorUri = null,
RentalDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null) : base(
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike(id, lockModel, wheelType, typeOfBike, description),
new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(),
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
isDemo,
group,
stationId,
stationName,
operatorUri,
tariffDescription,
dateTimeProvider,
stateInfo)
{
}
}
[Test]
public void TestConstruct()
{
var l_oBikeInfo = new BikeInfoMutable("17", LockModel.ILockIt);
Assert.AreEqual("17", l_oBikeInfo.Id);
Assert.IsNull(l_oBikeInfo.StationId);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.AreEqual(null, l_oBikeInfo.WheelType);
Assert.AreEqual(null, l_oBikeInfo.TypeOfBike);
l_oBikeInfo = new BikeInfoMutable("22", LockModel.ILockIt, false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo, "Test description", "23");
Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.IsFalse(l_oBikeInfo.IsDemo);
Assert.AreEqual("23", l_oBikeInfo.StationId);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
}
[Test]
public void TestConstructCopyBooked()
{
// State Booked
var bikeInfoSource = Substitute.For<IBikeInfo>();
var stateSource = Substitute.For<IStateInfo>();
bikeInfoSource.Bike.Returns(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.BordComputer, WheelType.Trike, TypeOfBike.Cargo));
bikeInfoSource.StationId.Returns("23");
bikeInfoSource.State.Returns(stateSource);
stateSource.Value.Returns(InUseStateEnum.Booked);
stateSource.From.Returns(new System.DateTime(2018, 01, 03));
stateSource.MailAddress.Returns("a@b");
stateSource.Code.Returns("234");
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
Assert.AreEqual(InUseStateEnum.Booked, bikeInfoTarget.State.Value);
Assert.AreEqual("22", bikeInfoTarget.Id);
Assert.AreEqual("23", bikeInfoTarget.StationId);
Assert.AreEqual("My Station Name", bikeInfoTarget.StationName);
Assert.AreEqual(WheelType.Trike, bikeInfoTarget.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, bikeInfoTarget.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Booked, bikeInfoTarget.State.Value);
Assert.AreEqual(new System.DateTime(2018, 01, 03), bikeInfoTarget.State.From);
Assert.AreEqual("a@b", bikeInfoTarget.State.MailAddress);
}
[Test]
public void TestConstructCopyReserved()
{
// State Reserved
var bikeInfoSource = Substitute.For<IBikeInfo>();
var stateSource = Substitute.For<IStateInfo>();
bikeInfoSource.Bike.Returns(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.BordComputer, WheelType.Trike, TypeOfBike.Cargo));
bikeInfoSource.StationId.Returns("23");
bikeInfoSource.State.Returns(stateSource);
stateSource.Value.Returns(InUseStateEnum.Reserved);
stateSource.From.Returns(new System.DateTime(2018, 01, 03));
stateSource.MailAddress.Returns("a@b");
stateSource.Code.Returns("234");
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
Assert.AreEqual(InUseStateEnum.Reserved, bikeInfoTarget.State.Value);
Assert.AreEqual("22", bikeInfoTarget.Id);
Assert.AreEqual("23", bikeInfoTarget.StationId);
Assert.AreEqual(WheelType.Trike, bikeInfoTarget.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, bikeInfoTarget.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Reserved, bikeInfoTarget.State.Value);
Assert.AreEqual(new System.DateTime(2018, 01, 03), bikeInfoTarget.State.From);
Assert.AreEqual("a@b", bikeInfoTarget.State.MailAddress);
}
[Test]
public void TestConstructCopyAvailable()
{
// State Disposable
var bikeInfoSource = Substitute.For<IBikeInfo>();
var stateSource = Substitute.For<IStateInfo>();
bikeInfoSource.Bike.Returns(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.BordComputer, WheelType.Trike, TypeOfBike.Cargo));
bikeInfoSource.StationId.Returns("23");
bikeInfoSource.State.Returns(stateSource);
stateSource.Value.Returns(InUseStateEnum.Disposable);
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
Assert.AreEqual(InUseStateEnum.Disposable, bikeInfoTarget.State.Value);
Assert.AreEqual("22", bikeInfoTarget.Id);
Assert.AreEqual("23", bikeInfoTarget.StationId);
Assert.AreEqual(WheelType.Trike, bikeInfoTarget.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, bikeInfoTarget.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Disposable, bikeInfoTarget.State.Value);
Assert.IsNull(bikeInfoTarget.State.From);
}
[Test]
public void TestConstructBikeNull()
{
Assert.That(
() => new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(null, "My Station Name"),
Throws.ArgumentNullException);
}
}
}

View file

@ -0,0 +1,57 @@
using System;
using NUnit.Framework;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
namespace TestShareeLib.Model.Bike.BluetoothLock
{
[TestFixture]
public class TestBikeInfoMutalbe
{
[Test]
public void TestCtor()
{
Assert.That(
new BikeInfoMutable(
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike(
"MyBikeId",
TINK.Model.Bikes.BikeInfoNS.BikeNS.LockModel.ILockIt),
new Drive(),
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
42,
new Guid(),
"17"),
"My Station Name").StationName,
Is.EqualTo("My Station Name"));
}
[Test]
public void TestToString()
{
Assert.That(
new BikeInfoMutable(
new TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo(
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike(
"MyBikeId",
TINK.Model.Bikes.BikeInfoNS.BikeNS.LockModel.ILockIt,
TINK.Model.Bikes.BikeInfoNS.BikeNS.WheelType.Trike,
TINK.Model.Bikes.BikeInfoNS.BikeNS.TypeOfBike.Cargo),
new Drive(),
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
42,
new Guid(),
"17"),
"My Station Name").ToString(),
Is.EqualTo("Id=MyBikeId;type=Cargo;state=Disposable"));
}
[Test]
public void TestCtorBikeNull()
{
Assert.That(
() => new BikeInfoMutable(null, "My Station Name"),
Throws.ArgumentNullException);
}
}
}

View file

@ -1,4 +1,4 @@
using System;
using System;
using MonkeyCache.FileStore;
using NUnit.Framework;
using Serilog;
@ -44,7 +44,7 @@ namespace TestTINKLib.Fixtures.Misc
null /*UI language */,
cookieAndMail.Split(';')[0],
cookieAndMail.Split(';')[1],
TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
expiresAfter: TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
var start = DateTime.Now;
@ -96,7 +96,7 @@ namespace TestTINKLib.Fixtures.Misc
null /*UI language */,
cookieAndMail.Split(';')[0],
cookieAndMail.Split(';')[1],
TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
expiresAfter: TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
var start = DateTime.Now;
@ -144,7 +144,7 @@ namespace TestTINKLib.Fixtures.Misc
null /*UI language */,
cookieAndMail.Split(';')[0],
cookieAndMail.Split(';')[1],
TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
expiresAfter: TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
var start = DateTime.Now;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using MonkeyCache.FileStore;
using Newtonsoft.Json;
@ -120,7 +120,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
"123", // Merchant id
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
null /*UI language */,
"456", // cookie
sessionCookie: "456",
cacheServer: cache,
httpsServer: https);
@ -219,7 +219,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
"12345678", // Merchant id
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
null /*UI language */,
"f782a208d9399291ba8d086b5dcc2509", // Auth cookie
sessionCookie: "f782a208d9399291ba8d086b5dcc2509",
cacheServer: cache,
httpsServer: https);
@ -244,7 +244,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
"12345678", // Merchant id
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
null /*UI language */,
"f782a208d9399291ba8d086b5dcc2509", // Auth cookie
sessionCookie: "f782a208d9399291ba8d086b5dcc2509",
cacheServer: cache,
httpsServer: https);
@ -269,7 +269,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
"12345678", // Merchant id
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
null /*UI language */,
"f782a208d9399291ba8d086b5dcc2509", // Auth cookie
sessionCookie: "f782a208d9399291ba8d086b5dcc2509",
cacheServer: cache,
httpsServer: https);
@ -295,7 +295,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
"12345678", // Merchant id
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
null /*UI language */,
"f782a208d9399291ba8d086b5dcc2509", // Auth cookie
sessionCookie: "f782a208d9399291ba8d086b5dcc2509",
cacheServer: cache,
httpsServer: https);
@ -320,7 +320,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
"123", // Merchant id
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
null /*UI language */,
"456", // cookie
sessionCookie: "456", // cookie
cacheServer: cache,
httpsServer: https);
@ -498,7 +498,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
"123456789",
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
null /* langugage */,
"876");
sessionCookie: "876");
var bikes = await provider.GetBikesOccupied(true);
Assert.AreEqual(0, bikes.Response.bikes_occupied.Count);

View file

@ -23,13 +23,13 @@ namespace TestTINKLib.Model.Settings
public void TestGetPolling()
{
// Serialize parameters.
var l_oDict = new Dictionary<string, string>()
var dict = new Dictionary<string, string>()
.SetPollingParameters(new PollingParameters(new TimeSpan(0, 0, 0, 15, 0), false));
// Deserialize parameters.
Assert.AreEqual(
new PollingParameters(new TimeSpan(0, 0, 0, 15, 0), false),
l_oDict.GetPollingParameters());
dict.GetPollingParameters());
}
/// <summary> Verifies that empty log fiel leads to expected default value and doesn not throw exceptions.</summary>
@ -42,22 +42,22 @@ namespace TestTINKLib.Model.Settings
[Test]
public void TestGetGetCopriHostUri()
{
var l_oDict = new Dictionary<string, string>()
var dict = new Dictionary<string, string>()
.SetCopriHostUri("http://1.2.3.4");
Assert.AreEqual(
new Uri("http://1.2.3.4"),
JsonSettingsDictionary.GetCopriHostUri(l_oDict));
JsonSettingsDictionary.GetCopriHostUri(dict));
}
/// <summary> Verifies that empty log fiel leads to expected default value and doesn not throw exceptions.</summary>
[Test]
public void TestGetLoggingLevel()
{
var l_oDictionary = new Dictionary<string, string>()
var dict = new Dictionary<string, string>()
.SetMinimumLoggingLevel(0); // Verbose = 0
Assert.AreEqual(
LogEventLevel.Verbose,
JsonSettingsDictionary.GetMinimumLoggingLevel(l_oDictionary)); // LogEventLevel.Error = 4
JsonSettingsDictionary.GetMinimumLoggingLevel(dict)); // LogEventLevel.Error = 4
}
/// <summary> Verifies that empty log fiel leads to expected default value and doesn not throw exceptions.</summary>
@ -70,58 +70,58 @@ namespace TestTINKLib.Model.Settings
[Test]
public void TestGetAppVersion_FirstInstall()
{
var l_oDict = new Dictionary<string, string>();
Assert.IsNull(JsonSettingsDictionary.GetAppVersion(l_oDict));
var dict = new Dictionary<string, string>();
Assert.IsNull(JsonSettingsDictionary.GetAppVersion(dict));
}
[Test]
public void TestGetAppVersion_LegacyTo115()
{
var l_oDict = new Dictionary<string, string> { { "AppVersion", "7.2.3.9" } };
Assert.AreEqual(new Version(7, 2, 3, 9), JsonSettingsDictionary.GetAppVersion(l_oDict));
var dict = new Dictionary<string, string> { { "AppVersion", "7.2.3.9" } };
Assert.AreEqual(new Version(7, 2, 3, 9), JsonSettingsDictionary.GetAppVersion(dict));
l_oDict = new Dictionary<string, string> { { "AppVersion", "7.2.3" } };
Assert.AreEqual(new Version(7, 2, 3), JsonSettingsDictionary.GetAppVersion(l_oDict));
dict = new Dictionary<string, string> { { "AppVersion", "7.2.3" } };
Assert.AreEqual(new Version(7, 2, 3), JsonSettingsDictionary.GetAppVersion(dict));
}
[Test]
public void TestGetAppVersion_Json()
{
var l_oDict = new Dictionary<string, string> { { "AppVersion", "\"3.1.2.117\"" } };
Assert.AreEqual(new Version(3, 1, 2, 117), JsonSettingsDictionary.GetAppVersion(l_oDict));
var dict = new Dictionary<string, string> { { "AppVersion", "\"3.1.2.117\"" } };
Assert.AreEqual(new Version(3, 1, 2, 117), JsonSettingsDictionary.GetAppVersion(dict));
}
[Test]
public void TestSetAppVersion_Json()
{
var l_oDict = new Dictionary<string, string>()
var dict = new Dictionary<string, string>()
.SetAppVersion(new Version(47, 12, 3));
Assert.AreEqual(new Version(47, 12, 3), JsonSettingsDictionary.GetAppVersion(l_oDict));
Assert.AreEqual(new Version(47, 12, 3), JsonSettingsDictionary.GetAppVersion(dict));
}
[Test]
public void TestGetShowWhatsNew_FirstInstall()
{
var l_oDict = new Dictionary<string, string>();
Assert.IsNull(JsonSettingsDictionary.GetWhatsNew(l_oDict));
var dict = new Dictionary<string, string>();
Assert.IsNull(JsonSettingsDictionary.GetWhatsNew(dict));
}
[Test]
public void TestGetShowWhatsNew_Json()
{
var l_oDict = new Dictionary<string, string> { { "ShowWhatsNew", "\"3.1.2.117\"" } };
Assert.AreEqual(new Version(3, 1, 2, 117), JsonSettingsDictionary.GetWhatsNew(l_oDict));
var dict = new Dictionary<string, string> { { "ShowWhatsNew", "\"3.1.2.117\"" } };
Assert.AreEqual(new Version(3, 1, 2, 117), JsonSettingsDictionary.GetWhatsNew(dict));
l_oDict = new Dictionary<string, string> { { "ShowWhatsNew", "\"3.1.2\"" } };
Assert.AreEqual(new Version(3, 1, 2), JsonSettingsDictionary.GetWhatsNew(l_oDict));
dict = new Dictionary<string, string> { { "ShowWhatsNew", "\"3.1.2\"" } };
Assert.AreEqual(new Version(3, 1, 2), JsonSettingsDictionary.GetWhatsNew(dict));
}
[Test]
public void TestSetShowWhats_Json()
{
var l_oDict = new Dictionary<string, string>()
var dict = new Dictionary<string, string>()
.SetWhatsNew(new Version(47, 12, 3));
Assert.AreEqual(new Version(47, 12, 3), JsonSettingsDictionary.GetWhatsNew(l_oDict));
Assert.AreEqual(new Version(47, 12, 3), JsonSettingsDictionary.GetWhatsNew(dict));
}
[Test]

View file

@ -1,4 +1,4 @@
using System;
using System;
using NSubstitute;
using NUnit.Framework;
using Plugin.BLE.Abstractions.Contracts;
@ -43,8 +43,8 @@ namespace TestTINKLib.Fixtures.UseCases.Logout
accountStore,
isConnectedFunc: () => true,
connectorFactory: (isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie)
? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), null /*UI language */, sessionCookie, mail, new CopriCallsMemory001())
: new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), null /*UI language */, sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), null /*UI language */, sessionCookie, mail, server: new CopriCallsMemory001())
: new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), null /*UI language */, sessionCookie, mail, server: new CopriCallsMemory001(sessionCookie)),
merchantId: "MyMerchId",
bluetoothService: Substitute.For<IBluetoothLE>(),
locationPermissionsService: permissions,

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using NSubstitute;
using NUnit.Framework;
@ -38,8 +38,8 @@ namespace TestShareeLib.UseCases.Login
accountStore,
isConnectedFunc: () => true,
connectorFactory: (isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie)
? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), null /*UI language */, sessionCookie, mail, new CopriCallsMemory001())
: new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), null /*UI language */, sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), null /*UI language */, sessionCookie, mail, server: new CopriCallsMemory001())
: new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), null /*UI language */, sessionCookie, mail, server: new CopriCallsMemory001(sessionCookie)),
merchantId: "MyMerchId",
bluetoothService: Substitute.For<IBluetoothLE>(),
locationPermissionsService: permissions,