Tests fixed.

This commit is contained in:
Oliver Hauff 2021-11-08 23:11:56 +01:00
parent 4df8aa98aa
commit 8aa3089f32
15 changed files with 779 additions and 82 deletions

View file

@ -36,36 +36,36 @@ namespace TINK.Model.Connector
/// If communication fails an exception is thrown.
/// </summary>
public async Task<IAccount> DoLogin(
string p_strMail,
string p_strPassword,
string p_strDeviceId)
string mail,
string password,
string deviceId)
{
if (string.IsNullOrEmpty(p_strMail))
if (string.IsNullOrEmpty(mail))
{
throw new ArgumentNullException("Can not loging user. Mail address must not be null or empty.");
}
if (string.IsNullOrEmpty(p_strPassword))
if (string.IsNullOrEmpty(password))
{
throw new ArgumentNullException("Can not loging user. Password must not be null or empty.");
}
if (string.IsNullOrEmpty(p_strDeviceId))
if (string.IsNullOrEmpty(deviceId))
{
throw new ArgumentNullException("Can not loging user. Device not be null or empty.");
}
AuthorizationResponse l_oResponse;
AuthorizationResponse response;
try
{
l_oResponse = (await CopriServer.DoAuthorizationAsync(p_strMail, p_strPassword, p_strDeviceId)).GetIsResponseOk(p_strMail);
response = (await CopriServer.DoAuthorizationAsync(mail, password, deviceId)).GetIsResponseOk(mail);
}
catch (System.Exception)
{
throw;
}
var l_oAccount = l_oResponse.GetAccount(MerchantId, p_strMail, p_strPassword);
var l_oAccount = response.GetAccount(MerchantId, mail, password);
// Log in state changes. Notify parent object to update.
LoginStateChanged?.Invoke(this, new LoginStateChangedEventArgs(l_oAccount.SessionCookie, l_oAccount.Mail));
@ -83,9 +83,9 @@ namespace TINK.Model.Connector
/// <summary>
/// Request to reserve a bike.
/// </summary>
/// <param name="p_oBike">Bike to book.</param>
/// <param name="bike">Bike to book.</param>
public async Task DoReserve(
Bikes.Bike.BC.IBikeInfoMutable p_oBike)
Bikes.Bike.BC.IBikeInfoMutable bike)
{
Log.ForContext<Command>().Error("Unexpected booking request detected. No user logged in.");
await Task.CompletedTask;

View file

@ -5,12 +5,13 @@ namespace TINK.Model.Connector
public static class FilteredConnectorFactory
{
/// <summary> Creates a filter object. </summary>
/// <param name="group"></param>
/// <param name="group">Filter to apply on stations and bikes.</param>
/// <param name="connector">Connector to connect to COPRI.</param>
public static IFilteredConnector Create(IEnumerable<string> group, IConnector connector)
{
return group != null
? (IFilteredConnector) new FilteredConnector(group, connector)
: new NullFilterConnector(connector);
: new NullFilterConnector(connector); // Do not apply filtering.
}
}
}

View file

@ -91,7 +91,7 @@ namespace TINK.Model.Connector
{
if (loginResponse == null)
{
throw new ArgumentNullException("p_oLoginResponse");
throw new ArgumentNullException(nameof(loginResponse));
}
return new Account(
@ -165,13 +165,13 @@ namespace TINK.Model.Connector
}
/// <summary> Gets bikes available from copri server response.</summary>
/// <param name="p_oBikesAvailableResponse">Response to create collection from.</param>
/// <param name="bikesAvailableResponse">Response to create collection from.</param>
/// <returns>New collection of available bikes.</returns>
public static BikeCollection GetBikesAvailable(
this BikesAvailableResponse p_oBikesAvailableResponse)
this BikesAvailableResponse bikesAvailableResponse)
{
return GetBikesAll(
p_oBikesAvailableResponse,
bikesAvailableResponse,
new BikesReservedOccupiedResponse(), // There are no occupied bikes.
string.Empty,
() => DateTime.Now);
@ -198,8 +198,8 @@ namespace TINK.Model.Connector
public static BikeCollection GetBikesAll(
BikesAvailableResponse bikesAvailableResponse,
BikesReservedOccupiedResponse bikesOccupiedResponse,
string p_strMail,
Func<DateTime> p_oDateTimeProvider)
string mail,
Func<DateTime> dateTimeProvider)
{
var bikesDictionary = new Dictionary<string, BikeInfo>();
var duplicates = new Dictionary<string, BikeInfo>();
@ -242,8 +242,8 @@ namespace TINK.Model.Connector
{
BikeInfo bikeInfo = BikeInfoFactory.Create(
bikeInfoResponse,
p_strMail,
p_oDateTimeProvider);
mail,
dateTimeProvider);
if (bikeInfo == null)
{