Version 3.0.337

This commit is contained in:
Anja Müller-Meißner 2022-08-30 15:42:25 +02:00
parent fd0e63cf10
commit 573fe77e12
2336 changed files with 33688 additions and 86082 deletions

View file

@ -1,19 +1,18 @@
using NUnit.Framework;
using Rhino.Mocks;
using System;
using System;
using System.Collections.Generic;
using TINK.Model.Bike;
using TINK.Model.Bikes.Bike;
using NSubstitute;
using NUnit.Framework;
using TINK.Model.Bikes.BikeInfoNS;
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
using TINK.Model.State;
using IBikeInfo = TINK.Model.Bike.BC.IBikeInfo;
using IBikeInfo = TINK.Model.Bikes.BikeInfoNS.BC.IBikeInfo;
namespace TestTINKLib.Fixtures.ObjectTests.Bike
{
[TestFixture]
public class TestBikeInfoMutable
{
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
private class BikeInfoMutable : TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable
{
public BikeInfoMutable(
string id,
@ -28,7 +27,17 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
Uri operatorUri = null,
RentalDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null) : base(id, lockModel, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
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)
{
}
}
@ -52,80 +61,92 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
}
[Test]
public void TestConstructCopy()
public void TestConstructCopyBooked()
{
// State Booked
var l_oBikeInfoMock = MockRepository.GenerateStub<IBikeInfo>();
var l_oStateInfoMock = MockRepository.GenerateStub<IStateInfo>();
var bikeInfoSource = Substitute.For<IBikeInfo>();
var stateSource = Substitute.For<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.StationId).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");
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 l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.AreEqual("23", l_oBikeInfo.StationId);
Assert.AreEqual("My Station Name", l_oBikeInfo.StationName);
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);
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
l_oBikeInfoMock = MockRepository.GenerateStub<IBikeInfo>();
l_oStateInfoMock = MockRepository.GenerateStub<IStateInfo>();
var bikeInfoSource = Substitute.For<IBikeInfo>();
var stateSource = Substitute.For<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.StationId).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");
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");
l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.AreEqual("23", l_oBikeInfo.StationId);
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);
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
l_oBikeInfoMock = MockRepository.GenerateStub<IBikeInfo>();
l_oStateInfoMock = MockRepository.GenerateStub<IStateInfo>();
var bikeInfoSource = Substitute.For<IBikeInfo>();
var stateSource = Substitute.For<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.StationId).Return("23");
l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock);
l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Disposable);
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);
l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
var bikeInfoTarget = new TINK.Model.Bikes.BikeInfoNS.BC.BikeInfoMutable(bikeInfoSource, "My Station Name");
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.AreEqual("23", l_oBikeInfo.StationId);
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);
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);
}
}
}