Version 3.0.361

This commit is contained in:
Anja 2023-03-08 13:18:54 +01:00
parent faf68061f4
commit cba4da9357
88 changed files with 1119 additions and 1502 deletions

View file

@ -1,50 +0,0 @@
using NUnit.Framework;
using System;
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.State;
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
{
[TestFixture]
public class TestBikeInfo
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[Test]
public void TestCtorCopyNull()
{
Assert.Throws<System.ArgumentException>(
() => new BikeInfo(null, null),
"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),
"Verify that no unspecific reference not set to... exception is thrown");
}
[Test]
public void TestCtorAvailable()
{
Assert.AreEqual (12,new BikeInfo(12, 13).Id);
Assert.AreEqual(13, new BikeInfo(12, 13).CurrentStation);
Assert.AreEqual(InUseStateEnum.Disposable, new BikeInfo(12, 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, 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, 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, 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).Id);
Assert.AreEqual(112, new BikeInfo(12, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", 13).LockInfo.Id);
Assert.AreEqual(InUseStateEnum.Booked, new BikeInfo(12, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", 13).State.Value);
}
}
}

View file

@ -1,155 +0,0 @@
using NUnit.Framework;
using System;
using TINK.Model.Bike.BluetoothLock;
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
{
[TestFixture]
public class TestLockInfo
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[Test]
public void TestCtor()
{
Assert.AreEqual(
LockingState.Unknown,
new LockInfo.Builder { Id = 123 }.Build().State);
Assert.AreEqual(
123,
new LockInfo.Builder { Id = 123 }.Build().Id);
}
[Test]
public void TestEquals()
{
Assert.IsTrue(new LockInfo.Builder {
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed}.Build() == new LockInfo.Builder {
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build());
}
[Test]
public void TestEqualsFalse()
{
Assert.IsFalse(new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build() == new LockInfo.Builder
{
Id = 3,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build());
Assert.IsFalse(new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build() == new LockInfo.Builder
{
Id = 2,
Guid = new Guid("1000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build());
Assert.IsFalse(new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build() == new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 5, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build());
Assert.IsFalse(new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build() == new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 9, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build());
Assert.IsFalse(new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build() == new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 11, 1 },
State = LockingState.Closed
}.Build());
Assert.IsFalse(new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Closed
}.Build() == new LockInfo.Builder
{
Id = 2,
Guid = new Guid("0000f00d-1212-efde-1523-785fef13d123"),
Seed = new byte[] { 1, 2 },
UserKey = new byte[] { 7, 2 },
AdminKey = new byte[] { 2, 1 },
State = LockingState.Open
}.Build());
}
}
}

View file

@ -1,56 +0,0 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using TINK.Model.Bike.BluetoothLock;
using TINK.Services.BluetoothLock.Tdo;
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestLockInfoHelper
{
[Test]
public void TestUpdateById_State()
{
var locksInfo = new List<LockInfo> {
new LockInfo.Builder { Id = 12, Seed = new byte[] { 3, 5 }, UserKey = new byte[] {2, 1 }, State = LockingState.Unknown }.Build(),
new LockInfo.Builder { Id = 14, Seed = new byte[] { 3, 1 }, UserKey = new byte[] {2, 7 }, State = LockingState.Open }.Build(),
new LockInfo.Builder { Id = 3, Seed = new byte[] { 1, 5 }, UserKey = new byte[] {2, 9 }, State = LockingState.Closed }.Build(),
};
var locksInfoTdo = new List<LockInfoTdo> {
new LockInfoTdo.Builder { Id =14, State = LockitLockingState.Closed}.Build()
};
var resultList = locksInfo.UpdateById(locksInfoTdo);
var result = resultList.FirstOrDefault(x => x.Id == 14);
Assert.NotNull(result, "Target element was removed.");
Assert.AreEqual(LockingState.Closed, result.State);
}
[Test]
public void TestUpdateById_Guid()
{
var locksInfo = new List<LockInfo> {
new LockInfo.Builder { Id = 12, Seed = new byte[] { 3, 5 }, UserKey = new byte[] {2, 1 }, State = LockingState.Unknown }.Build(),
new LockInfo.Builder { Id = 14, Seed = new byte[] { 3, 1 }, UserKey = new byte[] {2, 7 }, State = LockingState.Open }.Build(),
new LockInfo.Builder { Id = 3, Seed = new byte[] { 1, 5 }, UserKey = new byte[] {2, 9 }, State = LockingState.Closed }.Build(),
};
var locksInfoTdo = new List<LockInfoTdo> {
new LockInfoTdo.Builder { Id =14, Guid = new System.Guid("00000000-0000-0000-0000-e57e6b9aee16"), State = LockitLockingState.Open}.Build()
};
var resultList = locksInfo.UpdateById(locksInfoTdo);
var result = resultList.FirstOrDefault(x => x.Id == 14);
Assert.NotNull(result, "Target element was removed.");
Assert.AreEqual(new Guid("00000000-0000-0000-0000-e57e6b9aee16"), result.Guid);
}
}
}

View file

@ -1,39 +0,0 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TINK.Model.Bike.BluetoothLock;
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestLockInfoMutable
{
[Test]
public void TestCtor()
{
var lockInfo = new LockInfoMutable(1, new Guid(), new byte[] { 1, 2, 3 }, new byte[] { 1, 23 }, new byte[] { 1, 12 }, LockingState.Closed);
Assert.AreEqual(1, lockInfo.Id);
Assert.AreEqual(new Guid(), lockInfo.Guid);
Assert.IsTrue((new byte[] { 1, 2, 3 }).SequenceEqual(lockInfo.UserKey));
Assert.IsTrue((new byte[] { 1, 23 }).SequenceEqual(lockInfo.AdminKey));
Assert.IsTrue((new byte[] { 1, 12 }).SequenceEqual(lockInfo.Seed));
Assert.AreEqual(LockingState.Closed, lockInfo.State);
}
[Test]
public void TestSetGuid()
{
var lockInfo = new LockInfoMutable(1, new Guid(), new byte[] { 1, 2, 3 }, new byte[] { 1, 23 }, new byte[] { 1, 12 }, LockingState.Closed);
lockInfo.Guid = new Guid("00000000-0000-0000-0000-e57e6b9aee16");
Assert.AreEqual(new Guid("00000000-0000-0000-0000-e57e6b9aee16"), lockInfo.Guid);
}
}
}

View file

@ -1,49 +0,0 @@
using NUnit.Framework;
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
using TINK.Model.Bike;
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestBike
{
[Test]
public void TestConstruct()
{
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);
Assert.AreEqual(43, l_oBike.Id);
Assert.AreEqual(TypeOfBike.Cargo, l_oBike.TypeOfBike);
Assert.AreEqual(WheelType.Mono, l_oBike.WheelType);
}
[Test]
public void TestCompare()
{
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);
Assert.IsFalse(l_oBike1 == l_oBike2);
l_oBike2 = new Bike(43, WheelType.Mono, TypeOfBike.Allround);
Assert.IsFalse(l_oBike1 == l_oBike2);
l_oBike2 = new Bike(43, WheelType.Two, TypeOfBike.Cargo);
Assert.IsFalse(l_oBike1 == l_oBike2);
l_oBike2 = new Bike(43, null, null);
Assert.IsTrue(l_oBike1 == l_oBike2);
}
}
}

