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

102 lines
4.7 KiB
C#
Raw Normal View History

2024-04-09 12:53:23 +02:00
using System;
using NUnit.Framework;
using ShareeBike.Model.Bikes.BikeInfoNS.BikeNS;
using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock;
using ShareeBike.Model.Bikes.BikeInfoNS.DriveNS;
using ShareeBike.Model.State;
namespace SharedBusinessLogic.Tests.Fixtures.ObjectTests.Bike.BluetoothLock
{
[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");
[Test]
public void TestCtorAvailable()
{
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").Id, Is.EqualTo("12"));
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").StationId, Is.EqualTo("13"));
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value, Is.EqualTo(InUseStateEnum.Disposable));
}
[Test]
public void TestCtorAvailableBikeNull()
{
Assert.That(
() => new BikeInfo(
null,
new DriveMutable(),
ShareeBike.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
5200544,
new Guid("00000000-0000-0000-0000-000000000001"),
"13"),
Throws.ArgumentNullException);
}
[Test]
public void TestCtorRequested()
{
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.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, Is.EqualTo("12"));
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.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, Is.EqualTo(112));
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.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, Is.EqualTo(InUseStateEnum.Reserved));
}
[Test]
public void TestCtorRequestedBikeNull()
{
Assert.That(
() => new BikeInfo(
null,
new DriveMutable(),
ShareeBike.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*/),
Throws.ArgumentNullException);
}
[Test]
public void TestCtorBooked()
{
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.Model.Bikes.BikeInfoNS.BC.DataSource.Copri, 112, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b", "13", null /*operator uri*/).Id, Is.EqualTo("12"));
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.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, Is.EqualTo(112));
Assert.That(new BikeInfo(new ShareeBike.Model.Bikes.BikeInfoNS.BikeNS.Bike("12", LockModel.ILockIt), new DriveMutable(), ShareeBike.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, Is.EqualTo(InUseStateEnum.Booked));
}
[Test]
public void TestCtorBookedNull()
{
Assert.That(
() => new BikeInfo(
null,
new DriveMutable(),
ShareeBike.Model.Bikes.BikeInfoNS.BC.DataSource.Copri,
112,
new Guid(),
null,
null,
null,
new DateTime(2020, 1, 1),
"a@b",
"13",
null /*operator uri*/),
Throws.ArgumentNullException);
}
}
}