mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Code updated to 3.0.238
This commit is contained in:
parent
3302d80678
commit
9c6a1fa92b
257 changed files with 7763 additions and 2861 deletions
|
@ -13,13 +13,13 @@ namespace TestTINKLib
|
|||
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
|
||||
{
|
||||
public BikeInfoMutable(
|
||||
int id,
|
||||
string id,
|
||||
bool isDemo = false,
|
||||
IEnumerable<string> group = null,
|
||||
WheelType? wheelType = null,
|
||||
TypeOfBike? typeOfBike = null,
|
||||
string description = null,
|
||||
int? currentStationId = null,
|
||||
string currentStationId = null,
|
||||
Uri operatorUri = null,
|
||||
TariffDescription tariffDescription = null,
|
||||
Func<DateTime> dateTimeProvider = null,
|
||||
|
@ -32,13 +32,13 @@ namespace TestTINKLib
|
|||
public void TestConstruct()
|
||||
{
|
||||
var l_oBike = new BikeInfoMutable(
|
||||
42,
|
||||
"42",
|
||||
false,
|
||||
new List<string> { "TINK" },
|
||||
WheelType.Two,
|
||||
TypeOfBike.Cargo);
|
||||
|
||||
Assert.AreEqual(42, l_oBike.Id);
|
||||
Assert.AreEqual("42", l_oBike.Id);
|
||||
Assert.IsFalse(l_oBike.IsDemo);
|
||||
Assert.AreEqual(WheelType.Two, l_oBike.WheelType);
|
||||
Assert.AreEqual(TypeOfBike.Cargo, l_oBike.TypeOfBike);
|
||||
|
@ -46,32 +46,32 @@ namespace TestTINKLib
|
|||
Assert.IsNull(l_oBike.CurrentStation);
|
||||
|
||||
l_oBike = new BikeInfoMutable(
|
||||
17,
|
||||
"17",
|
||||
true,
|
||||
new List<string> { "TINK" },
|
||||
WheelType.Mono,
|
||||
TypeOfBike.Allround,
|
||||
"Test description",
|
||||
1);
|
||||
"1");
|
||||
|
||||
Assert.AreEqual(17, l_oBike.Id);
|
||||
Assert.AreEqual("17", l_oBike.Id);
|
||||
Assert.IsTrue(l_oBike.IsDemo);
|
||||
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.CurrentStation);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestToString()
|
||||
{
|
||||
var l_oBike = new BikeInfoMutable(3, false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Cargo, dateTimeProvider: () => new DateTime(1970, 1, 1));
|
||||
var l_oBike = new BikeInfoMutable("3", false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Cargo, dateTimeProvider: () => new DateTime(1970, 1, 1));
|
||||
|
||||
Assert.AreEqual(
|
||||
"Id=3, wheel(s)=Two, type=Cargo, demo=False, state=Disposable, location=On the road.",
|
||||
l_oBike.ToString());
|
||||
|
||||
l_oBike = new BikeInfoMutable(3, true, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", 5, dateTimeProvider: () => new DateTime(1970, 1, 1));
|
||||
l_oBike = new BikeInfoMutable("3", true, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "5", dateTimeProvider: () => new DateTime(1970, 1, 1));
|
||||
Assert.AreEqual(
|
||||
"Id=3, wheel(s)=Trike, type=Allround, demo=True, state=Disposable, location=Station 5.",
|
||||
l_oBike.ToString());
|
||||
|
|
|
@ -16,32 +16,32 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
"Verify that no unspecific reference not set to... exception is thrown");
|
||||
|
||||
Assert.Throws<System.ArgumentException>(
|
||||
() => new BikeInfo(new TINK.Model.Bike.BC.BikeInfo(12,1), null),
|
||||
() => new BikeInfo(new TINK.Model.Bike.BC.BikeInfo("12", "1"), null),
|
||||
"Verify that no unspecific reference not set to... exception is thrown");
|
||||
}
|
||||
|
||||
[Test]
|
||||
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(InUseStateEnum.Disposable, new BikeInfo(12, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), 13).State.Value);
|
||||
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(InUseStateEnum.Disposable, new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorRequested()
|
||||
{
|
||||
Assert.AreEqual(12, new BikeInfo(12, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", 13, null, null, dateTimeProvider: () => new DateTime(2019, 1, 1)).Id);
|
||||
Assert.AreEqual(112, new BikeInfo(12, 112, new Guid(), null, null, null, new DateTime(2020,1,1), "a@b", 13, null, null, dateTimeProvider: () => new DateTime(2019, 1, 1)).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Reserved, new BikeInfo(12, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", 13, null, null, dateTimeProvider: () => new DateTime(2019, 1, 1)).State.Value);
|
||||
Assert.AreEqual("12", new BikeInfo("12", 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1)).Id);
|
||||
Assert.AreEqual(112, new BikeInfo("12", 112, new Guid(), null, null, null, new DateTime(2020,1,1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1)).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Reserved, new BikeInfo("12", 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1)).State.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorBooked()
|
||||
{
|
||||
Assert.AreEqual(12, new BikeInfo(12, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", 13, null /*operator uri*/).Id);
|
||||
Assert.AreEqual(112, new BikeInfo(12, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", 13, null /*operator uri*/).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Booked, new BikeInfo(12, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", 13, null /*operator uri*/).State.Value);
|
||||
Assert.AreEqual("12", new BikeInfo("12", 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).Id);
|
||||
Assert.AreEqual(112, new BikeInfo("12", 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Booked, new BikeInfo("12", 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).State.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
|||
[Test]
|
||||
public void TestConstruct()
|
||||
{
|
||||
var l_oBike = new Bike(43);
|
||||
Assert.AreEqual(43, l_oBike.Id);
|
||||
var l_oBike = new Bike("43");
|
||||
Assert.AreEqual("43", l_oBike.Id);
|
||||
Assert.AreEqual(null, l_oBike.TypeOfBike);
|
||||
Assert.AreEqual(null, l_oBike.WheelType);
|
||||
|
||||
l_oBike = new Bike(43, WheelType.Mono, TypeOfBike.Cargo);
|
||||
l_oBike = new Bike("43", WheelType.Mono, TypeOfBike.Cargo);
|
||||
|
||||
Assert.AreEqual(43, l_oBike.Id);
|
||||
Assert.AreEqual("43", l_oBike.Id);
|
||||
Assert.AreEqual(TypeOfBike.Cargo, l_oBike.TypeOfBike);
|
||||
Assert.AreEqual(WheelType.Mono, l_oBike.WheelType);
|
||||
}
|
||||
|
@ -25,21 +25,21 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
|||
[Test]
|
||||
public void TestCompare()
|
||||
{
|
||||
var l_oBike1 = new Bike(43);
|
||||
Assert.AreEqual(43, l_oBike1.Id);
|
||||
var l_oBike1 = new Bike("43");
|
||||
Assert.AreEqual("43", l_oBike1.Id);
|
||||
Assert.AreEqual(null, l_oBike1.TypeOfBike);
|
||||
Assert.AreEqual(null, l_oBike1.WheelType);
|
||||
|
||||
var l_oBike2 = new Bike(42, WheelType.Two, TypeOfBike.Allround);
|
||||
var l_oBike2 = new Bike("42", WheelType.Two, TypeOfBike.Allround);
|
||||
Assert.IsFalse(l_oBike1 == l_oBike2);
|
||||
|
||||
l_oBike2 = new Bike(43, WheelType.Mono, TypeOfBike.Allround);
|
||||
l_oBike2 = new Bike("43", WheelType.Mono, TypeOfBike.Allround);
|
||||
Assert.IsFalse(l_oBike1 == l_oBike2);
|
||||
|
||||
l_oBike2 = new Bike(43, WheelType.Two, TypeOfBike.Cargo);
|
||||
l_oBike2 = new Bike("43", WheelType.Two, TypeOfBike.Cargo);
|
||||
Assert.IsFalse(l_oBike1 == l_oBike2);
|
||||
|
||||
l_oBike2 = new Bike(43, null, null);
|
||||
l_oBike2 = new Bike("43", null, null);
|
||||
Assert.IsTrue(l_oBike1 == l_oBike2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace TestTINKLib
|
|||
var l_oColl = new BikeCollection();
|
||||
|
||||
Assert.AreEqual(0, l_oColl.Count);
|
||||
Assert.IsNull(l_oColl.GetById(1));
|
||||
Assert.IsNull(l_oColl.GetById("1"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ namespace TestTINKLib
|
|||
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
|
||||
{
|
||||
public BikeInfoMutable(
|
||||
int id,
|
||||
string id,
|
||||
bool isDemo = false,
|
||||
IEnumerable<string> group = null,
|
||||
WheelType? wheelType = null,
|
||||
TypeOfBike? typeOfBike = null,
|
||||
string description = null,
|
||||
int? currentStationId = null,
|
||||
string currentStationId = null,
|
||||
Uri operatorUri = null,
|
||||
TariffDescription tariffDescription = null,
|
||||
Func<DateTime> dateTimeProvider = null,
|
||||
|
@ -38,72 +38,72 @@ namespace TestTINKLib
|
|||
{
|
||||
var l_oColl = new BikeCollectionMutable();
|
||||
|
||||
l_oColl.Add(new BikeInfoMutable(57, false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Allround));
|
||||
l_oColl.Add(new BikeInfoMutable("57", false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Allround));
|
||||
|
||||
Assert.Throws<Exception>(() => l_oColl.Add(new BikeInfoMutable(57, false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo)));
|
||||
Assert.Throws<Exception>(() => l_oColl.Add(new BikeInfoMutable("57", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpdate_Null()
|
||||
{
|
||||
var l_oBikeRequested = new BikeInfoMutable(20, false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround);
|
||||
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 l_oBikeColl = 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),
|
||||
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,
|
||||
};
|
||||
|
||||
// Verify initial state
|
||||
Assert.NotNull(l_oBikeColl.GetById(63));
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeColl.GetById(57).State.Value);
|
||||
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById(20).State.Value);
|
||||
Assert.Null(l_oBikeColl.GetById(33));
|
||||
Assert.NotNull(l_oBikeColl.GetById("63"));
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeColl.GetById("57").State.Value);
|
||||
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById("20").State.Value);
|
||||
Assert.Null(l_oBikeColl.GetById("33"));
|
||||
|
||||
l_oBikeColl.Update(null);
|
||||
|
||||
// Verify modified state
|
||||
Assert.Null(l_oBikeColl.GetById(63));
|
||||
Assert.Null(l_oBikeColl.GetById(57));
|
||||
Assert.Null(l_oBikeColl.GetById(20));
|
||||
Assert.Null(l_oBikeColl.GetById(33));
|
||||
Assert.Null(l_oBikeColl.GetById("63"));
|
||||
Assert.Null(l_oBikeColl.GetById("57"));
|
||||
Assert.Null(l_oBikeColl.GetById("20"));
|
||||
Assert.Null(l_oBikeColl.GetById("33"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUpdate()
|
||||
{
|
||||
var l_oBikeRequested = new BikeInfoMutable(20, false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround);
|
||||
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 l_oBikeColl = 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),
|
||||
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,
|
||||
};
|
||||
|
||||
// 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(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")); //
|
||||
|
||||
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(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),
|
||||
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("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);
|
||||
|
||||
// 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(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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue