mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-14 22:36:26 +01:00
152 lines
5.7 KiB
C#
152 lines
5.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using TINK.Model.Bikes.BikeInfoNS;
|
|
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
|
using TINK.Model.State;
|
|
using IBikeInfo = TINK.Model.Bikes.BikeInfoNS.BC.IBikeInfo;
|
|
|
|
namespace TestTINKLib.Fixtures.ObjectTests.Bike
|
|
{
|
|
[TestFixture]
|
|
public class TestBikeInfoMutable
|
|
{
|
|
private class BikeInfoMutable : TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable
|
|
{
|
|
public BikeInfoMutable(
|
|
string id,
|
|
LockModel lockModel,
|
|
bool isDemo = false,
|
|
IEnumerable<string> group = null,
|
|
WheelType? wheelType = null,
|
|
TypeOfBike? typeOfBike = null,
|
|
string description = null,
|
|
string stationId = null,
|
|
string stationName = null,
|
|
Uri operatorUri = null,
|
|
RentalDescription tariffDescription = null,
|
|
Func<DateTime> dateTimeProvider = null,
|
|
IStateInfo stateInfo = null) : base(
|
|
new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike(id, lockModel, wheelType, typeOfBike, description),
|
|
new TINK.Model.Bikes.BikeInfoNS.DriveNS.Drive(),
|
|
isDemo,
|
|
group,
|
|
stationId,
|
|
stationName,
|
|
operatorUri,
|
|
tariffDescription,
|
|
dateTimeProvider,
|
|
stateInfo)
|
|
{
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void TestConstruct()
|
|
{
|
|
var l_oBikeInfo = new BikeInfoMutable("17", LockModel.ILockIt);
|
|
Assert.AreEqual("17", l_oBikeInfo.Id);
|
|
Assert.IsNull(l_oBikeInfo.StationId);
|
|
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
|
|
Assert.AreEqual(null, l_oBikeInfo.WheelType);
|
|
Assert.AreEqual(null, l_oBikeInfo.TypeOfBike);
|
|
|
|
l_oBikeInfo = new BikeInfoMutable("22", LockModel.ILockIt, false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo, "Test description", "23");
|
|
Assert.AreEqual("22", l_oBikeInfo.Id);
|
|
Assert.IsFalse(l_oBikeInfo.IsDemo);
|
|
Assert.AreEqual("23", l_oBikeInfo.StationId);
|
|
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
|
|
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
|
|
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void TestConstructCopyBooked()
|
|
{
|
|
// State Booked
|
|
var bikeInfoSource = Substitute.For<IBikeInfo>();
|
|
var stateSource = Substitute.For<IStateInfo>();
|
|
|
|
bikeInfoSource.Bike.Returns(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.BordComputer, WheelType.Trike, TypeOfBike.Cargo));
|
|
bikeInfoSource.StationId.Returns("23");
|
|
bikeInfoSource.State.Returns(stateSource);
|
|
stateSource.Value.Returns(InUseStateEnum.Booked);
|
|
stateSource.From.Returns(new System.DateTime(2018, 01, 03));
|
|
stateSource.MailAddress.Returns("a@b");
|
|
stateSource.Code.Returns("234");
|
|
|
|
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
|
|
|
|
Assert.AreEqual(InUseStateEnum.Booked, bikeInfoTarget.State.Value);
|
|
Assert.AreEqual("22", bikeInfoTarget.Id);
|
|
Assert.AreEqual("23", bikeInfoTarget.StationId);
|
|
Assert.AreEqual("My Station Name", bikeInfoTarget.StationName);
|
|
Assert.AreEqual(WheelType.Trike, bikeInfoTarget.WheelType);
|
|
Assert.AreEqual(TypeOfBike.Cargo, bikeInfoTarget.TypeOfBike);
|
|
Assert.AreEqual(InUseStateEnum.Booked, bikeInfoTarget.State.Value);
|
|
Assert.AreEqual(new System.DateTime(2018, 01, 03), bikeInfoTarget.State.From);
|
|
Assert.AreEqual("a@b", bikeInfoTarget.State.MailAddress);
|
|
}
|
|
|
|
[Test]
|
|
public void TestConstructCopyReserved()
|
|
{
|
|
// State Reserved
|
|
var bikeInfoSource = Substitute.For<IBikeInfo>();
|
|
var stateSource = Substitute.For<IStateInfo>();
|
|
|
|
bikeInfoSource.Bike.Returns(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.BordComputer, WheelType.Trike, TypeOfBike.Cargo));
|
|
bikeInfoSource.StationId.Returns("23");
|
|
bikeInfoSource.State.Returns(stateSource);
|
|
stateSource.Value.Returns(InUseStateEnum.Reserved);
|
|
stateSource.From.Returns(new System.DateTime(2018, 01, 03));
|
|
stateSource.MailAddress.Returns("a@b");
|
|
stateSource.Code.Returns("234");
|
|
|
|
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
|
|
|
|
Assert.AreEqual(InUseStateEnum.Reserved, bikeInfoTarget.State.Value);
|
|
Assert.AreEqual("22", bikeInfoTarget.Id);
|
|
Assert.AreEqual("23", bikeInfoTarget.StationId);
|
|
Assert.AreEqual(WheelType.Trike, bikeInfoTarget.WheelType);
|
|
Assert.AreEqual(TypeOfBike.Cargo, bikeInfoTarget.TypeOfBike);
|
|
Assert.AreEqual(InUseStateEnum.Reserved, bikeInfoTarget.State.Value);
|
|
Assert.AreEqual(new System.DateTime(2018, 01, 03), bikeInfoTarget.State.From);
|
|
Assert.AreEqual("a@b", bikeInfoTarget.State.MailAddress);
|
|
|
|
}
|
|
|
|
[Test]
|
|
public void TestConstructCopyAvailable()
|
|
{
|
|
// State Disposable
|
|
var bikeInfoSource = Substitute.For<IBikeInfo>();
|
|
var stateSource = Substitute.For<IStateInfo>();
|
|
|
|
bikeInfoSource.Bike.Returns(new TINK.Model.Bikes.BikeInfoNS.BikeNS.Bike("22", LockModel.BordComputer, WheelType.Trike, TypeOfBike.Cargo));
|
|
bikeInfoSource.StationId.Returns("23");
|
|
bikeInfoSource.State.Returns(stateSource);
|
|
stateSource.Value.Returns(InUseStateEnum.Disposable);
|
|
|
|
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
|
|
|
|
Assert.AreEqual(InUseStateEnum.Disposable, bikeInfoTarget.State.Value);
|
|
Assert.AreEqual("22", bikeInfoTarget.Id);
|
|
Assert.AreEqual("23", bikeInfoTarget.StationId);
|
|
Assert.AreEqual(WheelType.Trike, bikeInfoTarget.WheelType);
|
|
Assert.AreEqual(TypeOfBike.Cargo, bikeInfoTarget.TypeOfBike);
|
|
Assert.AreEqual(InUseStateEnum.Disposable, bikeInfoTarget.State.Value);
|
|
Assert.IsNull(bikeInfoTarget.State.From);
|
|
}
|
|
|
|
[Test]
|
|
public void TestConstructBikeNull()
|
|
{
|
|
Assert.That(
|
|
() => new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(null, "My Station Name"),
|
|
Throws.ArgumentNullException);
|
|
}
|
|
}
|
|
}
|