sharee.bike-App/TestShareeLib/Model/Bike/BluetoothLock/TestBikeInfo.cs

104 lines
4 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using System;
using NUnit.Framework;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
2021-05-13 20:09:46 +02:00
using TINK.Model.State;
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
{
2022-09-06 16:08:19 +02:00
[TestFixture]
public class TestBikeInfo
{
[Test]
public void TestCtorCopyNull()
{
Assert.Throws<ArgumentException>(
() => new BikeInfo(null, null),
"Verify that no unspecific reference not set to... exception is thrown");
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
Assert.Throws<ArgumentException>(
() => 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");
}
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCtorAvailable()
{
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);
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCtorAvailableBikeNull()
{
Assert.That(
() => new BikeInfo(
null,
new Drive(),
5200544,
new Guid("00000000-0000-0000-0000-000000000001"),
"13"),
Throws.ArgumentNullException);
}
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCtorRequested()
{
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);
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[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);
}
2021-05-13 20:09:46 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCtorBooked()
{
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);
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[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);
}
}
2021-05-13 20:09:46 +02:00
}