mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-21 21:46:27 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -1,65 +1,65 @@
|
|||
namespace TestTINKLib
|
||||
{
|
||||
/// <summary>
|
||||
/// Object do define login session info from copri.
|
||||
/// </summary>
|
||||
public struct LoginSessionCopriInfo
|
||||
{
|
||||
public LoginSessionCopriInfo(
|
||||
string p_strMail,
|
||||
string p_strPwd,
|
||||
string p_strAuthCookie,
|
||||
string p_strDeviceId)
|
||||
{
|
||||
Mail = p_strMail;
|
||||
Pwd = p_strPwd;
|
||||
AuthCookie = p_strAuthCookie;
|
||||
DeviceId = p_strDeviceId;
|
||||
}
|
||||
/// <summary>
|
||||
/// Object do define login session info from copri.
|
||||
/// </summary>
|
||||
public struct LoginSessionCopriInfo
|
||||
{
|
||||
public LoginSessionCopriInfo(
|
||||
string p_strMail,
|
||||
string p_strPwd,
|
||||
string p_strAuthCookie,
|
||||
string p_strDeviceId)
|
||||
{
|
||||
Mail = p_strMail;
|
||||
Pwd = p_strPwd;
|
||||
AuthCookie = p_strAuthCookie;
|
||||
DeviceId = p_strDeviceId;
|
||||
}
|
||||
|
||||
public string Mail { get; private set; }
|
||||
public string Pwd { get; private set; }
|
||||
public string AuthCookie { get; private set; }
|
||||
public string DeviceId { get; private set; }
|
||||
public string Mail { get; private set; }
|
||||
public string Pwd { get; private set; }
|
||||
public string AuthCookie { get; private set; }
|
||||
public string DeviceId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// First test user which typically has some bikes.
|
||||
/// </summary>
|
||||
public static LoginSessionCopriInfo JavaministerHardwareNr1 = new LoginSessionCopriInfo(
|
||||
"javaminister@gmail.com",
|
||||
"javaminister",
|
||||
"6103_4da3044c8657a04ba60e2eaa753bc51a_",
|
||||
"HwId1000000000000"
|
||||
);
|
||||
/// <summary>
|
||||
/// First test user which typically has some bikes.
|
||||
/// </summary>
|
||||
public static LoginSessionCopriInfo JavaministerHardwareNr1 = new LoginSessionCopriInfo(
|
||||
"javaminister@gmail.com",
|
||||
"javaminister",
|
||||
"6103_4da3044c8657a04ba60e2eaa753bc51a_",
|
||||
"HwId1000000000000"
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// First test user which typically has some bikes.
|
||||
/// </summary>
|
||||
public static LoginSessionCopriInfo SkiministerHardwareNr1 = new LoginSessionCopriInfo(
|
||||
"skiminister@posteo.de",
|
||||
"skiminister",
|
||||
"",
|
||||
"HwId1000000000000"
|
||||
);
|
||||
/// <summary>
|
||||
/// First test user which typically has some bikes.
|
||||
/// </summary>
|
||||
public static LoginSessionCopriInfo SkiministerHardwareNr1 = new LoginSessionCopriInfo(
|
||||
"skiminister@posteo.de",
|
||||
"skiminister",
|
||||
"",
|
||||
"HwId1000000000000"
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// User which does not exist in copri.
|
||||
/// </summary>
|
||||
public static LoginSessionCopriInfo JavaministerGibtsNet = new LoginSessionCopriInfo(
|
||||
"javaminister@gmail.com.GibtsNet",
|
||||
"javaminister",
|
||||
"",
|
||||
"HwId1000000000000"
|
||||
);
|
||||
/// <summary>
|
||||
/// User which does not exist in copri.
|
||||
/// </summary>
|
||||
public static LoginSessionCopriInfo JavaministerGibtsNet = new LoginSessionCopriInfo(
|
||||
"javaminister@gmail.com.GibtsNet",
|
||||
"javaminister",
|
||||
"",
|
||||
"HwId1000000000000"
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// User which does not exist in copri.
|
||||
/// </summary>
|
||||
public static LoginSessionCopriInfo JavaministerKeksGibtsNet = new LoginSessionCopriInfo(
|
||||
"javaminister@gmail.com",
|
||||
"javaminister",
|
||||
"6103_ThisKeksDoesNotExist_",
|
||||
"HwId1000000000000"
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// User which does not exist in copri.
|
||||
/// </summary>
|
||||
public static LoginSessionCopriInfo JavaministerKeksGibtsNet = new LoginSessionCopriInfo(
|
||||
"javaminister@gmail.com",
|
||||
"javaminister",
|
||||
"6103_ThisKeksDoesNotExist_",
|
||||
"HwId1000000000000"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,45 +3,45 @@ using Xamarin.Essentials;
|
|||
|
||||
namespace TestFramework.Model.Device
|
||||
{
|
||||
public class DeviceMock : ISmartDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the id of the device.
|
||||
/// </summary>
|
||||
private string m_strDeviceId = "522c6ff6886198fd";
|
||||
public class DeviceMock : ISmartDevice
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the id of the device.
|
||||
/// </summary>
|
||||
private string m_strDeviceId = "522c6ff6886198fd";
|
||||
|
||||
public string Manufacturer => throw new System.NotImplementedException();
|
||||
public string Manufacturer => throw new System.NotImplementedException();
|
||||
|
||||
public string Model => throw new System.NotImplementedException();
|
||||
public string Model => throw new System.NotImplementedException();
|
||||
|
||||
public DevicePlatform Platform => DevicePlatform.UWP;
|
||||
public DevicePlatform Platform => DevicePlatform.UWP;
|
||||
|
||||
public string VersionText => throw new System.NotImplementedException();
|
||||
public string VersionText => throw new System.NotImplementedException();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a device mock object setting device id to default value.
|
||||
/// </summary>
|
||||
public DeviceMock()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs a device mock object setting device id to default value.
|
||||
/// </summary>
|
||||
public DeviceMock()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a device mock object.
|
||||
/// </summary>
|
||||
/// <param name="p_strDeviceId">Mocked Id</param>
|
||||
public DeviceMock(string p_strDeviceId)
|
||||
{
|
||||
m_strDeviceId = p_strDeviceId;
|
||||
}
|
||||
/// <summary>
|
||||
/// Constructs a device mock object.
|
||||
/// </summary>
|
||||
/// <param name="p_strDeviceId">Mocked Id</param>
|
||||
public DeviceMock(string p_strDeviceId)
|
||||
{
|
||||
m_strDeviceId = p_strDeviceId;
|
||||
}
|
||||
|
||||
/// <summary> Gets the device ID.</summary>
|
||||
/// <returns></returns>
|
||||
public string Identifier
|
||||
=> m_strDeviceId;
|
||||
/// <summary> Gets the device ID.</summary>
|
||||
/// <returns></returns>
|
||||
public string Identifier
|
||||
=> m_strDeviceId;
|
||||
|
||||
/// <summary> Close the application. </summary>
|
||||
public void CloseApplication()
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <summary> Close the application. </summary>
|
||||
public void CloseApplication()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,22 +2,22 @@
|
|||
|
||||
namespace TestFramework.Model.Device
|
||||
{
|
||||
public class SpecialFolderMock : ISpecialFolder
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the folder name of external folder to write to.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetExternalFilesDir()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
public class SpecialFolderMock : ISpecialFolder
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the folder name of external folder to write to.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetExternalFilesDir()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary> Gets the folder name of the personal data folder dir on internal storage. </summary>
|
||||
/// <returns>Directory name.</returns>
|
||||
public string GetInternalPersonalDir()
|
||||
{
|
||||
return System.IO.Path.GetTempPath();
|
||||
}
|
||||
}
|
||||
/// <summary> Gets the folder name of the personal data folder dir on internal storage. </summary>
|
||||
/// <returns>Directory name.</returns>
|
||||
public string GetInternalPersonalDir()
|
||||
{
|
||||
return System.IO.Path.GetTempPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,39 +3,39 @@ using TINK.Model.User.Account;
|
|||
|
||||
namespace TestFramework.Model.User.Account
|
||||
{
|
||||
public class StoreMock : IStore
|
||||
{
|
||||
IAccount m_oAccount;
|
||||
public class StoreMock : IStore
|
||||
{
|
||||
IAccount m_oAccount;
|
||||
|
||||
/// <summary>
|
||||
/// Instantiates
|
||||
/// - a dummy account to simulate a logged in user before end of last session
|
||||
/// - an empty account to simulate no user logged in before end of last session
|
||||
/// </summary>
|
||||
/// <param name="p_oAccount">If null no user is logged in.</param>
|
||||
public StoreMock(IAccount p_oAccount = null)
|
||||
{
|
||||
m_oAccount = new TINK.Model.User.Account.Account(p_oAccount ?? new EmptyAccount());
|
||||
}
|
||||
/// <summary>
|
||||
/// Instantiates
|
||||
/// - a dummy account to simulate a logged in user before end of last session
|
||||
/// - an empty account to simulate no user logged in before end of last session
|
||||
/// </summary>
|
||||
/// <param name="p_oAccount">If null no user is logged in.</param>
|
||||
public StoreMock(IAccount p_oAccount = null)
|
||||
{
|
||||
m_oAccount = new TINK.Model.User.Account.Account(p_oAccount ?? new EmptyAccount());
|
||||
}
|
||||
|
||||
public Task<IAccount> Load()
|
||||
{
|
||||
return Task.FromResult<IAccount>(new TINK.Model.User.Account.Account(m_oAccount));
|
||||
}
|
||||
public Task<IAccount> Load()
|
||||
{
|
||||
return Task.FromResult<IAccount>(new TINK.Model.User.Account.Account(m_oAccount));
|
||||
}
|
||||
|
||||
public IAccount Delete(IAccount p_oAccount)
|
||||
{
|
||||
// Set member to empty.
|
||||
m_oAccount = new EmptyAccount();
|
||||
public IAccount Delete(IAccount p_oAccount)
|
||||
{
|
||||
// Set member to empty.
|
||||
m_oAccount = new EmptyAccount();
|
||||
|
||||
// Return empty account.
|
||||
return new EmptyAccount();
|
||||
}
|
||||
// Return empty account.
|
||||
return new EmptyAccount();
|
||||
}
|
||||
|
||||
public Task Save(IAccount p_oAccount)
|
||||
{
|
||||
m_oAccount = new TINK.Model.User.Account.Account(p_oAccount);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
public Task Save(IAccount p_oAccount)
|
||||
{
|
||||
m_oAccount = new TINK.Model.User.Account.Account(p_oAccount);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,304 +11,304 @@ using TINK.Repository.Response;
|
|||
|
||||
namespace TestFramework.Repository
|
||||
{
|
||||
/// <summary> Provides functionality for keeping a set of COPRI responses. </summary>
|
||||
public abstract class CopriCallMemoryBase
|
||||
{
|
||||
private string BikesAvailableResponse { get; }
|
||||
/// <summary> Provides functionality for keeping a set of COPRI responses. </summary>
|
||||
public abstract class CopriCallMemoryBase
|
||||
{
|
||||
private string BikesAvailableResponse { get; }
|
||||
|
||||
private string BikesOccupiedResponse { get; }
|
||||
private string BikesOccupiedResponse { get; }
|
||||
|
||||
private string AuthResponse { get; }
|
||||
private string AuthResponse { get; }
|
||||
|
||||
private string AuthOutResponse { get; }
|
||||
private string AuthOutResponse { get; }
|
||||
|
||||
private string Stations { get; }
|
||||
private string Stations { get; }
|
||||
|
||||
private string BookingRequestResponse { get; }
|
||||
private string BookingRequestResponse { get; }
|
||||
|
||||
private string CancelBookingRequestResponse { get; }
|
||||
private string CancelBookingRequestResponse { get; }
|
||||
|
||||
private IRequestBuilder requestBuilder;
|
||||
private IRequestBuilder requestBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs copri server mock from build in resources.
|
||||
/// </summary>
|
||||
/// <param name="bikesAvailableResponseResource"></param>
|
||||
/// <param name="bikesOccupiedResponseResoure"></param>
|
||||
/// <param name="authResponseResource"></param>
|
||||
/// <param name="authOutResponseResource"></param>
|
||||
/// <param name="stationsResponseResource"></param>
|
||||
/// <param name="bookingRequestResponseResource"></param>
|
||||
/// <param name="cancelBookingRequestResponseResource"></param>
|
||||
/// <param name="sessionCookie"></param>
|
||||
public CopriCallMemoryBase(
|
||||
string bikesAvailableResponseResource = null,
|
||||
string bikesOccupiedResponseResoure = null,
|
||||
string authResponseResource = null,
|
||||
string authOutResponseResource = null,
|
||||
string stationsResponseResource = null,
|
||||
string bookingRequestResponseResource = null,
|
||||
string cancelBookingRequestResponseResource = null,
|
||||
string sessionCookie = null)
|
||||
{
|
||||
string ReadResource(string resourceName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourceName))
|
||||
return string.Empty;
|
||||
/// <summary>
|
||||
/// Constructs copri server mock from build in resources.
|
||||
/// </summary>
|
||||
/// <param name="bikesAvailableResponseResource"></param>
|
||||
/// <param name="bikesOccupiedResponseResoure"></param>
|
||||
/// <param name="authResponseResource"></param>
|
||||
/// <param name="authOutResponseResource"></param>
|
||||
/// <param name="stationsResponseResource"></param>
|
||||
/// <param name="bookingRequestResponseResource"></param>
|
||||
/// <param name="cancelBookingRequestResponseResource"></param>
|
||||
/// <param name="sessionCookie"></param>
|
||||
public CopriCallMemoryBase(
|
||||
string bikesAvailableResponseResource = null,
|
||||
string bikesOccupiedResponseResoure = null,
|
||||
string authResponseResource = null,
|
||||
string authOutResponseResource = null,
|
||||
string stationsResponseResource = null,
|
||||
string bookingRequestResponseResource = null,
|
||||
string cancelBookingRequestResponseResource = null,
|
||||
string sessionCookie = null)
|
||||
{
|
||||
string ReadResource(string resourceName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourceName))
|
||||
return string.Empty;
|
||||
|
||||
using (var streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)))
|
||||
{
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
using (var streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)))
|
||||
{
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
SessionCookie = sessionCookie;
|
||||
SessionCookie = sessionCookie;
|
||||
|
||||
BikesAvailableResponse = ReadResource(bikesAvailableResponseResource);
|
||||
BikesOccupiedResponse = ReadResource(bikesOccupiedResponseResoure);
|
||||
AuthResponse = ReadResource(authResponseResource);
|
||||
AuthOutResponse = ReadResource(authOutResponseResource);
|
||||
Stations = ReadResource(stationsResponseResource);
|
||||
BookingRequestResponse = ReadResource(bookingRequestResponseResource);
|
||||
CancelBookingRequestResponse = ReadResource(cancelBookingRequestResponseResource);
|
||||
BikesAvailableResponse = ReadResource(bikesAvailableResponseResource);
|
||||
BikesOccupiedResponse = ReadResource(bikesOccupiedResponseResoure);
|
||||
AuthResponse = ReadResource(authResponseResource);
|
||||
AuthOutResponse = ReadResource(authOutResponseResource);
|
||||
Stations = ReadResource(stationsResponseResource);
|
||||
BookingRequestResponse = ReadResource(bookingRequestResponseResource);
|
||||
CancelBookingRequestResponse = ReadResource(cancelBookingRequestResponseResource);
|
||||
|
||||
requestBuilder = string.IsNullOrEmpty(sessionCookie)
|
||||
? new RequestBuilder(MerchantId, null /*UI language */) as IRequestBuilder
|
||||
: new RequestBuilderLoggedIn(MerchantId, null /*UI language */, sessionCookie);
|
||||
}
|
||||
requestBuilder = string.IsNullOrEmpty(sessionCookie)
|
||||
? new RequestBuilder(MerchantId, null /*UI language */) as IRequestBuilder
|
||||
: new RequestBuilderLoggedIn(MerchantId, null /*UI language */, sessionCookie);
|
||||
}
|
||||
|
||||
/// <summary> Holds the session id of the logged in user, null otherwise. </summary>
|
||||
public string SessionCookie { get; private set; }
|
||||
/// <summary> Holds the session id of the logged in user, null otherwise. </summary>
|
||||
public string SessionCookie { get; private set; }
|
||||
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <param name="p_oUser">User to log in.</param>
|
||||
/// <param name="deviceId">Id specifying user and hardware.</param>
|
||||
/// <param name="mailAddress">Mailaddress of user to log in.</param>
|
||||
/// <param name="password">Password to log in.</param>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public async Task<AuthorizationResponse> DoAuthorizationAsync(
|
||||
string mailAddress,
|
||||
string password,
|
||||
string deviceId)
|
||||
=> await Task.Run(() => DoAuthorize(AuthResponse, mailAddress, password, deviceId));
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <param name="p_oUser">User to log in.</param>
|
||||
/// <param name="deviceId">Id specifying user and hardware.</param>
|
||||
/// <param name="mailAddress">Mailaddress of user to log in.</param>
|
||||
/// <param name="password">Password to log in.</param>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public async Task<AuthorizationResponse> DoAuthorizationAsync(
|
||||
string mailAddress,
|
||||
string password,
|
||||
string deviceId)
|
||||
=> await Task.Run(() => DoAuthorize(AuthResponse, mailAddress, password, deviceId));
|
||||
|
||||
/// <summary> Logs user out. </summary>
|
||||
/// <param name="sessionCookie">User to log in.</param>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public async Task<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
=> await Task.Run(() => DoAuthout(AuthOutResponse, SessionCookie));
|
||||
/// <summary> Logs user out. </summary>
|
||||
/// <param name="sessionCookie">User to log in.</param>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public async Task<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
=> await Task.Run(() => DoAuthout(AuthOutResponse, SessionCookie));
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of bikes from memory.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
=> await Task.Run(() => GetBikesAvailable(BikesAvailableResponse, null, SessionCookie));
|
||||
/// <summary>
|
||||
/// Gets list of bikes from memory.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
=> await Task.Run(() => GetBikesAvailable(BikesAvailableResponse, null, SessionCookie));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
|
||||
/// </summary>
|
||||
/// <param name="p_strSessionCookie">Cookie to authenticate user.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public async Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
requestBuilder.GetBikesOccupied(); // Non mock implementation if ICopriServer call this member as well. To ensure comparable behaviour this member is called here as well.
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
// No user logged in.
|
||||
await Task.CompletedTask;
|
||||
return ResponseHelper.GetBikesOccupiedNone();
|
||||
}
|
||||
return await Task.Run(() => GetBikesOccupied(BikesOccupiedResponse, SessionCookie));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
|
||||
/// </summary>
|
||||
/// <param name="p_strSessionCookie">Cookie to authenticate user.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public async Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
requestBuilder.GetBikesOccupied(); // Non mock implementation if ICopriServer call this member as well. To ensure comparable behaviour this member is called here as well.
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
// No user logged in.
|
||||
await Task.CompletedTask;
|
||||
return ResponseHelper.GetBikesOccupiedNone();
|
||||
}
|
||||
return await Task.Run(() => GetBikesOccupied(BikesOccupiedResponse, SessionCookie));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list of stations from file.
|
||||
/// </summary>
|
||||
/// <param name="p_strCookie">Auto cookie of user if user is logged in.</param>
|
||||
/// <returns>List of files.</returns>
|
||||
public async Task<StationsAvailableResponse> GetStationsAsync()
|
||||
=> await Task.Run(() => GetStationsAll(Stations, null, SessionCookie));
|
||||
/// <summary>
|
||||
/// Get list of stations from file.
|
||||
/// </summary>
|
||||
/// <param name="p_strCookie">Auto cookie of user if user is logged in.</param>
|
||||
/// <returns>List of files.</returns>
|
||||
public async Task<StationsAvailableResponse> GetStationsAsync()
|
||||
=> await Task.Run(() => GetStationsAll(Stations, null, SessionCookie));
|
||||
|
||||
/// <summary>
|
||||
/// Gets booking request response.
|
||||
/// </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <returns>Booking response.</returns>
|
||||
public async Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
||||
=> await Task.Run(() => DoReserve(BookingRequestResponse, bikeId, SessionCookie));
|
||||
/// <summary>
|
||||
/// Gets booking request response.
|
||||
/// </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <returns>Booking response.</returns>
|
||||
public async Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
||||
=> await Task.Run(() => DoReserve(BookingRequestResponse, bikeId, SessionCookie));
|
||||
|
||||
/// <summary>
|
||||
/// Gets canel booking request response.
|
||||
/// </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="p_strCookie">Cookie of the logged in user.</param>
|
||||
/// <returns>Response on cancel booking request.</returns>
|
||||
public async Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string bikeId, Uri operatorUri)
|
||||
=> await Task.Run(() => DoCancelReservation(CancelBookingRequestResponse, bikeId, SessionCookie));
|
||||
/// <summary>
|
||||
/// Gets canel booking request response.
|
||||
/// </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="p_strCookie">Cookie of the logged in user.</param>
|
||||
/// <returns>Response on cancel booking request.</returns>
|
||||
public async Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string bikeId, Uri operatorUri)
|
||||
=> await Task.Run(() => DoCancelReservation(CancelBookingRequestResponse, bikeId, SessionCookie));
|
||||
|
||||
|
||||
/// <summary> Gets the merchant id.</summary>
|
||||
public string MerchantId => TinkApp.MerchantId;
|
||||
/// <summary> Gets the merchant id.</summary>
|
||||
public string MerchantId => TinkApp.MerchantId;
|
||||
|
||||
/// <summary> Returns false because cached values are returned. </summary>
|
||||
public bool IsConnected => false;
|
||||
/// <summary> Returns false because cached values are returned. </summary>
|
||||
public bool IsConnected => false;
|
||||
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <param name="deviceId">Id specifying user and hardware.</param>
|
||||
/// <param name="mailAddress">Mailaddress of user to log in.</param>
|
||||
/// <param name="password">Password to log in.</param>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public static AuthorizationResponse DoAuthorize(
|
||||
string doAuthResponse,
|
||||
string mailAddress,
|
||||
string password,
|
||||
string deviceId)
|
||||
{
|
||||
return mailAddress == "javaminister@gmail.com"
|
||||
&& password == "*********" &&
|
||||
deviceId == "HwId1000000000000"
|
||||
? JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(doAuthResponse).shareejson
|
||||
: JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(DO_AUTH_Unknown_User_FILE).shareejson;
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <param name="deviceId">Id specifying user and hardware.</param>
|
||||
/// <param name="mailAddress">Mailaddress of user to log in.</param>
|
||||
/// <param name="password">Password to log in.</param>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public static AuthorizationResponse DoAuthorize(
|
||||
string doAuthResponse,
|
||||
string mailAddress,
|
||||
string password,
|
||||
string deviceId)
|
||||
{
|
||||
return mailAddress == "javaminister@gmail.com"
|
||||
&& password == "*********" &&
|
||||
deviceId == "HwId1000000000000"
|
||||
? JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(doAuthResponse).shareejson
|
||||
: JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(DO_AUTH_Unknown_User_FILE).shareejson;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public static AuthorizationoutResponse DoAuthout(
|
||||
string authOutResponse,
|
||||
string sessionCookie)
|
||||
{
|
||||
// Response contains auth cookie of user "JavaministerHardwareNr1"
|
||||
// For this reason do not return answer if mail and pwd do not match.
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public static AuthorizationoutResponse DoAuthout(
|
||||
string authOutResponse,
|
||||
string sessionCookie)
|
||||
{
|
||||
// Response contains auth cookie of user "JavaministerHardwareNr1"
|
||||
// For this reason do not return answer if mail and pwd do not match.
|
||||
|
||||
return !string.IsNullOrEmpty(sessionCookie)
|
||||
? JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationoutResponse>>(authOutResponse).shareejson
|
||||
: throw new NotSupportedException();
|
||||
return !string.IsNullOrEmpty(sessionCookie)
|
||||
? JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationoutResponse>>(authOutResponse).shareejson
|
||||
: throw new NotSupportedException();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets list of bikes from memory.
|
||||
/// </summary>
|
||||
/// <param name="p_strMerchantId">Id of the merchant.</param>
|
||||
/// <param name="p_strSessionCookie">Auto cookie of user if user is logged in.</param>
|
||||
/// <param name="p_eSampleSet">Set of samples.</param>
|
||||
/// <param name="p_lStageIndex">Index of the stage.</param>
|
||||
/// <returns></returns>
|
||||
public static BikesAvailableResponse GetBikesAvailable(
|
||||
string BikesAvailableResponse,
|
||||
string p_strMerchantId,
|
||||
string p_strSessionCookie = null) =>
|
||||
CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BikesAvailableResponse);
|
||||
/// <summary>
|
||||
/// Gets list of bikes from memory.
|
||||
/// </summary>
|
||||
/// <param name="p_strMerchantId">Id of the merchant.</param>
|
||||
/// <param name="p_strSessionCookie">Auto cookie of user if user is logged in.</param>
|
||||
/// <param name="p_eSampleSet">Set of samples.</param>
|
||||
/// <param name="p_lStageIndex">Index of the stage.</param>
|
||||
/// <returns></returns>
|
||||
public static BikesAvailableResponse GetBikesAvailable(
|
||||
string BikesAvailableResponse,
|
||||
string p_strMerchantId,
|
||||
string p_strSessionCookie = null) =>
|
||||
CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BikesAvailableResponse);
|
||||
|
||||
/// <summary>
|
||||
/// Gets stations response.
|
||||
/// </summary>
|
||||
/// <param name="merchantId">Id of the merchant.</param>
|
||||
/// <param name="cookie">Auto cookie of user if user is logged in.</param>
|
||||
/// <param name="p_eSampleSet"></param>
|
||||
/// <param name="p_lStageIndex"></param>
|
||||
/// <returns></returns>
|
||||
public static StationsAvailableResponse GetStationsAll(
|
||||
string stations,
|
||||
string merchantId,
|
||||
string cookie = null)
|
||||
=> JsonConvertRethrow.DeserializeObject<ResponseContainer<StationsAvailableResponse>>(stations).shareejson;
|
||||
/// <summary>
|
||||
/// Gets stations response.
|
||||
/// </summary>
|
||||
/// <param name="merchantId">Id of the merchant.</param>
|
||||
/// <param name="cookie">Auto cookie of user if user is logged in.</param>
|
||||
/// <param name="p_eSampleSet"></param>
|
||||
/// <param name="p_lStageIndex"></param>
|
||||
/// <returns></returns>
|
||||
public static StationsAvailableResponse GetStationsAll(
|
||||
string stations,
|
||||
string merchantId,
|
||||
string cookie = null)
|
||||
=> JsonConvertRethrow.DeserializeObject<ResponseContainer<StationsAvailableResponse>>(stations).shareejson;
|
||||
|
||||
/// <summary>
|
||||
/// Gets booking request response.
|
||||
/// </summary>
|
||||
/// <param name="bikeId">Id of the bike.</param>
|
||||
/// <param name="sessionCookie">Identifies the logged in user.</param>
|
||||
/// <param name="sampleSet">Sample set to use.</param>
|
||||
/// <param name="stageIndex">Index of the stage.</param>
|
||||
/// <returns></returns>
|
||||
public static ReservationBookingResponse DoReserve(
|
||||
string bookingRequestResponse,
|
||||
string bikeId,
|
||||
string sessionCookie)
|
||||
=> JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationBookingResponse>>(bookingRequestResponse).shareejson;
|
||||
/// <summary>
|
||||
/// Gets booking request response.
|
||||
/// </summary>
|
||||
/// <param name="bikeId">Id of the bike.</param>
|
||||
/// <param name="sessionCookie">Identifies the logged in user.</param>
|
||||
/// <param name="sampleSet">Sample set to use.</param>
|
||||
/// <param name="stageIndex">Index of the stage.</param>
|
||||
/// <returns></returns>
|
||||
public static ReservationBookingResponse DoReserve(
|
||||
string bookingRequestResponse,
|
||||
string bikeId,
|
||||
string sessionCookie)
|
||||
=> JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationBookingResponse>>(bookingRequestResponse).shareejson;
|
||||
|
||||
/// <summary>
|
||||
/// Gets canel booking request response.
|
||||
/// </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="cookie">Cookie of the logged in user.</param>
|
||||
/// <returns>Response on cancel booking request.</returns>
|
||||
public static ReservationCancelReturnResponse DoCancelReservation(
|
||||
string cancelBookingRequestResponse,
|
||||
string bikeId,
|
||||
string cookie)
|
||||
=> JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(cancelBookingRequestResponse).shareejson;
|
||||
/// <summary>
|
||||
/// Gets canel booking request response.
|
||||
/// </summary>
|
||||
/// <param name="bikeId">Id of the bike to book.</param>
|
||||
/// <param name="cookie">Cookie of the logged in user.</param>
|
||||
/// <returns>Response on cancel booking request.</returns>
|
||||
public static ReservationCancelReturnResponse DoCancelReservation(
|
||||
string cancelBookingRequestResponse,
|
||||
string bikeId,
|
||||
string cookie)
|
||||
=> JsonConvertRethrow.DeserializeObject<ResponseContainer<ReservationCancelReturnResponse>>(cancelBookingRequestResponse).shareejson;
|
||||
|
||||
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
||||
=> null;
|
||||
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<ResponseBase> StartReturningBike(
|
||||
string bikeId,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
public Task<ResponseBase> StartReturningBike(
|
||||
string bikeId,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
Uri operatorUri,
|
||||
LocationDto geolocation,
|
||||
double batteryLevel)
|
||||
=> null;
|
||||
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
Uri operatorUri,
|
||||
LocationDto geolocation,
|
||||
double batteryLevel)
|
||||
=> null;
|
||||
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> null;
|
||||
public Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> null;
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> null;
|
||||
public Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> null;
|
||||
public Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<DoReturnResponse> DoReturn(
|
||||
string bikeId,
|
||||
LocationDto geolocation,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
public Task<DoReturnResponse> DoReturn(
|
||||
string bikeId,
|
||||
LocationDto geolocation,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
|
||||
string bikeId,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
|
||||
string bikeId,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> null;
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> null;
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
|
||||
/// </summary>
|
||||
/// <param name="sessionCookie">Cookie to authenticate user.</param>
|
||||
/// <param name="SampleSet">Sample set to use.</param>
|
||||
/// <param name="p_lStageIndex">Index of the stage.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public static BikesReservedOccupiedResponse GetBikesOccupied(
|
||||
string bikesOccupied,
|
||||
string sessionCookie = null)
|
||||
{
|
||||
var response = CopriCallsStatic.DeserializeResponse<BikesReservedOccupiedResponse>(bikesOccupied);
|
||||
return sessionCookie != null && (response?.authcookie?.Contains(sessionCookie) ?? false)
|
||||
? response
|
||||
: ResponseHelper.GetBikesOccupiedNone(sessionCookie);
|
||||
/// <summary>
|
||||
/// Gets a list of bikes reserved/ booked by acctive user from Copri.
|
||||
/// </summary>
|
||||
/// <param name="sessionCookie">Cookie to authenticate user.</param>
|
||||
/// <param name="SampleSet">Sample set to use.</param>
|
||||
/// <param name="p_lStageIndex">Index of the stage.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public static BikesReservedOccupiedResponse GetBikesOccupied(
|
||||
string bikesOccupied,
|
||||
string sessionCookie = null)
|
||||
{
|
||||
var response = CopriCallsStatic.DeserializeResponse<BikesReservedOccupiedResponse>(bikesOccupied);
|
||||
return sessionCookie != null && (response?.authcookie?.Contains(sessionCookie) ?? false)
|
||||
? response
|
||||
: ResponseHelper.GetBikesOccupiedNone(sessionCookie);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public const string DO_AUTH_Unknown_User_FILE = @"
|
||||
public const string DO_AUTH_Unknown_User_FILE = @"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""response"" : ""authorization"",
|
||||
|
@ -317,5 +317,5 @@ namespace TestFramework.Repository
|
|||
""apiserver"" : ""https://tinkwwp.copri-bike.de""
|
||||
}
|
||||
}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
|
||||
namespace TestFramework.Repository
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds some COPRI responses for testing purposes.
|
||||
/// </summary>
|
||||
/// <remarks> Holds some demo Meinkonrad and LastenradBayern bikes
|
||||
/// </remarks>
|
||||
public class CopriCallsMemory001 : CopriCallMemoryBase, ICopriServer
|
||||
{
|
||||
public CopriCallsMemory001(string sessionCookie = null) : base(
|
||||
bikesAvailableResponseResource: "TestFramework.Repository.CopriCallsMemory001.BikesAvailableResponse.json",
|
||||
bikesOccupiedResponseResoure: "TestFramework.Repository.CopriCallsMemory001.BikesOccupiedResponse.json",
|
||||
authResponseResource: "TestFramework.Repository.CopriCallsMemory001.AuthorizationResponse.json",
|
||||
authOutResponseResource: "TestFramework.Repository.CopriCallsMemory001.AuthoutResponse.json",
|
||||
stationsResponseResource: "TestFramework.Repository.CopriCallsMemory001.StationsAvailable.json",
|
||||
sessionCookie: sessionCookie)
|
||||
{ }
|
||||
}
|
||||
/// <summary>
|
||||
/// Holds some COPRI responses for testing purposes.
|
||||
/// </summary>
|
||||
/// <remarks> Holds some demo Meinkonrad and LastenradBayern bikes
|
||||
/// </remarks>
|
||||
public class CopriCallsMemory001 : CopriCallMemoryBase, ICopriServer
|
||||
{
|
||||
public CopriCallsMemory001(string sessionCookie = null) : base(
|
||||
bikesAvailableResponseResource: "TestFramework.Repository.CopriCallsMemory001.BikesAvailableResponse.json",
|
||||
bikesOccupiedResponseResoure: "TestFramework.Repository.CopriCallsMemory001.BikesOccupiedResponse.json",
|
||||
authResponseResource: "TestFramework.Repository.CopriCallsMemory001.AuthorizationResponse.json",
|
||||
authOutResponseResource: "TestFramework.Repository.CopriCallsMemory001.AuthoutResponse.json",
|
||||
stationsResponseResource: "TestFramework.Repository.CopriCallsMemory001.StationsAvailable.json",
|
||||
sessionCookie: sessionCookie)
|
||||
{ }
|
||||
}
|
||||
}
|
|
@ -8,98 +8,98 @@ using TINK.Repository.Response;
|
|||
|
||||
namespace TestFramework.Repository
|
||||
{
|
||||
/// <summary> Simulates communication errors when connecting to copri.</summary>
|
||||
public class ExceptionServer : ICopriServer
|
||||
{
|
||||
private Func<string, Exception> ExceptionFactory { get; }
|
||||
/// <summary> Simulates communication errors when connecting to copri.</summary>
|
||||
public class ExceptionServer : ICopriServer
|
||||
{
|
||||
private Func<string, Exception> ExceptionFactory { get; }
|
||||
|
||||
/// <summary> Constructs object.</summary>
|
||||
/// <param name="exceptionFactory"> Provides exceptions which are thrown whenn querrying information from server.</param>
|
||||
public ExceptionServer(Func<string, Exception> exceptionFactory)
|
||||
{
|
||||
ExceptionFactory = exceptionFactory;
|
||||
}
|
||||
/// <summary> Constructs object.</summary>
|
||||
/// <param name="exceptionFactory"> Provides exceptions which are thrown whenn querrying information from server.</param>
|
||||
public ExceptionServer(Func<string, Exception> exceptionFactory)
|
||||
{
|
||||
ExceptionFactory = exceptionFactory;
|
||||
}
|
||||
|
||||
public bool IsConnected => true;
|
||||
public bool IsConnected => true;
|
||||
|
||||
public string SessionCookie => string.Empty;
|
||||
public string SessionCookie => string.Empty;
|
||||
|
||||
public string MerchantId => string.Empty;
|
||||
public string MerchantId => string.Empty;
|
||||
|
||||
public Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string p_iBikeId, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string p_iBikeId, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ResponseBase> StartReturningBike(
|
||||
string bikeId,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
public Task<ResponseBase> StartReturningBike(
|
||||
string bikeId,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
Uri operatorUri,
|
||||
LocationDto geolocation,
|
||||
double batteryPercentage)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
Uri operatorUri,
|
||||
LocationDto geolocation,
|
||||
double batteryPercentage)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<DoReturnResponse> DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
|
||||
string bikeId,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<DoReturnResponse> DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
|
||||
string bikeId,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotImplementedException();
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetBikesAvailableAsync)}.");
|
||||
}
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetBikesAvailableAsync)}.");
|
||||
}
|
||||
|
||||
public Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetBikesOccupiedAsync)}.");
|
||||
}
|
||||
public Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetBikesOccupiedAsync)}.");
|
||||
}
|
||||
|
||||
public Task<StationsAvailableResponse> GetStationsAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetStationsAsync)}.");
|
||||
}
|
||||
}
|
||||
public Task<StationsAvailableResponse> GetStationsAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetStationsAsync)}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,79 +8,79 @@ using TINK.Services.BluetoothLock.Tdo;
|
|||
|
||||
namespace TestFramework.Services.BluetoothLock
|
||||
{
|
||||
public class LocksServiceMock : ILocksService
|
||||
{
|
||||
/// <param name="connectTimeout">Timeout for connect operation of a single lock.</param>
|
||||
public async Task<IEnumerable<LockInfoTdo>> GetLocksStateAsync(IEnumerable<LockInfoAuthTdo> locksInfo, TimeSpan connectTimeout)
|
||||
{
|
||||
return await Task.FromResult(new List<LockInfoTdo>());
|
||||
}
|
||||
public class LocksServiceMock : ILocksService
|
||||
{
|
||||
/// <param name="connectTimeout">Timeout for connect operation of a single lock.</param>
|
||||
public async Task<IEnumerable<LockInfoTdo>> GetLocksStateAsync(IEnumerable<LockInfoAuthTdo> locksInfo, TimeSpan connectTimeout)
|
||||
{
|
||||
return await Task.FromResult(new List<LockInfoTdo>());
|
||||
}
|
||||
|
||||
/// <summary> Holds timeout values for series of connecting attemps to a lock or multiple locks. </summary>
|
||||
public ITimeOutProvider TimeOut { get; set; }
|
||||
/// <summary> Holds timeout values for series of connecting attemps to a lock or multiple locks. </summary>
|
||||
public ITimeOutProvider TimeOut { get; set; }
|
||||
|
||||
public void UpdateSimulation(BikeCollection bikes) { }
|
||||
public void UpdateSimulation(BikeCollection bikes) { }
|
||||
|
||||
/// <summary> Opens lock.</summary>
|
||||
/// <param name="bike">Bike object to update.</param>
|
||||
public async Task<LockitLockingState?> OpenAsync(int lockId, byte[] copriKey) => await Task.FromResult(LockitLockingState.Open);
|
||||
/// <summary> Opens lock.</summary>
|
||||
/// <param name="bike">Bike object to update.</param>
|
||||
public async Task<LockitLockingState?> OpenAsync(int lockId, byte[] copriKey) => await Task.FromResult(LockitLockingState.Open);
|
||||
|
||||
/// <summary> Closes lock.</summary>
|
||||
/// <param name="bike">Bike object to update.</param>
|
||||
public async Task<LockitLockingState?> CloseAsync(int lockId, byte[] copriKey) => await Task.FromResult(LockitLockingState.Closed);
|
||||
/// <summary> Closes lock.</summary>
|
||||
/// <param name="bike">Bike object to update.</param>
|
||||
public async Task<LockitLockingState?> CloseAsync(int lockId, byte[] copriKey) => await Task.FromResult(LockitLockingState.Closed);
|
||||
|
||||
/// <summary> Gets the state of a bike. </summary>
|
||||
/// <param name="lockId">Id of lockId to get state for.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LockitLockingState?> GetState(string lockId) => await Task.FromResult((LockitLockingState?)null);
|
||||
/// <summary> Gets the state of a bike. </summary>
|
||||
/// <param name="lockId">Id of lockId to get state for.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<LockitLockingState?> GetState(string lockId) => await Task.FromResult((LockitLockingState?)null);
|
||||
|
||||
/// <summary> Connects to lock.</summary>
|
||||
/// <param name="authInfo"> Info required to connect to lock.</param>
|
||||
/// <param name="connectTimeout">Timeout for connect operation.</param>
|
||||
public async Task<LockInfoTdo> ConnectAsync(LockInfoAuthTdo authInfo, TimeSpan connectTimeout)
|
||||
{
|
||||
return await Task.FromResult(new LockInfoTdo.Builder { Id = 12, Guid = new System.Guid("00000000-0000-0000-0000-000000000042"), State = null }.Build());
|
||||
}
|
||||
/// <summary> Connects to lock.</summary>
|
||||
/// <param name="authInfo"> Info required to connect to lock.</param>
|
||||
/// <param name="connectTimeout">Timeout for connect operation.</param>
|
||||
public async Task<LockInfoTdo> ConnectAsync(LockInfoAuthTdo authInfo, TimeSpan connectTimeout)
|
||||
{
|
||||
return await Task.FromResult(new LockInfoTdo.Builder { Id = 12, Guid = new System.Guid("00000000-0000-0000-0000-000000000042"), State = null }.Build());
|
||||
}
|
||||
|
||||
/// <summary> Set sound settings.</summary>
|
||||
/// <param name="lockId">Id of lock to set sound settings.</param>
|
||||
public async Task<bool> SetSoundAsync(int lockId, SoundSettings settings)
|
||||
{
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
/// <summary> Set sound settings.</summary>
|
||||
/// <param name="lockId">Id of lock to set sound settings.</param>
|
||||
public async Task<bool> SetSoundAsync(int lockId, SoundSettings settings)
|
||||
{
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
/// <summary> Gets battery percentage.</summary>
|
||||
/// <param name="lockId">Id of lock to get info for.</param>
|
||||
public Task<double> GetBatteryPercentageAsync(int lockId)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
/// <summary> Gets battery percentage.</summary>
|
||||
/// <param name="lockId">Id of lock to get info for.</param>
|
||||
public Task<double> GetBatteryPercentageAsync(int lockId)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary> Sets whether alarm is on or off.</summary>
|
||||
/// <param name="lockId">Id of lock to get info from.</param>
|
||||
public async Task SetIsAlarmOffAsync(int lockId, bool activated)
|
||||
{
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
/// <summary> Sets whether alarm is on or off.</summary>
|
||||
/// <param name="lockId">Id of lock to get info from.</param>
|
||||
public async Task SetIsAlarmOffAsync(int lockId, bool activated)
|
||||
{
|
||||
await Task.FromResult(true);
|
||||
}
|
||||
|
||||
/// <summary> Gets whether alarm is on or off.</summary>
|
||||
/// <param name="lockId">Id of lock to get info for.</param>
|
||||
public async Task<bool> GetIsAlarmOffAsync(int lockId)
|
||||
{
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
/// <summary> Gets whether alarm is on or off.</summary>
|
||||
/// <param name="lockId">Id of lock to get info for.</param>
|
||||
public async Task<bool> GetIsAlarmOffAsync(int lockId)
|
||||
{
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
/// <summary>Gets a lock by bike Id.</summary>
|
||||
/// <param name="bikeId"></param>
|
||||
/// <returns>Lock object</returns>
|
||||
public ILockService this[int bikeId]
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/// <summary>Gets a lock by bike Id.</summary>
|
||||
/// <param name="bikeId"></param>
|
||||
/// <returns>Lock object</returns>
|
||||
public ILockService this[int bikeId]
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<LockingState> DisconnectAsync(int bikeId, Guid bikeGuid) => throw new NotSupportedException();
|
||||
}
|
||||
public Task<LockingState> DisconnectAsync(int bikeId, Guid bikeGuid) => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,118 +9,118 @@ using TINK.Repository.Response;
|
|||
|
||||
namespace TestFramework.Services.CopriApi.Connector
|
||||
{
|
||||
/// <summary> Allows use of memory for retrieving defined respones.</summary>
|
||||
public class CopriCallsCacheMemory001 : ICopriCache
|
||||
{
|
||||
private CopriCallsMemory001 server;
|
||||
/// <summary> Allows use of memory for retrieving defined respones.</summary>
|
||||
public class CopriCallsCacheMemory001 : ICopriCache
|
||||
{
|
||||
private CopriCallsMemory001 server;
|
||||
|
||||
public CopriCallsCacheMemory001(string sessionCookie = null)
|
||||
{
|
||||
server = new CopriCallsMemory001(sessionCookie);
|
||||
}
|
||||
public CopriCallsCacheMemory001(string sessionCookie = null)
|
||||
{
|
||||
server = new CopriCallsMemory001(sessionCookie);
|
||||
}
|
||||
|
||||
public bool IsStationsExpired => true;
|
||||
public bool IsStationsExpired => true;
|
||||
|
||||
public bool IsBikesAvailableExpired => true;
|
||||
public bool IsBikesAvailableExpired => true;
|
||||
|
||||
public bool IsBikesOccupiedExpired => true;
|
||||
public bool IsBikesOccupiedExpired => true;
|
||||
|
||||
public bool IsConnected => server.IsConnected;
|
||||
public bool IsConnected => server.IsConnected;
|
||||
|
||||
public string SessionCookie => server.SessionCookie;
|
||||
public string SessionCookie => server.SessionCookie;
|
||||
|
||||
public string MerchantId => server.MerchantId;
|
||||
public string MerchantId => server.MerchantId;
|
||||
|
||||
public void AddToCache(StationsAvailableResponse stations)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public void AddToCache(StationsAvailableResponse stations)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void AddToCache(BikesAvailableResponse bikes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public void AddToCache(BikesAvailableResponse bikes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public void AddToCache(BikesReservedOccupiedResponse bikes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public void AddToCache(BikesReservedOccupiedResponse bikes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<AuthorizationResponse> DoAuthorizationAsync(string p_strMailAddress, string p_strPassword, string p_strDeviceId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<ReservationBookingResponse> DoReserveAsync(string bikeId, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string p_iBikeId, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<ReservationCancelReturnResponse> DoCancelReservationAsync(string p_iBikeId, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotSupportedException();
|
||||
public Task<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotSupportedException();
|
||||
|
||||
public Task<ResponseBase> StartReturningBike(
|
||||
string bikeId,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
public Task<ResponseBase> StartReturningBike(
|
||||
string bikeId,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
Uri operatorUri,
|
||||
LocationDto geolocation,
|
||||
double batteryPercentage)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> UpdateLockingStateAsync(
|
||||
string bikeId,
|
||||
lock_state state,
|
||||
Uri operatorUri,
|
||||
LocationDto geolocation,
|
||||
double batteryPercentage)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> BookAvailableAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<ReservationBookingResponse> BookReservedAndStartOpeningAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<DoReturnResponse> DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<DoReturnResponse> DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
|
||||
string bikeId,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
|
||||
string bikeId,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, int? currentChargeBars, string message, bool isBikeBroken, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotImplementedException();
|
||||
/// <summary> Submits mini survey to copri server. </summary>
|
||||
/// <param name="answers">Collection of answers.</param>
|
||||
public Task<ResponseBase> DoSubmitMiniSurvey(IDictionary<string, string> answers)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
{
|
||||
return server.GetBikesAvailableAsync();
|
||||
}
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync()
|
||||
{
|
||||
return server.GetBikesAvailableAsync();
|
||||
}
|
||||
|
||||
public Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
return server.GetBikesOccupiedAsync();
|
||||
}
|
||||
public Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
return server.GetBikesOccupiedAsync();
|
||||
}
|
||||
|
||||
public Task<StationsAvailableResponse> GetStationsAsync()
|
||||
{
|
||||
return server.GetStationsAsync();
|
||||
}
|
||||
}
|
||||
public Task<StationsAvailableResponse> GetStationsAsync()
|
||||
{
|
||||
return server.GetStationsAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,17 @@ using Xamarin.Essentials;
|
|||
|
||||
namespace TestFramework.Model.Services.Geolocation
|
||||
{
|
||||
public class GeolocationMock : IGeolocation
|
||||
{
|
||||
public class GeolocationMock : IGeolocation
|
||||
{
|
||||
|
||||
public Task<Location> GetAsync(CancellationToken? cancelToken = null, DateTime? timeStamp = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<Location> GetAsync(CancellationToken? cancelToken = null, DateTime? timeStamp = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary> If true location data returned is simulated.</summary>
|
||||
public bool IsSimulation { get => true; }
|
||||
/// <summary> If true location data returned is simulated.</summary>
|
||||
public bool IsSimulation { get => true; }
|
||||
|
||||
public bool IsGeolcationEnabled => true;
|
||||
}
|
||||
public bool IsGeolcationEnabled => true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
namespace TestFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides helper functionality. Used in TestShareeLib and TestTINKLib.
|
||||
/// </summary>
|
||||
public static class TestHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Eases comparison of xml- files.
|
||||
/// </summary>
|
||||
/// <param name="p_strXmlFile"></param>
|
||||
/// <returns></returns>
|
||||
public static string PrepareXmlForStringCompare(string p_strXmlFile)
|
||||
{
|
||||
return p_strXmlFile.Replace("\r\n", string.Empty).Replace("\t", string.Empty).Replace(" ", string.Empty);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Provides helper functionality. Used in TestShareeLib and TestTINKLib.
|
||||
/// </summary>
|
||||
public static class TestHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Eases comparison of xml- files.
|
||||
/// </summary>
|
||||
/// <param name="p_strXmlFile"></param>
|
||||
/// <returns></returns>
|
||||
public static string PrepareXmlForStringCompare(string p_strXmlFile)
|
||||
{
|
||||
return p_strXmlFile.Replace("\r\n", string.Empty).Replace("\t", string.Empty).Replace(" ", string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue