mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 12:36:28 +02:00
Version 3.0.376
This commit is contained in:
parent
ca080c87c0
commit
f963c0a219
158 changed files with 3228 additions and 1279 deletions
|
@ -108,13 +108,17 @@ namespace TestFramework.Repository
|
|||
/// Gets list of bikes from memory.
|
||||
/// </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null)
|
||||
public async Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
=> await Task.Run(() => GetBikesAvailable(
|
||||
BikesAvailableResponse,
|
||||
null /* merchant id*/,
|
||||
SessionCookie,
|
||||
operatorUri));
|
||||
operatorUri,
|
||||
stationId,
|
||||
bikeId));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of bikes reserved/ booked by active user from Copri.
|
||||
|
@ -213,8 +217,14 @@ namespace TestFramework.Repository
|
|||
string BikesAvailableResponse,
|
||||
string merchantId,
|
||||
string sessionCookie = null,
|
||||
Uri operatorUri = null) =>
|
||||
CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BikesAvailableResponse);
|
||||
Uri operatorUri = null,
|
||||
string stationId = null,
|
||||
string bikeid = null)
|
||||
{
|
||||
return CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>(BikesAvailableResponse)
|
||||
.FilterByStation(stationId)
|
||||
.FilterByBike(bikeid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets stations response.
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Threading.Tasks;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BluetoothLock;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Device;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.MultilingualResources;
|
||||
using TINK.Repository;
|
||||
|
@ -46,9 +45,11 @@ namespace TestFramework.Repository
|
|||
}
|
||||
|
||||
/// <summary> Adds a bikes response to cache.</summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="bikes">Bikes to add.</param>
|
||||
public void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null)
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which was used for filtering bikes. Null if no filtering was applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which was used for filtering bikes. Null if no filtering was applied.</param>
|
||||
public void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -127,9 +128,11 @@ namespace TestFramework.Repository
|
|||
|
||||
/// <summary> Gets a list of bikes from Copri. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null)
|
||||
=> server.GetBikesAvailableAsync(operatorUri);
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
=> server.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
|
||||
public Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
|
|
|
@ -38,9 +38,11 @@ namespace TestFramework.Repository
|
|||
}
|
||||
|
||||
/// <summary> Adds a bikes response to cache.</summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="bikes">Bikes to add.</param>
|
||||
public void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null)
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which was used for filtering bikes. Null if no filtering was applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which was used for filtering bikes. Null if no filtering was applied.</param>
|
||||
public void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -114,9 +116,11 @@ namespace TestFramework.Repository
|
|||
|
||||
/// <summary> Gets a list of bikes from Copri. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null)
|
||||
=> server.GetBikesAvailableAsync(operatorUri);
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
=> server.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
|
||||
public Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
|
|
|
@ -37,9 +37,11 @@ namespace TestFramework.Repository
|
|||
}
|
||||
|
||||
/// <summary> Adds a bikes response to cache.</summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="bikes">Bikes to add.</param>
|
||||
public void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null)
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which was used for filtering bikes. Null if no filtering was applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which was used for filtering bikes. Null if no filtering was applied.</param>
|
||||
public void AddToCache(BikesAvailableResponse bikes, Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -113,9 +115,11 @@ namespace TestFramework.Repository
|
|||
|
||||
/// <summary> Gets a list of bikes from Copri. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null)
|
||||
=> server.GetBikesAvailableAsync(operatorUri);
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
=> server.GetBikesAvailableAsync(operatorUri, stationId, bikeId);
|
||||
|
||||
public Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
{
|
||||
|
|
75
TestFramework/Repository/CopriCallsHelper.cs
Normal file
75
TestFramework/Repository/CopriCallsHelper.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using TINK.Repository.Response;
|
||||
using TINK.Repository;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace TestFramework.Repository
|
||||
{
|
||||
public static class CopriCallsHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Filters bikes available response by station.
|
||||
/// </summary>
|
||||
/// <param name="bikes"></param>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
public static BikesAvailableResponse FilterByStation(this BikesAvailableResponse bikes, string stationId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(stationId))
|
||||
{
|
||||
// If filter is off there is nothing to filter.
|
||||
return bikes;
|
||||
}
|
||||
|
||||
var bikesText = JsonConvert.SerializeObject(bikes);
|
||||
var response = CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>($"{{ \"{nameof(VersionindependentResponse.shareejson)}\" : {bikesText} }}");
|
||||
|
||||
var bikeIdList = response.bikes.Select(x => x.Value.bike).ToList();
|
||||
foreach (var bike in bikeIdList)
|
||||
{
|
||||
response.bikes.Remove(bike);
|
||||
};
|
||||
|
||||
var allBikes = bikes.bikes.Values.Where(x => x.station == stationId).ToList();
|
||||
foreach (var bike in allBikes)
|
||||
{
|
||||
response.bikes.Add(bike.bike, bike);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filters bikes available response by station.
|
||||
/// </summary>
|
||||
/// <param name="bikes"></param>
|
||||
/// <param name="stationId"></param>
|
||||
/// <returns></returns>
|
||||
public static BikesAvailableResponse FilterByBike(this BikesAvailableResponse bikes, string bikeId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bikeId))
|
||||
{
|
||||
// If filter is off there is nothing to filter.
|
||||
return bikes;
|
||||
}
|
||||
|
||||
var bikesText = JsonConvert.SerializeObject(bikes);
|
||||
var response = CopriCallsStatic.DeserializeResponse<BikesAvailableResponse>($"{{ \"{nameof(VersionindependentResponse.shareejson)}\" : {bikesText} }}");
|
||||
|
||||
var bikeIdList = response.bikes.Select(x => x.Value.bike).ToList();
|
||||
foreach (var bike in bikeIdList)
|
||||
{
|
||||
response.bikes.Remove(bike);
|
||||
};
|
||||
|
||||
var allBikes = bikes.bikes.Values.Where(x => Regex.IsMatch(x.bike, bikeId)).ToList();
|
||||
foreach (var bike in allBikes)
|
||||
{
|
||||
response.bikes.Add(bike.bike, bike);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
1791
TestFramework/Repository/CopriCallsMemory.cs
Normal file
1791
TestFramework/Repository/CopriCallsMemory.cs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -93,8 +93,10 @@ namespace TestFramework.Repository
|
|||
|
||||
/// <summary> Gets a list of bikes from Copri. </summary>
|
||||
/// <param name="operatorUri">Uri of the operator host to get bikes from or null if bikes have to be gotten form primary host.</param>
|
||||
/// <param name="stationId"> Id of station which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <param name="bikeId"> Id of bike which is used for filtering bikes. Null if no filtering should be applied.</param>
|
||||
/// <returns>Response holding list of bikes.</returns>
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null)
|
||||
public Task<BikesAvailableResponse> GetBikesAvailableAsync(Uri operatorUri = null, string stationId = null, string bikeId = null)
|
||||
=> throw ExceptionFactory($"Simulated error thrown at {nameof(GetBikesAvailableAsync)}.");
|
||||
|
||||
public Task<BikesReservedOccupiedResponse> GetBikesOccupiedAsync()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue