sharee.bike-App/TestShareeLib/Model/Bike/BC/TestBikeMutable.cs

85 lines
3.4 KiB
C#
Raw Normal View History

2021-05-13 20:09:46 +02:00
using System;
using System.Collections.Generic;
using NUnit.Framework;
using TINK.Model.Bike;
using TINK.Model.Bikes.Bike;
using TINK.Model.State;
namespace TestTINKLib
{
[TestFixture]
class TestBikeMutable
{
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
{
public BikeInfoMutable(
2021-06-26 20:57:55 +02:00
string id,
2022-04-25 22:15:15 +02:00
LockModel lockType,
2021-05-13 20:09:46 +02:00
bool isDemo = false,
IEnumerable<string> group = null,
WheelType? wheelType = null,
2022-04-25 22:15:15 +02:00
TypeOfBike? typeOfBike = null,
2021-05-13 20:09:46 +02:00
string description = null,
2022-01-04 18:59:16 +01:00
string stationId = null,
string stationName = null,
2021-05-13 20:09:46 +02:00
Uri operatorUri = null,
TariffDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
2022-04-25 22:15:15 +02:00
IStateInfo stateInfo = null) : base(id, lockType, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
2021-05-13 20:09:46 +02:00
{
}
}
[Test]
public void TestConstruct()
{
var l_oBike = new BikeInfoMutable(
2021-06-26 20:57:55 +02:00
"42",
2022-04-25 22:15:15 +02:00
LockModel.ILockIt,
2021-05-13 20:09:46 +02:00
false,
new List<string> { "TINK" },
WheelType.Two,
TypeOfBike.Cargo);
2021-06-26 20:57:55 +02:00
Assert.AreEqual("42", l_oBike.Id);
2021-05-13 20:09:46 +02:00
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);
2022-01-04 18:59:16 +01:00
Assert.IsNull(l_oBike.StationId);
2021-05-13 20:09:46 +02:00
l_oBike = new BikeInfoMutable(
2021-06-26 20:57:55 +02:00
"17",
2022-04-25 22:15:15 +02:00
LockModel.ILockIt,
2021-05-13 20:09:46 +02:00
true,
new List<string> { "TINK" },
WheelType.Mono,
2022-04-25 22:15:15 +02:00
TypeOfBike.Allround,
2021-05-13 20:09:46 +02:00
"Test description",
2021-06-26 20:57:55 +02:00
"1");
2021-05-13 20:09:46 +02:00
2021-06-26 20:57:55 +02:00
Assert.AreEqual("17", l_oBike.Id);
2021-05-13 20:09:46 +02:00
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);
2022-01-04 18:59:16 +01:00
Assert.AreEqual("1", l_oBike.StationId);
2021-05-13 20:09:46 +02:00
}
[Test]
public void TestToString()
{
2022-04-25 22:15:15 +02:00
var l_oBike = new BikeInfoMutable("3", LockModel.ILockIt, false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Cargo, dateTimeProvider: () => new DateTime(1970, 1, 1));
2021-05-13 20:09:46 +02:00
Assert.AreEqual(
"Id=3, wheel(s)=Two, type=Cargo, demo=False, state=Disposable, location=On the road.",
l_oBike.ToString());
2022-04-25 22:15:15 +02:00
l_oBike = new BikeInfoMutable("3", LockModel.ILockIt, true, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "5", dateTimeProvider: () => new DateTime(1970, 1, 1));
2021-05-13 20:09:46 +02:00
Assert.AreEqual(
"Id=3, wheel(s)=Trike, type=Allround, demo=True, state=Disposable, location=Station 5.",
l_oBike.ToString());
}
}
}