View file

@ -1,25 +0,0 @@
using NUnit.Framework;
using System;
using TINK.Model.Bike;
namespace TestTINKLib
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestBikeCollection
{
/// <summary> Tests the member.</summary>
[Test]
public void TestConstruct()
{
var l_oColl = new BikeCollection();
Assert.AreEqual(0, l_oColl.Count);
Assert.IsNull(l_oColl.GetById(1));
}
}
}

View file

@ -1,78 +0,0 @@
using NUnit.Framework;
using System.Collections.Generic;
using TINK.Model;
using TINK.Model.Bike;
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestBikeCollectionFilter
{
[Test]
public void TestGetAtStation()
{
var coll = new BikeCollection(
new Dictionary<int, TINK.Model.Bike.BC.BikeInfo>
{
{3, new TINK.Model.Bike.BC.BikeInfo(7, 3 /* Stadion id */) },
{7, new TINK.Model.Bike.BC.BikeInfo(8, 12 /* Stadion id */) },
{12, new TINK.Model.Bike.BC.BikeInfo(33, 12 /* Stadion id */) }
});
Assert.AreEqual(
0,
BikeCollectionFilter.GetAtStation(null, 12).Count);
Assert.AreEqual(
0,
coll.GetAtStation(null).Count);
Assert.AreEqual(
0,
coll.GetAtStation(22).Count);
Assert.AreEqual(
1,
coll.GetAtStation(3).Count);
Assert.AreEqual(
2,
coll.GetAtStation(12).Count);
}
[Test]
public void TestGetLockIt()
{
var coll = new BikeCollection(
new Dictionary<int, TINK.Model.Bike.BC.BikeInfo>
{
{7, new TINK.Model.Bike.BC.BikeInfo(8, 12 /* Stadion id */) },
{12, new TINK.Model.Bike.BC.BikeInfo(33, 12 /* Stadion id */) }
});
Assert.AreEqual(
0,
coll.GetLockIt().Count);
coll = new BikeCollection(
new Dictionary<int, TINK.Model.Bike.BC.BikeInfo>
{
{7, new TINK.Model.Bike.BC.BikeInfo(8, 12 /* Stadion id */) },
{11, new TINK.Model.Bike.BluetoothLock.BikeInfo(33, 12 /* Stadion id */) },
{12, new TINK.Model.Bike.BC.BikeInfo(33, 12 /* Stadion id */) }
});
Assert.AreEqual(
0,
BikeCollectionFilter.GetLockIt(null).Count);
Assert.AreEqual(
1,
coll.GetLockIt().Count);
}
}
}

View file

