mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Version 3.0.337
This commit is contained in:
parent
fd0e63cf10
commit
573fe77e12
2336 changed files with 33688 additions and 86082 deletions
|
@ -1,17 +1,73 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model.Bike.BC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BC;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BC
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestBikeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Dummy subclass to provide assess to protected member for testing.
|
||||
/// </summary>
|
||||
private class TestBikeInfoSubClass : BikeInfo
|
||||
{
|
||||
public TestBikeInfoSubClass(
|
||||
IStateInfo stateInfo,
|
||||
TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike bike,
|
||||
Drive drive,
|
||||
bool? isDemo = DEFAULTVALUEISDEMO,
|
||||
IEnumerable<string> group = null,
|
||||
string stationId = null,
|
||||
Uri operatorUri = null,
|
||||
RentalDescription tariffDescription = null) : base(
|
||||
stateInfo,
|
||||
bike,
|
||||
drive,
|
||||
isDemo,
|
||||
group,
|
||||
stationId,
|
||||
operatorUri,
|
||||
tariffDescription)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorCopyNull()
|
||||
{
|
||||
Assert.Throws<System.ArgumentException>(
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => new BikeInfo(null),
|
||||
"Verify that no unspecific reference not set to... exception is thrown");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorBikeNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new TestBikeInfoSubClass(new StateInfo(), null, new Drive()),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorDriveNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new TestBikeInfoSubClass(new StateInfo(), new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike(string.Empty, LockModel.ILockIt), null),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorCopy()
|
||||
{
|
||||
Assert.That(
|
||||
() => new BikeInfo(null),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Bikes.Bike;
|
||||
using TINK.Model.Bikes.BikeInfoNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TestTINKLib
|
||||
|
@ -10,22 +10,32 @@ namespace TestTINKLib
|
|||
[TestFixture]
|
||||
class TestBikeMutable
|
||||
{
|
||||
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
|
||||
private class BikeInfoMutable : TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable
|
||||
{
|
||||
public BikeInfoMutable(
|
||||
string id,
|
||||
string id,
|
||||
LockModel lockType,
|
||||
bool isDemo = false,
|
||||
IEnumerable<string> group = null,
|
||||
WheelType? wheelType = null,
|
||||
bool isDemo = false,
|
||||
IEnumerable<string> group = null,
|
||||
WheelType? wheelType = null,
|
||||
TypeOfBike? typeOfBike = null,
|
||||
string description = null,
|
||||
string description = null,
|
||||
string stationId = null,
|
||||
string stationName = null,
|
||||
Uri operatorUri = null,
|
||||
RentalDescription tariffDescription = null,
|
||||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null) : base(id, lockType, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
|
||||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null) : base(
|
||||
new Bike(id, lockType, wheelType, typeOfBike, description),
|
||||
new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(),
|
||||
isDemo,
|
||||
group,
|
||||
stationId,
|
||||
stationName,
|
||||
operatorUri,
|
||||
tariffDescription,
|
||||
dateTimeProvider,
|
||||
stateInfo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +61,7 @@ namespace TestTINKLib
|
|||
l_oBike = new BikeInfoMutable(
|
||||
"17",
|
||||
LockModel.ILockIt,
|
||||
true,
|
||||
true,
|
||||
new List<string> { "TINK" },
|
||||
WheelType.Mono,
|
||||
TypeOfBike.Allround,
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Bike.BluetoothLock;
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.State;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
||||
|
@ -17,32 +18,86 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
"Verify that no unspecific reference not set to... exception is thrown");
|
||||
|
||||
Assert.Throws<ArgumentException>(
|
||||
() => new BikeInfo(new TINK.Model.Bike.BC.BikeInfo("12", LockModel.ILockIt, "1"), null),
|
||||
() => new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), "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").StationId);
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value);
|
||||
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").Id);
|
||||
Assert.AreEqual("13", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").StationId);
|
||||
Assert.AreEqual(InUseStateEnum.Disposable, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorAvailableBikeNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
5200544,
|
||||
new Guid("00000000-0000-0000-0000-000000000001"),
|
||||
"13"),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[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), false /*isDemo*/, null /*group*/, null /*wheelType*/, null /*typeOfBike*/, null /*description*/).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), false /*isDemo*/, null /*group*/, null /*wheelType*/, null /*typeOfBike*/, null /*description*/).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), false /*isDemo*/, null /*group*/, null /*wheelType*/, null /*typeOfBike*/, null /*description*/).State.Value);
|
||||
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).Id);
|
||||
Assert.AreEqual(112, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).LockInfo.Id);
|
||||
Assert.AreEqual(InUseStateEnum.Reserved, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null, null, dateTimeProvider: () => new DateTime(2019, 1, 1), false /*isDemo*/, null /*group*/).State.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorRequestedBikeNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new BikeInfo(
|
||||
null,
|
||||
new Drive(), 112,
|
||||
new Guid(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new DateTime(2020, 1, 1),
|
||||
"a@b",
|
||||
"13",
|
||||
null,
|
||||
null,
|
||||
dateTimeProvider: () => new DateTime(2019, 1, 1),
|
||||
false /*isDemo*/,
|
||||
null /*group*/),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[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(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).Id);
|
||||
Assert.AreEqual(112, new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 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(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).State.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorBookedNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
112,
|
||||
new Guid(),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new DateTime(2020, 1, 1),
|
||||
"a@b",
|
||||
"13",
|
||||
null /*operator uri*/),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Model.Bike.BluetoothLock;
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
|
||||
namespace TestShareeLib.Model.Bike.BluetoothLock
|
||||
{
|
||||
|
@ -11,8 +12,16 @@ namespace TestShareeLib.Model.Bike.BluetoothLock
|
|||
public void TestCtor()
|
||||
{
|
||||
Assert.That(
|
||||
new BikeInfoMutable(new BikeInfo("MyBikeId", 42, new Guid(), "17"), "My Station Name").StationName,
|
||||
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(), 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Model.Bike.BluetoothLock;
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
||||
{
|
||||
[TestFixture]
|
||||
|
@ -12,7 +12,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
Assert.AreEqual(
|
||||
LockingState.UnknownDisconnected,
|
||||
new LockInfo.Builder { Id = 123 }.Build().State);
|
||||
|
||||
|
||||
Assert.AreEqual(
|
||||
123,
|
||||
new LockInfo.Builder { Id = 123 }.Build().Id);
|
||||
|
@ -21,20 +21,23 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
[Test]
|
||||
public void TestEquals()
|
||||
{
|
||||
Assert.IsTrue(new LockInfo.Builder {
|
||||
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());
|
||||
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]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TINK.Model.Bike.BluetoothLock;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Services.BluetoothLock.Tdo;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
||||
|
@ -13,7 +13,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
[Test]
|
||||
public void TestUpdateById_State()
|
||||
{
|
||||
var locksInfo = new List<LockInfo> {
|
||||
var locksInfo = new List<LockInfo> {
|
||||
new LockInfo.Builder { Id = 12, Seed = new byte[] { 3, 5 }, UserKey = new byte[] {2, 1 }, State = LockingState.UnknownFromHardwareError }.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(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using TINK.Model.Bike.BluetoothLock;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
||||
{
|
||||
|
@ -12,8 +12,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
|
|||
public void TestCtor()
|
||||
{
|
||||
var lockInfo = new LockInfoMutable(
|
||||
1,
|
||||
new Guid("00000000-0000-0000-0000-e57e6b9aee16"),
|
||||
1,
|
||||
new Guid("00000000-0000-0000-0000-e57e6b9aee16"),
|
||||
new byte[] { 1, 2, 3 }, // User key
|
||||
new byte[] { 1, 23 }, // Admin key
|
||||
new byte[] { 1, 12 }, // Seed
|
||||
|
|
87
TestShareeLib/Model/Bike/CopriLock/TestBikeInfo.cs
Normal file
87
TestShareeLib/Model/Bike/CopriLock/TestBikeInfo.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
using System;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
|
||||
namespace TestShareeLib.Model.Bike.CopriLock
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestBikeInfo
|
||||
{
|
||||
[Test]
|
||||
public void TestCtorAvailable()
|
||||
{
|
||||
var bike = new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("bikeId", LockModel.Sigo),
|
||||
new Drive(),
|
||||
"stationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo());
|
||||
|
||||
Assert.That(
|
||||
bike.State.Value,
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.Disposable));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestCtorAvailableBikeNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
"stationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorFeedbackRequired()
|
||||
{
|
||||
var bike = new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("bikeId", LockModel.Sigo),
|
||||
new Drive(),
|
||||
"stationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo(),
|
||||
true);
|
||||
|
||||
Assert.That(
|
||||
bike.State.Value,
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.FeedbackPending));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorRequestedBikeNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
DateTime.Now,
|
||||
"a@b",
|
||||
"stationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo(),
|
||||
new Uri("https://sharee.bike"),
|
||||
new RentalDescription(),
|
||||
() => DateTime.Now),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorOccupiedBikeNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
null,
|
||||
new Drive(),
|
||||
DateTime.Now,
|
||||
"a@b",
|
||||
"stationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo(),
|
||||
new Uri("https://sharee.bike"),
|
||||
new RentalDescription()),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
}
|
||||
}
|
36
TestShareeLib/Model/Bike/CopriLock/TestBikeInfoMutable.cs
Normal file
36
TestShareeLib/Model/Bike/CopriLock/TestBikeInfoMutable.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BC;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
|
||||
namespace TestShareeLib.Model.Bike.CopriLock
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestBikeInfoMutable
|
||||
{
|
||||
[Test]
|
||||
public void TestCtorBikeInfoNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new BikeInfoMutable(null, "Station 32"),
|
||||
Throws.ArgumentNullException);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCtorBikeInfo()
|
||||
{
|
||||
var bike = new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike(
|
||||
"MyId",
|
||||
TINK.Model.Bikes.BikeInfoNS.BikeNS.LockModel.Sigo);
|
||||
|
||||
var bikeInfo = new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
bike,
|
||||
new Drive(new TINK.Model.Bikes.BikeInfoNS.DriveNS.EngineNS.Engine("BackendLock")),
|
||||
"StationId",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo());
|
||||
|
||||
Assert.That(
|
||||
new BikeInfoMutable(bikeInfo, "Station 32").Drive.Type,
|
||||
Is.EqualTo(DriveType.Pedelec));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
||||
{
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
|
||||
[TestFixture]
|
||||
public class TestBike
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Bikes;
|
||||
|
||||
|
||||
namespace TestTINKLib
|
||||
{
|
||||
|
||||
|
||||
[TestFixture]
|
||||
public class TestBikeCollection
|
||||
{
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Bikes.Bike;
|
||||
using TINK.Model.Connector;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes;
|
||||
using TINK.Model.Bikes.BikeInfoNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.Connector.Updater;
|
||||
using TINK.Model.State;
|
||||
using TINK.Model.Station;
|
||||
using BikeInfo = TINK.Model.Bike.BC.BikeInfo;
|
||||
using BikeInfo = TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo;
|
||||
|
||||
namespace TestTINKLib
|
||||
{
|
||||
|
||||
|
||||
[TestFixture]
|
||||
public class TestBikeCollectionMutable
|
||||
{
|
||||
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
|
||||
private class BikeInfoMutable : TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable
|
||||
{
|
||||
public BikeInfoMutable(
|
||||
string id,
|
||||
|
@ -30,7 +32,17 @@ namespace TestTINKLib
|
|||
Uri operatorUri = null,
|
||||
RentalDescription tariffDescription = null,
|
||||
Func<DateTime> dateTimeProvider = null,
|
||||
IStateInfo stateInfo = null) : base(id, lockType, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
|
||||
IStateInfo stateInfo = null) : base(
|
||||
new Bike(id, lockType, wheelType, typeOfBike, description),
|
||||
new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(),
|
||||
isDemo,
|
||||
group,
|
||||
stationId,
|
||||
stationName,
|
||||
operatorUri,
|
||||
tariffDescription,
|
||||
dateTimeProvider,
|
||||
stateInfo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +53,7 @@ namespace TestTINKLib
|
|||
{
|
||||
var l_oColl = new BikeCollectionMutable();
|
||||
|
||||
l_oColl.Add(new BikeInfoMutable("57", LockModel.ILockIt, false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Allround));
|
||||
l_oColl.Add(new BikeInfoMutable("57", LockModel.ILockIt, false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Allround));
|
||||
|
||||
Assert.Throws<Exception>(() => l_oColl.Add(new BikeInfoMutable("57", LockModel.ILockIt, false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo)));
|
||||
}
|
||||
|
@ -65,7 +77,7 @@ namespace TestTINKLib
|
|||
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById("20").State.Value);
|
||||
Assert.Null(l_oBikeColl.GetById("33"));
|
||||
|
||||
l_oBikeColl.Update(null, null );
|
||||
l_oBikeColl.Update(null, null);
|
||||
|
||||
// Verify modified state
|
||||
Assert.Null(l_oBikeColl.GetById("63"));
|
||||
|
@ -95,24 +107,26 @@ namespace TestTINKLib
|
|||
|
||||
var bikeResponse = new List<BikeInfo>
|
||||
{
|
||||
new TINK.Model.Bike.CopriLock.BikeInfo(
|
||||
"57" /* bike id*/,
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("57", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
DateTime.Now,
|
||||
"john@long",
|
||||
"7" /*station id*/,
|
||||
new TINK.Model.Bikes.Bike.CopriLock.LockInfo(),
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo(),
|
||||
null),
|
||||
new TINK.Model.Bike.CopriLock.BikeInfo(
|
||||
"20",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("20", LockModel.ILockIt),
|
||||
new Drive(),
|
||||
DateTime.Now,
|
||||
"john@long",
|
||||
"7",
|
||||
new TINK.Model.Bikes.Bike.CopriLock.LockInfo(),
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo(),
|
||||
null),
|
||||
new TINK.Model.Bike.CopriLock.BikeInfo(
|
||||
"33",
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("33", LockModel.Sigo), new Drive(),
|
||||
"7",
|
||||
new TINK.Model.Bikes.Bike.CopriLock.LockInfo()),
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()),
|
||||
};
|
||||
|
||||
|
||||
|
@ -138,10 +152,10 @@ namespace TestTINKLib
|
|||
|
||||
var l_oBikeResponse = new List<BikeInfo>
|
||||
{
|
||||
new TINK.Model.Bike.CopriLock.BikeInfo(
|
||||
"57" /* bike id*/,
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("57", LockModel.Sigo), new Drive(),
|
||||
"7" /*station id*/,
|
||||
new TINK.Model.Bikes.Bike.CopriLock.LockInfo()),
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo()),
|
||||
};
|
||||
|
||||
var stations = new List<IStation>
|
||||
|
@ -171,7 +185,7 @@ namespace TestTINKLib
|
|||
|
||||
var bikeResponse = new List<BikeInfo>
|
||||
{
|
||||
new BikeInfo("57" /* bike id*/, LockModel.ILockIt, 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(new Bike("57" /* bike id*/, LockModel.ILockIt, WheelType.Trike, TypeOfBike.Allround, "Test description"), new Drive(), false, new List<string> {"TINK" }, "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
|
||||
};
|
||||
|
||||
var stations = new List<IStation>
|
||||
|
@ -195,11 +209,11 @@ namespace TestTINKLib
|
|||
|
||||
var bikeResponse = new List<BikeInfo>
|
||||
{
|
||||
new TINK.Model.Bike.CopriLock.BikeInfo(
|
||||
"57" /* bike id*/,
|
||||
"7" /*station id*/,
|
||||
new TINK.Model.Bikes.Bike.CopriLock.LockInfo(),
|
||||
null /*operator uri*/),
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo(
|
||||
new Bike("57", LockModel.Sigo), new Drive(),
|
||||
"7" /*station id*/,
|
||||
new TINK.Model.Bikes.BikeInfoNS.CopriLock.LockInfo(),
|
||||
operatorUri: null /*operator uri*/),
|
||||
};
|
||||
|
||||
bikeColl.Update(bikeResponse, null);
|
||||
|
@ -224,7 +238,7 @@ namespace TestTINKLib
|
|||
|
||||
Assert.That(
|
||||
BikeCollectionMutable.BikeInfoMutableFactory.Create(bikeInfo, "Stat1").GetType(),
|
||||
Is.EqualTo(typeof(TINK.Model.Bike.BluetoothLock.BikeInfoMutable)));
|
||||
Is.EqualTo(typeof(TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfoMutable)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -242,7 +256,7 @@ namespace TestTINKLib
|
|||
|
||||
Assert.That(
|
||||
BikeCollectionMutable.BikeInfoMutableFactory.Create(bikeInfo, "Stat1").GetType(),
|
||||
Is.EqualTo(typeof(TINK.Model.Bike.CopriLock.BikeInfoMutable)));
|
||||
Is.EqualTo(typeof(TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfoMutable)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using TINK.Model.Bike;
|
||||
using TINK.Model.Bikes.Bike;
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
|
||||
namespace TestShareeLib.Model.Bike
|
||||
{
|
||||
|
@ -14,7 +13,7 @@ namespace TestShareeLib.Model.Bike
|
|||
Assert.That(LockModel.Sigo.GetLockType(), Is.EqualTo(LockType.Backend));
|
||||
Assert.That(LockModel.ILockIt.GetLockType(), Is.EqualTo(LockType.Bluethooth));
|
||||
Assert.That(
|
||||
() => LockModel.BordComputer.GetLockType(),
|
||||
() => LockModel.BordComputer.GetLockType(),
|
||||
Throws.InstanceOf<ArgumentException>());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue