sharee.bike-App/TestTINKLib/Fixtures/ObjectTests/Bike/BC/TestBikeInfoMutable.cs

132 lines
6.4 KiB
C#
Raw Normal View History

2021-07-12 21:31:46 +02:00
using NUnit.Framework;
using Rhino.Mocks;
using System;
using System.Collections.Generic;
using TINK.Model.Bike;
using TINK.Model.Bikes.Bike;
using TINK.Model.State;
using IBikeInfo = TINK.Model.Bike.BC.IBikeInfo;
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
[TestFixture]
public class TestBikeInfoMutable
{
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
{
public BikeInfoMutable(
string id,
2022-04-25 22:15:15 +02:00
LockModel lockModel,
2021-07-12 21:31:46 +02:00
bool isDemo = false,
IEnumerable<string> group = null,
WheelType? wheelType = null,
TypeOfBike? typeOfBike = null,
string description = null,
2022-01-04 18:59:16 +01:00
string stationId = null,
string stationName = null,
2021-07-12 21:31: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, lockModel, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
2021-07-12 21:31:46 +02:00
{
}
}
[Test]
public void TestConstruct()
{
2022-04-25 22:15:15 +02:00
var l_oBikeInfo = new BikeInfoMutable("17", LockModel.ILockIt);
2021-07-12 21:31:46 +02:00
Assert.AreEqual("17", l_oBikeInfo.Id);
2022-01-04 18:59:16 +01:00
Assert.IsNull(l_oBikeInfo.StationId);
2021-07-12 21:31:46 +02:00
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.AreEqual(null, l_oBikeInfo.WheelType);
Assert.AreEqual(null, l_oBikeInfo.TypeOfBike);
2022-04-25 22:15:15 +02:00
l_oBikeInfo = new BikeInfoMutable("22", LockModel.ILockIt, false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo, "Test description", "23");
2021-07-12 21:31:46 +02:00
Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.IsFalse(l_oBikeInfo.IsDemo);
2022-01-04 18:59:16 +01:00
Assert.AreEqual("23", l_oBikeInfo.StationId);
2021-07-12 21:31:46 +02:00
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 TestConstructCopy()
{
// State Booked
var l_oBikeInfoMock = MockRepository.GenerateStub<IBikeInfo>();
var l_oStateInfoMock = MockRepository.GenerateStub<IStateInfo>();
l_oBikeInfoMock.Stub(x => x.Id).Return("22");
l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo);
l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike);
2022-01-04 18:59:16 +01:00
l_oBikeInfoMock.Stub(x => x.StationId).Return("23");
2021-07-12 21:31:46 +02:00
l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock);
l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Booked);
l_oStateInfoMock.Stub(x => x.From).Return(new System.DateTime(2018, 01, 03));
l_oStateInfoMock.Stub(x => x.MailAddress).Return("a@b");
l_oStateInfoMock.Stub(x => x.Code).Return("234");
2022-01-04 18:59:16 +01:00
var l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
2021-07-12 21:31:46 +02:00
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id);
2022-01-04 18:59:16 +01:00
Assert.AreEqual("23", l_oBikeInfo.StationId);
Assert.AreEqual("My Station Name", l_oBikeInfo.StationName);
2021-07-12 21:31:46 +02:00
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeInfo.State.Value);
Assert.AreEqual(new System.DateTime(2018, 01, 03), l_oBikeInfo.State.From);
Assert.AreEqual("a@b", l_oBikeInfo.State.MailAddress);
// State Reserved
l_oBikeInfoMock = MockRepository.GenerateStub<IBikeInfo>();
l_oStateInfoMock = MockRepository.GenerateStub<IStateInfo>();
l_oBikeInfoMock.Stub(x => x.Id).Return("22");
l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo);
l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike);
2022-01-04 18:59:16 +01:00
l_oBikeInfoMock.Stub(x => x.StationId).Return("23");
2021-07-12 21:31:46 +02:00
l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock);
l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Reserved);
l_oStateInfoMock.Stub(x => x.From).Return(new System.DateTime(2018, 01, 03));
l_oStateInfoMock.Stub(x => x.MailAddress).Return("a@b");
l_oStateInfoMock.Stub(x => x.Code).Return("234");
2022-01-04 18:59:16 +01:00
l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
2021-07-12 21:31:46 +02:00
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id);
2022-01-04 18:59:16 +01:00
Assert.AreEqual("23", l_oBikeInfo.StationId);
2021-07-12 21:31:46 +02:00
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeInfo.State.Value);
Assert.AreEqual(new System.DateTime(2018, 01, 03), l_oBikeInfo.State.From);
Assert.AreEqual("a@b", l_oBikeInfo.State.MailAddress);
// State Disposable
l_oBikeInfoMock = MockRepository.GenerateStub<IBikeInfo>();
l_oStateInfoMock = MockRepository.GenerateStub<IStateInfo>();
l_oBikeInfoMock.Stub(x => x.Id).Return("22");
l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo);
l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike);
2022-01-04 18:59:16 +01:00
l_oBikeInfoMock.Stub(x => x.StationId).Return("23");
2021-07-12 21:31:46 +02:00
l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock);
l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Disposable);
2022-01-04 18:59:16 +01:00
l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
2021-07-12 21:31:46 +02:00
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id);
2022-01-04 18:59:16 +01:00
Assert.AreEqual("23", l_oBikeInfo.StationId);
2021-07-12 21:31:46 +02:00
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.IsNull(l_oBikeInfo.State.From);
}
}
}