@ -1,93 +0,0 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using TINK.Model.Bike;
using TINK.Model.State;
using BikeInfo = TINK.Model.Bike.BC.BikeInfo;
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
namespace TestTINKLib
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestBikeCollectionMutable
{
/// <summary> Tests the member.</summary>
[Test]
public void TestAdd()
{
var l_oColl = new BikeCollectionMutable();
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)));
}
[Test]
public void TestUpdate_Null()
{
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),
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"));
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"));
}
[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 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),
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")); //
var l_oBikeResponse = new List<BikeInfo>
{
new BikeInfo("57", false, new [] { "TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", 7, DateTime.Now, "john@long,", "1234"),
new BikeInfo("20", false, new [] {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", 7, DateTime.Now, "john@long,", "1234"),
new BikeInfo("33", 7, false, new [] {"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"));
}
}
}

View file

@ -1,67 +0,0 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using TINK.Model.Bike;
using TINK.Model.State;
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
namespace TestTINKLib
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
class TestBikeMutable
{
[Test]
public void TestConstruct()
{
var l_oBike = new BikeInfoMutable(
42,
false,
new List<string> { "TINK" },
WheelType.Two,
TypeOfBike.Cargo);
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);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value);
Assert.IsNull(l_oBike.CurrentStation);
l_oBike = new BikeInfoMutable(
17,
true,
new List<string> { "TINK" },
WheelType.Mono,
TypeOfBike.Allround,
"Test description",
1);
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);
}
[Test]
public void TestToString()
{
var l_oBike = new BikeInfoMutable(3, false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Cargo, p_oDateTimeProvider: () => 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, p_oDateTimeProvider: () => new DateTime(1970, 1, 1));
Assert.AreEqual(
"Id=3, wheel(s)=Trike, type=Allround, demo=True, state=Disposable, location=Station 5.",
l_oBike.ToString());
}
}
}

View file

@ -1,69 +0,0 @@
using Newtonsoft.Json;
using NUnit.Framework;
using TINK.Repository.Response;
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestBikesAvailableResponse
{
[Test]
public void TestDeserializeStationEmpty()
{
// Response for bike 231 is a real world answer.
var l_oBikes = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
{
""apiserver"" : ""https://app.tink-konstanz.de"",
""response"" : ""bikes_available"",
""bikes"" : {
""231"" : {
""bike"" : ""231"",
""description"" : ""Stadtrad"",
""system"" : ""BC"",
""bike_group"" : [ ""Konrad"" ],
""station"" : """",
""state"" : ""available"",
""gps"" : { ""latitude"": ""9.1594501"", ""longitude"": ""47.6749928"" }
}
},
""copri_version"" : ""4.1.0.0"",
""authcookie"" : """",
""response_state"" : ""OK""
}
");
Assert.IsNull(l_oBikes.bikes[231].station);
}
[Test]
public void TestDeserializeStationInfoMissing()
{
// Response for bike 231 might not be real world answer.
var l_oBikes = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
{
""apiserver"" : ""https://app.tink-konstanz.de"",
""response"" : ""bikes_available"",
""bikes"" : {
""231"" : {
""bike"" : ""231"",
""description"" : ""Stadtrad"",
""system"" : ""BC"",
""bike_group"" : [ ""Konrad"" ],
""state"" : ""available"",
""gps"" : { ""latitude"": ""9.1594501"", ""longitude"": ""47.6749928"" }
}
},
""copri_version"" : ""4.1.0.0"",
""authcookie"" : """",
""response_state"" : ""OK""
}
");
Assert.IsNull(l_oBikes.bikes[231].station);
}
}
}

View file

@ -1,44 +0,0 @@
using Newtonsoft.Json;
using NUnit.Framework;
using System;
using TINK.Model.State;
namespace TestTINKLib.Fixtures.Bike
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestStateBookedInfoSerializeJSON
{
[Test]
public void TestSerializeJSON()
{
// Create object to test.
var l_oInfoSource = new StateOccupiedInfo(
new DateTime(2017, 09, 20, 23, 05, 0),
"Heinz@mueller",
"17 xxb");
// Serialize object and verify.
var l_oDetected = JsonConvert.SerializeObject(l_oInfoSource);
const string EXPECTED = @"
{
""From"":""2017 - 09 - 20T23: 05:00"",
""MailAddress"":""Heinz@mueller"",
""Code"":""17 xxb""
}";
Assert.AreEqual(
TestHelper.PrepareXmlForStringCompare(EXPECTED.Replace("\n", string.Empty).Replace("\r", string.Empty)),
TestHelper.PrepareXmlForStringCompare(l_oDetected.Replace("\n", string.Empty).Replace("\r", string.Empty)));
// Deserialize object and verify.
var l_oInfoTarget = JsonConvert.DeserializeObject<StateOccupiedInfo>(l_oDetected);
Assert.AreEqual(InUseStateEnum.Booked, l_oInfoTarget.Value);
Assert.AreEqual("Heinz@mueller", l_oInfoTarget.MailAddress);
Assert.AreEqual("17 xxb", l_oInfoTarget.Code);
Assert.AreEqual(new DateTime(2017, 9, 20, 23, 5, 0), l_oInfoTarget.From);
}
}
}