mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-14 22:36:26 +01:00
143 lines
5.7 KiB
C#
143 lines
5.7 KiB
C#
using NUnit.Framework;
|
|
using System;
|
|
using TINK.Model.Bike;
|
|
using TINK.Model.User;
|
|
using TINK.Model.User.Account;
|
|
using static TINK.Repository.CopriCallsMemory;
|
|
using TINK.Model.State;
|
|
using System.Collections.Generic;
|
|
using TINK.Repository;
|
|
using TINK.ViewModel.Bikes.Bike;
|
|
using TestFramework.Model.User.Account;
|
|
|
|
namespace UITest.Fixtures.ViewModel
|
|
{
|
|
public class TestBikeViewModel
|
|
{
|
|
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
|
|
{
|
|
public BikeInfoMutable(
|
|
string p_iId,
|
|
bool p_bIsDemo = false,
|
|
IEnumerable<string> p_oGroup = null,
|
|
WheelType? p_eWheelType = null,
|
|
TypeOfBike? p_eTypeOfBike = null,
|
|
string description = null,
|
|
string p_strCurrentStationName = null,
|
|
Uri operatorUri = null,
|
|
Func<DateTime> p_oDateTimeProvider = null,
|
|
IStateInfo stateInfo = null) : base(p_iId, p_bIsDemo, p_oGroup, p_eWheelType, p_eTypeOfBike, description, p_strCurrentStationName, operatorUri, null, p_oDateTimeProvider, stateInfo)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Tests base class functionaltiy by using child.
|
|
/// </summary>
|
|
public static BikeViewModelBase TestStateText_LoggedIn_Reserved(Func<TINK.Model.Bike.BC.BikeInfoMutable, User, BikeViewModelBase> p_oFactory)
|
|
{
|
|
var l_oBike = new BikeInfoMutable(
|
|
"2",
|
|
false,
|
|
new List<string> { "TINK" },
|
|
WheelType.Trike,
|
|
TypeOfBike.Cargo,
|
|
"Test description",
|
|
"3",
|
|
null,
|
|
() => new DateTime(1980, 1, 1)); // Now time stamp
|
|
|
|
// Update state from Copri.
|
|
l_oBike.State.Load(
|
|
InUseStateEnum.Reserved, // Copri acknowledges state reserved.
|
|
new DateTime(1980, 1, 1), // Date when bike was booked.
|
|
"ragu@gnu-systems.de"); // Owner from Copri.
|
|
|
|
var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, "987654321" /* session cookie */, new List<string> { "TINK" }));
|
|
var l_oUser = new User(
|
|
l_oStoreMock,
|
|
l_oStoreMock.Load().Result,
|
|
"123456789");
|
|
|
|
// Verify prerequisites
|
|
Assert.AreEqual(InUseStateEnum.Reserved, l_oBike.State.Value);
|
|
Assert.IsTrue(l_oUser.IsLoggedIn);
|
|
Assert.AreEqual(l_oBike.State.MailAddress, l_oUser.Mail);
|
|
|
|
// Do not update from Copri
|
|
var l_oViewModel = p_oFactory(l_oBike, l_oUser);
|
|
|
|
return l_oViewModel;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tests base class functionaltiy by using child.
|
|
/// </summary>
|
|
public static BikeViewModelBase TestStateText_LoggedIn_ReservedWithCopriConnect(Func<TINK.Model.Bike.BC.BikeInfoMutable, User, BikeViewModelBase> p_oFactory)
|
|
{
|
|
var l_oBike = new BikeInfoMutable(
|
|
"2",
|
|
false,
|
|
new List<string> { "TINK" },
|
|
WheelType.Trike,
|
|
TypeOfBike.Cargo,
|
|
"Test description",
|
|
"3",
|
|
null,
|
|
() => (new DateTime(1980, 1, 1)).Add(new TimeSpan(0, 8, 0)));
|
|
|
|
// Update state from Copri.
|
|
l_oBike.State.Load(
|
|
InUseStateEnum.Reserved, // Copri acknowledges state reserved.
|
|
new DateTime(1980, 1, 1),
|
|
"ragu@gnu-systems.de", // Owner from Copri.
|
|
"4asdfA"); // Reservation code from Copri
|
|
|
|
var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, "987654321" /* session cookie */, new List<string> { "TINK" }));
|
|
var l_oUser = new User(
|
|
l_oStoreMock, // Mocks account store functionality.
|
|
l_oStoreMock.Load().Result,
|
|
"123456789");
|
|
|
|
// Verify prerequisites
|
|
Assert.AreEqual(InUseStateEnum.Reserved, l_oBike.State.Value);
|
|
Assert.IsTrue(l_oUser.IsLoggedIn);
|
|
Assert.AreEqual(l_oBike.State.MailAddress, l_oUser.Mail);
|
|
|
|
var l_oViewModel = p_oFactory(l_oBike, l_oUser); // Bikes collection mock.
|
|
|
|
return l_oViewModel;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tests base class functionaltiy by using child.
|
|
/// </summary>
|
|
public static BikeViewModelBase TestStateText_LoggedIn_Booked(Func<TINK.Model.Bike.BC.BikeInfoMutable, User, BikeViewModelBase> p_oFactory)
|
|
{
|
|
var l_oBike = new BikeInfoMutable("2", false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Cargo, "Test description", "3");
|
|
|
|
// Update from Copri.
|
|
l_oBike.State.Load(
|
|
InUseStateEnum.Booked,
|
|
new DateTime(2017, 10, 24, 21, 49, 3),
|
|
"ragu@gnu-systems.de",
|
|
"4asdfA");
|
|
|
|
var l_oCopriServer = new CopriCallsMemory(SampleSets.Set1, 1);
|
|
|
|
var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, "987654321" /* session cookie */, new List<string> { "TINK" }));
|
|
var l_oUser = new User(
|
|
l_oStoreMock,
|
|
l_oStoreMock.Load().Result,
|
|
"123456789"); // Device id
|
|
|
|
// Verify prerequisites
|
|
Assert.AreEqual(InUseStateEnum.Booked, l_oBike.State.Value);
|
|
Assert.IsTrue(l_oUser.IsLoggedIn);
|
|
Assert.AreEqual(l_oBike.State.MailAddress, l_oUser.Mail);
|
|
|
|
var l_oViewModel = p_oFactory(l_oBike, l_oUser);
|
|
|
|
return l_oViewModel;
|
|
}
|
|
}
|
|
}
|