sharee.bike-App/SharedBusinessLogic.Tests.Framework/Repository/ExceptionServer.cs
2024-04-09 12:53:23 +02:00

113 lines
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ShareeBike.Model.Bikes.BikeInfoNS.BluetoothLock;
using ShareeBike.Model.Connector;
using ShareeBike.Model.Device;
using ShareeBike.Repository;
using ShareeBike.Repository.Request;
using ShareeBike.Repository.Response;
using ShareeBike.Repository.Response.Stations;
namespace SharedBusinessLogic.Tests.Framework.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 when querying 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<BookingActionResponse> DoCancelReservationAsync(string p_iBikeId, 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<ReservationBookingResponse> UpdateLockingStateAsync(
string bikeId,
lock_state state,
Uri operatorUri,
LocationDto geolocation,
double batteryPercentage,
IVersionInfo versionInfo)
=> throw new NotImplementedException();
public Task<ReservationBookingResponse> DoBookAsync(Uri operatorUri, string bikeId, Guid guid, double batteryPercentage, LockingAction? nextAction = null)
=> 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<DoReturnResponse> DoReturn(string bikeId, LocationDto location, Uri operatorUri)
=> throw new NotImplementedException();
public Task<DoReturnResponse> ReturnAndStartClosingAsync(
string bikeId,
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> 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, string stationId = null, string bikeId = null)
=> 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)}.");
}
}
}