mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-06 02:56:32 +01:00
128 lines
6.2 KiB
C#
128 lines
6.2 KiB
C#
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,
|
|
bool isDemo = false,
|
|
IEnumerable<string> group = null,
|
|
WheelType? wheelType = null,
|
|
TypeOfBike? typeOfBike = null,
|
|
string description = null,
|
|
string currentStationId = null,
|
|
Uri operatorUri = null,
|
|
TariffDescription tariffDescription = null,
|
|
Func<DateTime> dateTimeProvider = null,
|
|
IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
|
|
{
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void TestConstruct()
|
|
{
|
|
var l_oBikeInfo = new BikeInfoMutable("17");
|
|
Assert.AreEqual("17", l_oBikeInfo.Id);
|
|
Assert.IsNull(l_oBikeInfo.CurrentStation);
|
|
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", 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.CurrentStation);
|
|
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);
|
|
l_oBikeInfoMock.Stub(x => x.CurrentStation).Return("23");
|
|
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");
|
|
|
|
var l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock);
|
|
|
|
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeInfo.State.Value);
|
|
Assert.AreEqual("22", l_oBikeInfo.Id);
|
|
Assert.AreEqual("23", l_oBikeInfo.CurrentStation);
|
|
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);
|
|
l_oBikeInfoMock.Stub(x => x.CurrentStation).Return("23");
|
|
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");
|
|
|
|
l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock);
|
|
|
|
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeInfo.State.Value);
|
|
Assert.AreEqual("22", l_oBikeInfo.Id);
|
|
Assert.AreEqual("23", l_oBikeInfo.CurrentStation);
|
|
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);
|
|
l_oBikeInfoMock.Stub(x => x.CurrentStation).Return("23");
|
|
l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock);
|
|
l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Disposable);
|
|
|
|
l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock);
|
|
|
|
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
|
|
Assert.AreEqual("22", l_oBikeInfo.Id);
|
|
Assert.AreEqual("23", l_oBikeInfo.CurrentStation);
|
|
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);
|
|
}
|
|
}
|
|
}
|