mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 12:06:29 +02:00
Version 3.0.261
This commit is contained in:
parent
8aa3089f32
commit
4bccfe740b
80 changed files with 2672 additions and 458 deletions
306
TestFramework/Repository/CopriCallMemoryBase.cs
Normal file
306
TestFramework/Repository/CopriCallMemoryBase.cs
Normal file
|
@ -0,0 +1,306 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
using TINK.Repository.Request;
|
||||
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; }
|
||||
|
||||
private string BikesOccupiedResponse { get; }
|
||||
|
||||
private string AuthResponse { get; }
|
||||
|
||||
private string AuthOutResponse { get; }
|
||||
|
||||
private string Stations { get; }
|
||||
|
||||
private string BookingRequestResponse { get; }
|
||||
|
||||
private string CancelBookingRequestResponse { get; }
|
||||
|
||||
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;
|
||||
|
||||
using (var streamReader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)))
|
||||
{
|
||||
return streamReader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
SessionCookie = sessionCookie;
|
||||
|
||||
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) as IRequestBuilder
|
||||
: new RequestBuilderLoggedIn(MerchantId, sessionCookie);
|
||||
}
|
||||
|
||||
/// <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 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 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>
|
||||
/// 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 the merchant id.</summary>
|
||||
public string MerchantId => TinkApp.MerchantId;
|
||||
|
||||
/// <summary> Returns false because cached values are returned. </summary>
|
||||
public bool IsConnected => false;
|
||||
|
||||
/// <summary> Logs user in. </summary>
|
||||
/// <param name="p_oUser">User to log in.</param>
|
||||
/// <param name="p_strDeviceId">Id specifying user and hardware.</param>
|
||||
/// <param name="p_strMailAddress">Mailaddress of user to log in.</param>
|
||||
/// <param name="p_strPassword">Password to log in.</param>
|
||||
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
|
||||
public static AuthorizationResponse DoAuthorize(
|
||||
string DoAuthResponse,
|
||||
string p_strMailAddress,
|
||||
string p_strPassword,
|
||||
string p_strDeviceId)
|
||||
{
|
||||
return p_strMailAddress == "javaminister@gmail.com"
|
||||
&& p_strPassword == "*********" &&
|
||||
p_strDeviceId == "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.
|
||||
|
||||
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 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 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> UpdateLockingStateAsync(
|
||||
string bikeId,
|
||||
LocationDto geolocation,
|
||||
lock_state state,
|
||||
double batteryLevel,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<ReservationCancelReturnResponse> DoReturn(
|
||||
string bikeId,
|
||||
LocationDto geolocation,
|
||||
ISmartDevice smartDevice,
|
||||
Uri operatorUri)
|
||||
=> null;
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, 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>
|
||||
/// 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 = @"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""response"" : ""authorization"",
|
||||
""authcookie"" : 0,
|
||||
""response_state"" : ""Failure: cannot generate authcookie"",
|
||||
""apiserver"" : ""https://tinkwwp.copri-bike.de""
|
||||
}
|
||||
}";
|
||||
}
|
||||
}
|
21
TestFramework/Repository/CopriCallsMemory001.cs
Normal file
21
TestFramework/Repository/CopriCallsMemory001.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using TINK.Repository;
|
||||
|
||||
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)
|
||||
{ }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"shareejson": {
|
||||
"clearing_cache": "0",
|
||||
"privacy_html": "site/privacy.html",
|
||||
"user_id": "javaminister@gmail.com",
|
||||
"impress_html": "site/impress.html",
|
||||
"tariff_info_html": "site/tariff_info_1.html",
|
||||
"lang": "DE",
|
||||
"last_used_operator": {
|
||||
"operator_name": "sharee.bike | TeilRad GmbH",
|
||||
"operator_hours": "Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr",
|
||||
"operator_phone": "+49 761 45370097",
|
||||
"operator_email": "hotline@sharee.bike",
|
||||
"operator_color": "#009699"
|
||||
},
|
||||
"response": "authorization",
|
||||
"agb_checked": "0",
|
||||
"agb_html": "site/agb.html",
|
||||
"response_text": "Herzlich willkommen im Fahrradmietsystem",
|
||||
"bike_info_html": "site/bike_info.html",
|
||||
"debuglevel": "1",
|
||||
"uri_primary": "https://shareeapp-primary.copri.eu",
|
||||
"response_state": "OK, nothing todo",
|
||||
"new_authcoo": "1",
|
||||
"user_tour": [],
|
||||
"authcookie": "6103_112e96b36ba33de245943c5ffaf369cd_oiF2kahH",
|
||||
"copri_version": "4.1.8.21",
|
||||
"apiserver": "https://shareeapp-fr01.copri.eu",
|
||||
"user_group": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"shareejson": {
|
||||
"copri_version": "4.1.8.21",
|
||||
"authcookie": "1",
|
||||
"user_tour": [],
|
||||
"user_group": null,
|
||||
"apiserver": "https://shareeapp-fr01.copri.eu",
|
||||
"debuglevel": "1",
|
||||
"uri_primary": "https://shareeapp-primary.copri.eu",
|
||||
"bike_info_html": "site/bike_info.html",
|
||||
"response_state": "OK, logout",
|
||||
"new_authcoo": "0",
|
||||
"lang": "DE",
|
||||
"last_used_operator": {
|
||||
"operator_hours": "Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr",
|
||||
"operator_name": "sharee.bike | TeilRad GmbH",
|
||||
"operator_email": "hotline@sharee.bike",
|
||||
"operator_phone": "+49 761 45370097",
|
||||
"operator_color": "#009699"
|
||||
},
|
||||
"tariff_info_html": "site/tariff_info_1.html",
|
||||
"impress_html": "site/impress.html",
|
||||
"response_text": "Auf Wiedersehen.",
|
||||
"agb_html": "site/agb.html",
|
||||
"response": "authout",
|
||||
"agb_checked": "0",
|
||||
"privacy_html": "site/privacy.html",
|
||||
"clearing_cache": "0",
|
||||
"user_id": "javaminister@gmail.com"
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
{
|
||||
"shareejson": {
|
||||
"agb_checked": "1",
|
||||
"response": "bikes_available",
|
||||
"agb_html": "site/agb.html",
|
||||
"impress_html": "site/impress.html",
|
||||
"tariff_info_html": "site/tariff_info_1.html",
|
||||
"lang": "DE",
|
||||
"last_used_operator": {
|
||||
"operator_color": "#008dd2",
|
||||
"operator_email": "hotline@lastenraddemo.bayern",
|
||||
"operator_phone": "+49 089 / 111111111",
|
||||
"operator_name": "Lastenrad Bayern",
|
||||
"operator_hours": "Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr",
|
||||
"operator_logo": ""
|
||||
},
|
||||
"user_id": "ohauff@posteo.de",
|
||||
"clearing_cache": "0",
|
||||
"privacy_html": "site/privacy.html",
|
||||
"bikes": {
|
||||
// Entry manually created (copy-paste). Might contain dupe entries (2021-11-12).
|
||||
"FR9999": {
|
||||
"system": "Ilockit",
|
||||
"gps": {
|
||||
"longitude": "7.8255321",
|
||||
"latitude": "47.9767121"
|
||||
},
|
||||
"lock_state": "locked",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-cc141a6f68bb",
|
||||
"state": "available",
|
||||
"tariff_description": {
|
||||
"free_hours": "0.50",
|
||||
"name": "Tester Basic",
|
||||
"eur_per_hour": "3.00",
|
||||
"number": "5494",
|
||||
"1543": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
},
|
||||
"max_eur_per_day": "10.00"
|
||||
},
|
||||
"bike_group": [
|
||||
"FR300103"
|
||||
],
|
||||
"station": "FR103",
|
||||
"description": "Quest Carbon",
|
||||
"Ilockit_ID": "ISHAREIT-9999999",
|
||||
"authed": "1",
|
||||
"bike": "FR9999",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu"
|
||||
},
|
||||
// Entry manually created (copy-paste). Might contain dupe entries (2021-11-12).
|
||||
"FR9998": {
|
||||
"system": "Ilockit",
|
||||
"gps": {
|
||||
"longitude": "7.8255321",
|
||||
"latitude": "47.9767121"
|
||||
},
|
||||
"lock_state": "locked",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-cc141a6f68bb",
|
||||
"state": "available",
|
||||
"tariff_description": {
|
||||
"free_hours": "0.50",
|
||||
"name": "Bacchetta Giro",
|
||||
"eur_per_hour": "3.00",
|
||||
"number": "5494",
|
||||
"1543": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
},
|
||||
"max_eur_per_day": "10.00"
|
||||
},
|
||||
"bike_group": [
|
||||
"FR300103"
|
||||
],
|
||||
"station": "FR103",
|
||||
"description": "Quest Carbon",
|
||||
"Ilockit_ID": "ISHAREIT-9999999",
|
||||
"authed": "1",
|
||||
"bike": "FR9998",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu"
|
||||
},
|
||||
"FR1543": {
|
||||
"system": "Ilockit",
|
||||
"gps": {
|
||||
"longitude": "7.8255321",
|
||||
"latitude": "47.9767121"
|
||||
},
|
||||
"lock_state": "locked",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-cc141a6f68bb",
|
||||
"state": "available",
|
||||
"tariff_description": {
|
||||
"free_hours": "0.50",
|
||||
"name": "Tester Basic",
|
||||
"eur_per_hour": "3.00",
|
||||
"number": "5494",
|
||||
"1543": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
},
|
||||
"max_eur_per_day": "10.00"
|
||||
},
|
||||
"bike_group": [
|
||||
"FR300103"
|
||||
],
|
||||
"station": "FR101",
|
||||
"description": "Contributor-bike Dominik",
|
||||
"Ilockit_ID": "ISHAREIT-2200543",
|
||||
"authed": "1",
|
||||
"bike": "FR1543",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu"
|
||||
},
|
||||
"FR1003": {
|
||||
"bike": "FR1003",
|
||||
"authed": "1",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu",
|
||||
"bike_group": [
|
||||
"FR300101"
|
||||
],
|
||||
"Ilockit_ID": "ISHAREIT-2200545",
|
||||
"station": "FR101",
|
||||
"description": "Stadtrad",
|
||||
"tariff_description": {
|
||||
"max_eur_per_day": "10.00",
|
||||
"number": "5491",
|
||||
"eur_per_hour": "2.00",
|
||||
"1003": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
},
|
||||
"free_hours": "0.50",
|
||||
"name": "Vauban Basic"
|
||||
},
|
||||
"state": "available",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-e38bf9d32234",
|
||||
"system": "Ilockit",
|
||||
"gps": {
|
||||
"longitude": "7.8255772",
|
||||
"latitude": "47.9765188"
|
||||
},
|
||||
"lock_state": "locked"
|
||||
},
|
||||
"FR1540": {
|
||||
"bike_group": [
|
||||
"FR300103"
|
||||
],
|
||||
"Ilockit_ID": "ISHAREIT-2200540",
|
||||
"description": "Contributor-bike Dieter",
|
||||
"station": "FR101",
|
||||
"bike": "FR1540",
|
||||
"authed": "1",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-fc3c002a2add",
|
||||
"system": "Ilockit",
|
||||
"gps": {
|
||||
"longitude": "7.8256267",
|
||||
"latitude": "47.976803"
|
||||
},
|
||||
"lock_state": "locked",
|
||||
"tariff_description": {
|
||||
"1540": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
},
|
||||
"free_hours": "0.50",
|
||||
"name": "Tester Basic",
|
||||
"max_eur_per_day": "10.00",
|
||||
"eur_per_hour": "3.00",
|
||||
"number": "5494"
|
||||
},
|
||||
"state": "available"
|
||||
},
|
||||
"FR1002": {
|
||||
"bike_group": [
|
||||
"FR300101"
|
||||
],
|
||||
"description": "Lasten-Dreirad",
|
||||
"station": "FR101",
|
||||
"Ilockit_ID": "ISHAREIT-2200539",
|
||||
"authed": "1",
|
||||
"bike": "FR1002",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu",
|
||||
"gps": {
|
||||
"latitude": "47.976552",
|
||||
"longitude": "7.8255068"
|
||||
},
|
||||
"system": "Ilockit",
|
||||
"lock_state": "locked",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-f0b4a692e169",
|
||||
"state": "available",
|
||||
"tariff_description": {
|
||||
"max_eur_per_day": "10.00",
|
||||
"1002": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
},
|
||||
"eur_per_hour": "2.00",
|
||||
"number": "5491",
|
||||
"free_hours": "0.50",
|
||||
"name": "Vauban Basic"
|
||||
}
|
||||
},
|
||||
"FR1538": {
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu",
|
||||
"authed": "1",
|
||||
"bike": "FR1538",
|
||||
"station": "FR105",
|
||||
"description": "Contributor-bike Rainer",
|
||||
"Ilockit_ID": "ISHAREIT-2200538",
|
||||
"bike_group": [
|
||||
"FR300103"
|
||||
],
|
||||
"state": "available",
|
||||
"tariff_description": {
|
||||
"max_eur_per_day": "10.00",
|
||||
"eur_per_hour": "3.00",
|
||||
"number": "5494",
|
||||
"1538": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
},
|
||||
"free_hours": "0.50",
|
||||
"name": "Tester Basic"
|
||||
},
|
||||
"gps": {
|
||||
"latitude": "47.9275957",
|
||||
"longitude": "7.973976"
|
||||
},
|
||||
"lock_state": "locked",
|
||||
"system": "Ilockit",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-db0319a2555b"
|
||||
},
|
||||
"FR1001": {
|
||||
"bike_group": [
|
||||
"FR300101"
|
||||
],
|
||||
"station": "FR101",
|
||||
"description": "Lastenrad",
|
||||
"Ilockit_ID": "ISHAREIT-2200536",
|
||||
"authed": "1",
|
||||
"bike": "FR1001",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu",
|
||||
"lock_state": "locked",
|
||||
"gps": {
|
||||
"latitude": "47.9765091",
|
||||
"longitude": "7.8255631"
|
||||
},
|
||||
"system": "Ilockit",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-caa87760e53e",
|
||||
"state": "available",
|
||||
"tariff_description": {
|
||||
"free_hours": "0.50",
|
||||
"name": "Vauban Basic",
|
||||
"eur_per_hour": "2.00",
|
||||
"number": "5491",
|
||||
"max_eur_per_day": "10.00",
|
||||
"1001": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"user_group": [
|
||||
"FR300103",
|
||||
"FR300101"
|
||||
],
|
||||
"apiserver": "https://shareeapp-fr01.copri.eu",
|
||||
"user_tour": [],
|
||||
"authcookie": "6103_112e96b36ba33de245943c5ffaf369cd_oiF2kahH",
|
||||
"copri_version": "4.1.8.21",
|
||||
"response_state": "OK, nothing todo",
|
||||
"new_authcoo": "0",
|
||||
"bike_info_html": "site/bike_info.html",
|
||||
"debuglevel": "1",
|
||||
"uri_primary": "https://shareeapp-primary.copri.eu"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
"shareejson": {
|
||||
"authcookie": "6103_112e96b36ba33de245943c5ffaf369cd_oiF2kahH",
|
||||
"copri_version": "4.1.8.21",
|
||||
"user_tour": [],
|
||||
"user_group": [
|
||||
"FR300103",
|
||||
"FR300101"
|
||||
],
|
||||
"bikes_occupied": {
|
||||
"157056": {
|
||||
"K_seed": "[-20, -104, -112, -49, 3, -74, -43, -115, -53, 34, -48, -29, -64, -90, -26, -74]",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu",
|
||||
"bike": "FR1544",
|
||||
"unit_price": "3.00",
|
||||
"description": "Contributor-Paul",
|
||||
"station": "FR103",
|
||||
"request_time": "2021-11-06 18:57:20.034438+01",
|
||||
"Ilockit_ID": "ISHAREIT-2200544",
|
||||
"total_price": "25.50",
|
||||
"bike_group": [
|
||||
"FR300103"
|
||||
],
|
||||
"K_u": "[43, -16, 72, -5, 23, -117, 43, 57, 124, -106, -115, 97, -93, -30, -34, -7, -21, 119, 109, 92, 0, 0, 0, 0]",
|
||||
"computed_hours": "8.50",
|
||||
"end_time": "2021-11-08 21:14:35",
|
||||
"state": "occupied",
|
||||
"tariff_description": {
|
||||
"eur_per_hour": "3.00",
|
||||
"number": "5494",
|
||||
"max_eur_per_day": "10.00",
|
||||
"name": "Tester Basic",
|
||||
"free_hours": "0.50",
|
||||
"track_info": "Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!",
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB)."
|
||||
},
|
||||
"lock_state": "locked",
|
||||
"system": "Ilockit",
|
||||
"gps": {
|
||||
"latitude": "47.9994661873206",
|
||||
"longitude": "7.7904340904206"
|
||||
},
|
||||
"real_hours": "50.2833333333333",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-dc969f648732",
|
||||
"start_time": "2021-11-06 18:57:25.445447+01"
|
||||
},
|
||||
"157072": {
|
||||
"bike": "FR1004",
|
||||
"K_seed": "[-31, -81, -41, 95, 112, -113, -78, -22, 84, -112, -73, 31, -125, -49, 125, 10]",
|
||||
"uri_operator": "https://shareeapp-fr01.copri.eu",
|
||||
"bike_group": [
|
||||
"FR300103"
|
||||
],
|
||||
"total_price": "0.00",
|
||||
"description": "Contributor-Recumbent",
|
||||
"station": "FR103",
|
||||
"request_time": "2021-11-08 21:10:24.829395+01",
|
||||
"Ilockit_ID": "ISHAREIT-2302373",
|
||||
"unit_price": "3.00",
|
||||
"end_time": "2021-11-08 21:10:00+01",
|
||||
"state": "requested",
|
||||
"tariff_description": {
|
||||
"operator_agb": "Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-fr01.copri.eu/site/agb.html'>AGB</a> zugestimmt (als Demo sharee AGB).",
|
||||
"free_hours": "0.50",
|
||||
"name": "Tester Basic",
|
||||
"max_eur_per_day": "10.00",
|
||||
"eur_per_hour": "3.00",
|
||||
"number": "5494"
|
||||
},
|
||||
"computed_hours": "0",
|
||||
"K_u": "[126, -125, 125, 83, 104, -121, -80, 40, 77, -35, 81, 27, 89, -124, -37, 57, 118, -113, 71, -37, 0, 0, 0, 0]",
|
||||
"start_time": "2021-11-08 21:10:24.829395+01",
|
||||
"gps": {
|
||||
"latitude": "47.9980777",
|
||||
"longitude": "7.7848769"
|
||||
},
|
||||
"lock_state": "locked",
|
||||
"system": "Ilockit",
|
||||
"real_hours": "0",
|
||||
"Ilockit_GUID": "00000000-0000-0000-0000-fe3962c08bcc"
|
||||
}
|
||||
},
|
||||
"apiserver": "https://shareeapp-fr01.copri.eu",
|
||||
"uri_primary": "https://shareeapp-primary.copri.eu",
|
||||
"debuglevel": "1",
|
||||
"bike_info_html": "site/bike_info.html",
|
||||
"new_authcoo": "0",
|
||||
"response_state": "OK, nothing todo",
|
||||
"last_used_operator": {
|
||||
"operator_color": "#008dd2",
|
||||
"operator_phone": "+49 089 / 111111111",
|
||||
"operator_email": "hotline@lastenraddemo.bayern",
|
||||
"operator_hours": "Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr",
|
||||
"operator_name": "Lastenrad Bayern",
|
||||
"operator_logo": ""
|
||||
},
|
||||
"lang": "DE",
|
||||
"impress_html": "site/impress.html",
|
||||
"tariff_info_html": "site/tariff_info_1.html",
|
||||
"agb_html": "site/agb.html",
|
||||
"response": "user_bikes_occupied",
|
||||
"agb_checked": "1",
|
||||
"privacy_html": "site/privacy.html",
|
||||
"clearing_cache": "0",
|
||||
"user_id": "ohauff@posteo.de"
|
||||
}
|
||||
}
|
1042
TestFramework/Repository/CopriCallsMemory001/StationsAvailable.json
Normal file
1042
TestFramework/Repository/CopriCallsMemory001/StationsAvailable.json
Normal file
File diff suppressed because it is too large
Load diff
88
TestFramework/Repository/ExceptionServer.cs
Normal file
88
TestFramework/Repository/ExceptionServer.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Repository;
|
||||
using TINK.Repository.Request;
|
||||
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> 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 string SessionCookie => 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<AuthorizationoutResponse> DoAuthoutAsync()
|
||||
{
|
||||
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<ReservationBookingResponse> CalculateAuthKeysAsync(string bikeId, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ReservationBookingResponse> UpdateLockingStateAsync(string bikeId, LocationDto geolocation, lock_state state, double batteryPercentage, Uri operatorUri)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public Task<ReservationBookingResponse> DoBookAsync(string bikeId, Guid guid, double batteryPercentage, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ReservationCancelReturnResponse> DoReturn(string bikeId, LocationDto location, ISmartDevice smartDevice, Uri operatorUri)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<SubmitFeedbackResponse> DoSubmitFeedback(string bikeId, 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();
|
||||
|
||||
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<StationsAvailableResponse> GetStationsAsync()
|
||||
{
|
||||
throw ExceptionFactory($"Simulated error thrown at {nameof(GetStationsAsync)}.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue