sharee.bike-App/TestShareeLib/Model/Bikes/BikeInfoNS/BluetoothLock/TestBikeInfo.cs

109 lines
4.7 KiB
C#
Raw Normal View History

2023-01-18 14:22:51 +01:00
using System;
using NSubstitute.ExceptionExtensions;
2022-08-30 15:42:25 +02:00
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>(
2023-01-18 14:22:51 +01:00
() => new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, "1"), null),
2022-09-06 16:08:19 +02:00
"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()
{
2023-01-18 14:22:51 +01:00
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 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(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 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(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value);
2022-09-06 16:08:19 +02:00
}
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(),
2023-01-18 14:22:51 +01:00
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
2022-09-06 16:08:19 +02:00
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()
{
2023-01-18 14:22:51 +01:00
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 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(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 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(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 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-09-06 16:08:19 +02:00
}
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,
2023-01-18 14:22:51 +01:00
new Drive(),
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
112,
2022-09-06 16:08:19 +02:00
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()
{
2023-01-18 14:22:51 +01:00
Assert.AreEqual("12", new BikeInfo(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new Drive(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 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(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 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(), TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).State.Value);
2022-09-06 16:08:19 +02:00
}
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(),
2023-01-18 14:22:51 +01:00
TINK.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
2022-09-06 16:08:19 +02:00
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
}