Legacy testing lib added..

This commit is contained in:
Oliver Hauff 2021-07-12 21:31:46 +02:00
parent 0167fc321f
commit 47ed05837e
118 changed files with 17505 additions and 0 deletions

View file

@ -0,0 +1,20 @@
using NUnit.Framework;
using TINK.Model.Bike.BC;
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BC
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestBikeInfo
{
[Test]
public void TestCtorCopyNull()
{
Assert.Throws<System.ArgumentException>(
() => new BikeInfo(null),
"Verify that no unspecific reference not set to... exception is thrown");
}
}
}

View file

@ -0,0 +1,128 @@
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);
}
}
}