Version 3.0.270

This commit is contained in:
Oliver Hauff 2022-01-04 18:59:16 +01:00
parent 67999ef4ae
commit e0c75d5b37
81 changed files with 812 additions and 474 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.TeilRad.LastenradBayern" android:versionName="3.0.267" android:versionCode="267"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.TeilRad.LastenradBayern" android:versionName="3.0.270" android:versionCode="270">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" /> <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" />
<!-- Google Maps related permissions --> <!-- Google Maps related permissions -->
<!-- Permission to receive remote notifications from Google Play Services --> <!-- Permission to receive remote notifications from Google Play Services -->

View file

@ -49,8 +49,8 @@
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>LastenradBayern</string> <string>LastenradBayern</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>267</string> <string>270</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>3.0.267</string> <string>3.0.270</string>
</dict> </dict>
</plist> </plist>

View file

@ -141,12 +141,15 @@ namespace TINK
var appInfoService = DependencyService.Get<IAppInfo>(); var appInfoService = DependencyService.Get<IAppInfo>();
const string MERCHANTID = "baei987w";
// Create new app instnace. // Create new app instnace.
Log.Debug("Constructing main model..."); Log.Debug("Constructing main model...");
m_oModelRoot = new TinkApp( m_oModelRoot = new TinkApp(
settings, settings,
store, // Manages user account store, // Manages user account
(isConnected, activeUri, sessionCookie, mail, expiresAfter) => ConnectorFactory.Create(isConnected, activeUri, new Repository.AppContextInfo("baei987w", "LastenradBayern", appInfoService.Version), sessionCookie, mail, expiresAfter), (isConnected, activeUri, sessionCookie, mail, expiresAfter) => ConnectorFactory.Create(isConnected, activeUri, new Repository.AppContextInfo(MERCHANTID, "LastenradBayern", appInfoService.Version), sessionCookie, mail, expiresAfter),
MERCHANTID,
GeolocationServicesContainer, GeolocationServicesContainer,
null, /* locksService */ null, /* locksService */
DependencyService.Get<ISmartDevice>(), DependencyService.Get<ISmartDevice>(),

View file

@ -26,6 +26,7 @@ namespace TINK.View.CopriWebView
}; };
RegisterView.BindingContext = new RegisterPageViewModel( RegisterView.BindingContext = new RegisterPageViewModel(
Model.TinkApp.MerchantId,
App.ModelRoot.NextActiveUri.Host); App.ModelRoot.NextActiveUri.Host);
} }

View file

@ -47,6 +47,7 @@ namespace TINK.View.FindBike
(isConnected) => model.GetConnector(isConnected), (isConnected) => model.GetConnector(isConnected),
App.GeolocationServicesContainer.Active, App.GeolocationServicesContainer.Active,
model.LocksServices.Active, model.LocksServices.Active,
model.Stations,
model.Polling, model.Polling,
(d, obj) => synchronizationContext.Post(d, obj), (d, obj) => synchronizationContext.Post(d, obj),
model.SmartDevice, model.SmartDevice,

View file

@ -64,6 +64,7 @@ namespace TINK.View.MyBikes
(isConnected) => model.GetConnector(isConnected), (isConnected) => model.GetConnector(isConnected),
App.GeolocationServicesContainer.Active, App.GeolocationServicesContainer.Active,
model.LocksServices.Active, model.LocksServices.Active,
model.Stations,
model.Polling, model.Polling,
(d, obj) => synchronizationContext.Post(d, obj), (d, obj) => synchronizationContext.Post(d, obj),
model.SmartDevice, model.SmartDevice,

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.TeilRad.Meinkonrad" android:versionName="3.0.267" android:versionCode="267"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.TeilRad.Meinkonrad" android:versionName="3.0.270" android:versionCode="270">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" /> <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" />
<!-- Google Maps related permissions --> <!-- Google Maps related permissions -->
<!-- Permission to receive remote notifications from Google Play Services --> <!-- Permission to receive remote notifications from Google Play Services -->

View file

@ -49,8 +49,8 @@
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>Mein konrad</string> <string>Mein konrad</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>267</string> <string>270</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>3.0.267</string> <string>3.0.270</string>
</dict> </dict>
</plist> </plist>

View file

@ -140,12 +140,15 @@ namespace TINK
var appInfoService = DependencyService.Get<IAppInfo>(); var appInfoService = DependencyService.Get<IAppInfo>();
const string MERCHANTID = "mkef9BuN";
// Create new app instnace. // Create new app instnace.
Log.Debug("Constructing main model..."); Log.Debug("Constructing main model...");
m_oModelRoot = new TinkApp( m_oModelRoot = new TinkApp(
settings, settings,
store, // Manages user account store, // Manages user account
(isConnected, activeUri, sessionCookie, mail, expiresAfter) => ConnectorFactory.Create(isConnected, activeUri, new Repository.AppContextInfo("mkef9BuN", "Meinkonrad", appInfoService.Version), sessionCookie, mail, expiresAfter), (isConnected, activeUri, sessionCookie, mail, expiresAfter) => ConnectorFactory.Create(isConnected, activeUri, new Repository.AppContextInfo(MERCHANTID, "Meinkonrad", appInfoService.Version), sessionCookie, mail, expiresAfter),
MERCHANTID,
GeolocationServicesContainer, GeolocationServicesContainer,
null, /* locksService */ null, /* locksService */
DependencyService.Get<ISmartDevice>(), DependencyService.Get<ISmartDevice>(),

View file

@ -26,6 +26,7 @@ namespace TINK.View.CopriWebView
}; };
RegisterView.BindingContext = new RegisterPageViewModel( RegisterView.BindingContext = new RegisterPageViewModel(
Model.TinkApp.MerchantId,
App.ModelRoot.NextActiveUri.Host); App.ModelRoot.NextActiveUri.Host);
} }

View file

@ -47,6 +47,7 @@ namespace TINK.View.FindBike
(isConnected) => model.GetConnector(isConnected), (isConnected) => model.GetConnector(isConnected),
App.GeolocationServicesContainer.Active, App.GeolocationServicesContainer.Active,
model.LocksServices.Active, model.LocksServices.Active,
model.Stations,
model.Polling, model.Polling,
(d, obj) => synchronizationContext.Post(d, obj), (d, obj) => synchronizationContext.Post(d, obj),
model.SmartDevice, model.SmartDevice,

View file

@ -64,6 +64,7 @@ namespace TINK.View.MyBikes
(isConnected) => model.GetConnector(isConnected), (isConnected) => model.GetConnector(isConnected),
App.GeolocationServicesContainer.Active, App.GeolocationServicesContainer.Active,
model.LocksServices.Active, model.LocksServices.Active,
model.Stations,
model.Polling, model.Polling,
(d, obj) => synchronizationContext.Post(d, obj), (d, obj) => synchronizationContext.Post(d, obj),
model.SmartDevice, model.SmartDevice,

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.hauffware.sharee" android:versionName="3.0.267" android:versionCode="267"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" package="com.hauffware.sharee" android:versionName="3.0.270" android:versionCode="270">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" /> <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="30" />
<!-- Google Maps related permissions --> <!-- Google Maps related permissions -->
<!-- Permission to receive remote notifications from Google Play Services --> <!-- Permission to receive remote notifications from Google Play Services -->

View file

@ -49,8 +49,8 @@
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>sharee.bike</string> <string>sharee.bike</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>267</string> <string>270</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>3.0.267</string> <string>3.0.270</string>
</dict> </dict>
</plist> </plist>

View file

@ -140,12 +140,15 @@ namespace TINK
var appInfoService = DependencyService.Get<IAppInfo>(); var appInfoService = DependencyService.Get<IAppInfo>();
const string MERCHANTID = "oiF2kahH";
// Create new app instnace. // Create new app instnace.
Log.Debug("Constructing main model..."); Log.Debug("Constructing main model...");
m_oModelRoot = new TinkApp( m_oModelRoot = new TinkApp(
settings, settings,
store, // Manages user account store, // Manages user account
(isConnected, activeUri, sessionCookie, mail, expiresAfter) => ConnectorFactory.Create(isConnected, activeUri, new Repository.AppContextInfo("oiF2kahH", "sharee.bike", appInfoService.Version), sessionCookie, mail, expiresAfter), (isConnected, activeUri, sessionCookie, mail, expiresAfter) => ConnectorFactory.Create(isConnected, activeUri, new Repository.AppContextInfo(MERCHANTID, "sharee.bike", appInfoService.Version), sessionCookie, mail, expiresAfter),
MERCHANTID,
GeolocationServicesContainer, GeolocationServicesContainer,
null, /* locksService */ null, /* locksService */
DependencyService.Get<ISmartDevice>(), DependencyService.Get<ISmartDevice>(),

View file

@ -26,6 +26,7 @@ namespace TINK.View.CopriWebView
}; };
RegisterView.BindingContext = new RegisterPageViewModel( RegisterView.BindingContext = new RegisterPageViewModel(
Model.TinkApp.MerchantId,
App.ModelRoot.NextActiveUri.Host); App.ModelRoot.NextActiveUri.Host);
} }

View file

@ -47,6 +47,7 @@ namespace TINK.View.FindBike
(isConnected) => model.GetConnector(isConnected), (isConnected) => model.GetConnector(isConnected),
App.GeolocationServicesContainer.Active, App.GeolocationServicesContainer.Active,
model.LocksServices.Active, model.LocksServices.Active,
model.Stations,
model.Polling, model.Polling,
(d, obj) => synchronizationContext.Post(d, obj), (d, obj) => synchronizationContext.Post(d, obj),
model.SmartDevice, model.SmartDevice,

View file

@ -64,6 +64,7 @@ namespace TINK.View.MyBikes
(isConnected) => model.GetConnector(isConnected), (isConnected) => model.GetConnector(isConnected),
App.GeolocationServicesContainer.Active, App.GeolocationServicesContainer.Active,
model.LocksServices.Active, model.LocksServices.Active,
model.Stations,
model.Polling, model.Polling,
(d, obj) => synchronizationContext.Post(d, obj), (d, obj) => synchronizationContext.Post(d, obj),
model.SmartDevice, model.SmartDevice,

View file

@ -27,7 +27,7 @@ namespace TINK.Model.Bike.BC
WheelType? wheelType = null, WheelType? wheelType = null,
TypeOfBike? typeOfBike = null, TypeOfBike? typeOfBike = null,
string description = null, string description = null,
string currentStationId = null, string stationId = null,
Uri operatorUri = null, Uri operatorUri = null,
TariffDescription tariffDescription = null) TariffDescription tariffDescription = null)
{ {
@ -37,7 +37,7 @@ namespace TINK.Model.Bike.BC
IsDemo = isDemo ?? DEFAULTVALUEISDEMO; IsDemo = isDemo ?? DEFAULTVALUEISDEMO;
Group = group ?? new List<string>(); Group = group ?? new List<string>();
CurrentStation = currentStationId; StationId = stationId;
OperatorUri = operatorUri; OperatorUri = operatorUri;
TariffDescription = tariffDescription; TariffDescription = tariffDescription;
} }
@ -50,7 +50,7 @@ namespace TINK.Model.Bike.BC
bikeInfo.WheelType, bikeInfo.WheelType,
bikeInfo.TypeOfBike, bikeInfo.TypeOfBike,
bikeInfo.Description, bikeInfo.Description,
bikeInfo.CurrentStation, bikeInfo.StationId,
bikeInfo.OperatorUri, bikeInfo.OperatorUri,
bikeInfo.TariffDescription) { } bikeInfo.TariffDescription) { }
@ -58,13 +58,13 @@ namespace TINK.Model.Bike.BC
/// Constructs a bike info object for a available bike. /// Constructs a bike info object for a available bike.
/// </summary> /// </summary>
/// <param name="id">Unique id of bike.</param> /// <param name="id">Unique id of bike.</param>
/// <param name="currentStationId">Id of station where bike is located.</param> /// <param name="stationId">Id of station where bike is located.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param> /// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <param name="tariffDescription">Hold tariff description of bike.</param> /// <param name="tariffDescription">Hold tariff description of bike.</param>
/// <param name="wheelType"></param> /// <param name="wheelType"></param>
public BikeInfo( public BikeInfo(
string id, string id,
string currentStationId, string stationId,
Uri operatorUri = null, Uri operatorUri = null,
TariffDescription tariffDescription = null, TariffDescription tariffDescription = null,
bool? isDemo = DEFAULTVALUEISDEMO, bool? isDemo = DEFAULTVALUEISDEMO,
@ -79,7 +79,7 @@ namespace TINK.Model.Bike.BC
wheelType, wheelType,
typeOfBike, typeOfBike,
description, description,
currentStationId, stationId,
operatorUri, operatorUri,
tariffDescription) tariffDescription)
{ {
@ -179,7 +179,7 @@ namespace TINK.Model.Bike.BC
/// <summary> /// <summary>
/// Station a which bike is located, null otherwise. /// Station a which bike is located, null otherwise.
/// </summary> /// </summary>
public string CurrentStation { get; } public string StationId { get; }
/// <summary> Holds description about the tarif. </summary> /// <summary> Holds description about the tarif. </summary>
public TariffDescription TariffDescription { get; } public TariffDescription TariffDescription { get; }
@ -210,7 +210,7 @@ namespace TINK.Model.Bike.BC
/// </summary> /// </summary>
public new string ToString() public new string ToString()
{ {
return $"Id={Bike.Id}{(Bike.WheelType != null ? $", wheel(s)={Bike.WheelType}" : string.Empty)}{(Bike.TypeOfBike != null ? $"type={Bike.TypeOfBike}" : "")}, state={State}, location={(!string.IsNullOrEmpty(CurrentStation)? $"Station {CurrentStation}" : "On the road")}, is demo={IsDemo}."; return $"Id={Bike.Id}{(Bike.WheelType != null ? $", wheel(s)={Bike.WheelType}" : string.Empty)}{(Bike.TypeOfBike != null ? $"type={Bike.TypeOfBike}" : "")}, state={State}, location={(!string.IsNullOrEmpty(StationId)? $"Station {StationId}" : "On the road")}, is demo={IsDemo}.";
} }
} }
} }

View file

@ -24,7 +24,7 @@ namespace TINK.Model.Bike.BC
/// <param name="isDemo">True if device is demo device, false otherwise.</param> /// <param name="isDemo">True if device is demo device, false otherwise.</param>
/// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param> /// <param name="dateTimeProvider">Provider for current date time to calculate remainig time on demand for state of type reserved.</param>
/// <param name="wheelType"></param> /// <param name="wheelType"></param>
/// <param name="currentStationId">Name of station where bike is located, null if bike is on the road.</param> /// <param name="stationId">Name of station where bike is located, null if bike is on the road.</param>
/// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param> /// <param name="operatorUri">Holds the uri of the operator or null, in case of single operator setup.</param>
/// <param name="tariffDescription">Hold tariff description of bike.</param> /// <param name="tariffDescription">Hold tariff description of bike.</param>
/// <param name="stateInfo">Bike state info.</param> /// <param name="stateInfo">Bike state info.</param>
@ -35,7 +35,8 @@ namespace TINK.Model.Bike.BC
WheelType? wheelType = null, WheelType? wheelType = null,
TypeOfBike? typeOfBike = null, TypeOfBike? typeOfBike = null,
string description = null, string description = null,
string currentStationId = null, string stationId = null,
string stationName = null,
Uri operatorUri = null, Uri operatorUri = null,
TariffDescription tariffDescription = null, TariffDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null, Func<DateTime> dateTimeProvider = null,
@ -46,32 +47,36 @@ namespace TINK.Model.Bike.BC
m_oBike = new Bike(id, wheelType, typeOfBike, description); m_oBike = new Bike(id, wheelType, typeOfBike, description);
m_oStateInfo = new StateInfoMutable(dateTimeProvider, stateInfo); m_oStateInfo = new StateInfoMutable(dateTimeProvider, stateInfo);
m_oStateInfo.PropertyChanged += (sender, eventargs) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(eventargs.PropertyName)); m_oStateInfo.PropertyChanged += (sender, eventargs) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(eventargs.PropertyName));
CurrentStation = currentStationId; StationId = stationId;
StationName = stationName;
OperatorUri = operatorUri; OperatorUri = operatorUri;
TariffDescription = tariffDescription; TariffDescription = tariffDescription;
} }
/// <summary> Constructs a bike object from source. </summary> /// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(IBikeInfo p_oBike) : this( public BikeInfoMutable(IBikeInfo bike, string stationName) : this(
p_oBike.Id, bike.Id,
p_oBike.IsDemo, bike.IsDemo,
p_oBike.Group, bike.Group,
p_oBike.WheelType, bike.WheelType,
p_oBike.TypeOfBike, bike.TypeOfBike,
p_oBike.Description, bike.Description,
p_oBike.CurrentStation, bike.StationId,
p_oBike.OperatorUri, stationName,
p_oBike.TariffDescription, bike.OperatorUri,
bike.TariffDescription,
null, null,
p_oBike.State) bike.State)
{ {
} }
/// <summary> /// <summary> Id of station a which bike is located, null otherwise.</summary>
/// Station a which bike is located, null otherwise.
/// </summary>
[DataMember] [DataMember]
public string CurrentStation { get; } public string StationId { get; }
/// <summary> Name of station a which bike is located, null otherwise. </summary>
[DataMember]
public string StationName { get; }
/// <summary> Holds description about the tarif. </summary> /// <summary> Holds description about the tarif. </summary>
[DataMember] [DataMember]
@ -118,7 +123,7 @@ namespace TINK.Model.Bike.BC
/// <returns></returns> /// <returns></returns>
public new string ToString() public new string ToString()
{ {
return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(!string.IsNullOrEmpty(CurrentStation) ? $"Station {CurrentStation}" : "On the road")}."; return $"Id={Id}{(WheelType != null ? $", wheel(s)={WheelType}" : string.Empty)}{(TypeOfBike != null ? $", type={TypeOfBike}" : "")}, demo={IsDemo}, state={State.ToString()}, location={(!string.IsNullOrEmpty(StationId) ? $"Station {StationId}" : "On the road")}.";
} }
} }
} }

View file

@ -37,7 +37,7 @@ namespace TINK.Model.Bike.BC
/// <summary> /// <summary>
/// Station a which bike is located, null otherwise. /// Station a which bike is located, null otherwise.
/// </summary> /// </summary>
string CurrentStation { get; } string StationId { get; }
/// <summary> /// <summary>
/// Uri of the operator or null, in case of single operator setup. /// Uri of the operator or null, in case of single operator setup.

View file

@ -35,7 +35,7 @@ namespace TINK.Model.Bikes.Bike.BC
/// <summary> /// <summary>
/// Station a which bike is located, null otherwise. /// Station a which bike is located, null otherwise.
/// </summary> /// </summary>
string CurrentStation { get; } string StationId { get; }
/// <summary> /// <summary>
/// Holds the rent state of the bike. /// Holds the rent state of the bike.

View file

@ -1,5 +1,4 @@
using System; using System;
using TINK.Model.Bikes.Bike;
using TINK.Model.Bikes.Bike.BluetoothLock; using TINK.Model.Bikes.Bike.BluetoothLock;
namespace TINK.Model.Bike.BluetoothLock namespace TINK.Model.Bike.BluetoothLock
@ -7,14 +6,15 @@ namespace TINK.Model.Bike.BluetoothLock
public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable
{ {
/// <summary> Constructs a bike object from source. </summary> /// <summary> Constructs a bike object from source. </summary>
public BikeInfoMutable(BikeInfo bike) : base( public BikeInfoMutable(BikeInfo bike, string stationName) : base(
bike.Id, bike.Id,
bike.IsDemo, bike.IsDemo,
bike.Group, bike.Group,
bike.WheelType, bike.WheelType,
bike.TypeOfBike, bike.TypeOfBike,
bike.Description, bike.Description,
bike.CurrentStation, bike.StationId,
stationName,
bike.OperatorUri, bike.OperatorUri,
bike.TariffDescription, bike.TariffDescription,
() => DateTime.Now, () => DateTime.Now,

View file

@ -17,7 +17,7 @@ namespace TINK.Model
string selectedStation) string selectedStation)
{ {
return new BikeCollection(bikesAtAnyStation? return new BikeCollection(bikesAtAnyStation?
.Where(bike => !string.IsNullOrEmpty(selectedStation) && bike.CurrentStation == selectedStation) .Where(bike => !string.IsNullOrEmpty(selectedStation) && bike.StationId == selectedStation)
.ToDictionary(x => x.Id) ?? new Dictionary<string, BikeInfo>()); .ToDictionary(x => x.Id) ?? new Dictionary<string, BikeInfo>());
} }

View file

@ -1,8 +1,9 @@
using System; using Serilog;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using TINK.Model.Station;
using BikeInfo = TINK.Model.Bike.BC.BikeInfo; using BikeInfo = TINK.Model.Bike.BC.BikeInfo;
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable; using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
@ -22,10 +23,11 @@ namespace TINK.Model.Bike
/// - removes bikes which are no more contained in bikes response /// - removes bikes which are no more contained in bikes response
/// - updates state of all bikes from state contained in bikes response /// - updates state of all bikes from state contained in bikes response
/// </summary> /// </summary>
/// <param name="bikesAll"> Object holding bikes info from copri to update from.</param> /// <param name="bikesAll"> Object holding bikes info from copri to update from. Holds station id but not station name.</param>
/// <param name="stations"> All stations to get station names from.</param>
/// <param name="p_oDateTimeProvider">Provices date time information.</param> /// <param name="p_oDateTimeProvider">Provices date time information.</param>
public void Update( public void Update(IEnumerable<BikeInfo> bikesAll,
IEnumerable<BikeInfo> bikesAll) IEnumerable<IStation> stations)
{ {
// Get list of current bikes by state(s) to update. // Get list of current bikes by state(s) to update.
// Needed to remove bikes which switched state and have to be removed from collection. // Needed to remove bikes which switched state and have to be removed from collection.
@ -33,16 +35,21 @@ namespace TINK.Model.Bike
foreach (var bikeInfo in bikesAll ?? new List<BikeInfo>()) foreach (var bikeInfo in bikesAll ?? new List<BikeInfo>())
{ {
/// Check if bike has to be added to list of existing station. // Get name of station form station id.
var stationName = stations?.FirstOrDefault(x => x.Id == bikeInfo.StationId)?.StationName ?? string.Empty;
if (string.IsNullOrEmpty(stationName))
Log.ForContext<BikeCollectionMutable>().Debug($"No name for station with id {bikeInfo.StationId} found.");
// Check if bike has to be added to list of existing station.
if (ContainsKey(bikeInfo.Id) == false) if (ContainsKey(bikeInfo.Id) == false)
{ {
// Bike does not yet exist in list of bikes. // Bike does not yet exist in list of bikes.
Add(BikeInfoMutableFactory.Create(bikeInfo)); Add(BikeInfoMutableFactory.Create(bikeInfo, stationName));
continue; continue;
} }
// Update bike. // Update bike.
GetById(bikeInfo.Id).State.Load(bikeInfo.State); GetById(bikeInfo.Id).State.Load(bikeInfo.State);
if (bikesToBeRemoved.Contains<string>(bikeInfo.Id)) if (bikesToBeRemoved.Contains<string>(bikeInfo.Id))
{ {
@ -52,29 +59,29 @@ namespace TINK.Model.Bike
} }
// Remove obsolete bikes. // Remove obsolete bikes.
foreach (var l_oId in bikesToBeRemoved) foreach (var stationId in bikesToBeRemoved)
{ {
RemoveById(l_oId); RemoveById(stationId);
} }
} }
/// <summary> /// <summary>
/// Adds a new bike to collecion of bike. /// Adds a new bike to collecion of bike.
/// </summary> /// </summary>
/// <param name="p_oNewBike">New bike to add.</param> /// <param name="newBike">New bike to add.</param>
/// <exception cref="Exception">Thrown if bike is not unique.</exception> /// <exception cref="Exception">Thrown if bike is not unique.</exception>
public new void Add(BikeInfoMutable p_oNewBike) public new void Add(BikeInfoMutable newBike)
{ {
// Ensure that bike id of new bike is is unique // Ensure that bike id of new bike is is unique
foreach (BikeInfoMutable l_oBike in Items) foreach (BikeInfoMutable bike in Items)
{ {
if (l_oBike.Id == p_oNewBike.Id) if (bike.Id == newBike.Id)
{ {
throw new Exception(string.Format("Can not add bike with {0} to collection ob bike. Id is not unnique.", p_oNewBike)); throw new Exception(string.Format("Can not add bike with {0} to collection ob bike. Id is not unnique.", newBike));
} }
} }
base.Add(p_oNewBike); base.Add(newBike);
} }
/// <summary> /// <summary>
@ -134,11 +141,11 @@ namespace TINK.Model.Bike
/// </summary> /// </summary>
private static class BikeInfoMutableFactory private static class BikeInfoMutableFactory
{ {
public static BikeInfoMutable Create(BikeInfo bikeInfo) public static BikeInfoMutable Create(BikeInfo bikeInfo, string stationName)
{ {
return (bikeInfo is BluetoothLock.BikeInfo bluetoothLockBikeInfo) return (bikeInfo is BluetoothLock.BikeInfo bluetoothLockBikeInfo)
? new BluetoothLock.BikeInfoMutable(bluetoothLockBikeInfo) ? new BluetoothLock.BikeInfoMutable(bluetoothLockBikeInfo, stationName)
: new BikeInfoMutable(bikeInfo); : new BikeInfoMutable(bikeInfo, stationName);
} }
} }
} }

View file

@ -60,7 +60,7 @@ namespace TINK.Model.Connector
{ {
response = (await CopriServer.DoAuthorizationAsync(mail, password, deviceId)).GetIsResponseOk(mail); response = (await CopriServer.DoAuthorizationAsync(mail, password, deviceId)).GetIsResponseOk(mail);
} }
catch (System.Exception) catch (Exception)
{ {
throw; throw;
} }

View file

@ -23,9 +23,9 @@ namespace TINK.Model.Connector
/// <summary>Constructs a copri query object.</summary> /// <summary>Constructs a copri query object.</summary>
/// <param name="p_oCopriServer">Server which implements communication.</param> /// <param name="p_oCopriServer">Server which implements communication.</param>
public CommandLoggedIn(ICopriServerBase p_oCopriServer, public CommandLoggedIn(ICopriServerBase p_oCopriServer,
string p_strSessionCookie, string sessionCookie,
string p_strMail, string mail,
Func<DateTime> p_oDateTimeProvider) : base(p_oCopriServer, p_strSessionCookie, p_strMail, p_oDateTimeProvider) Func<DateTime> dateTimeProvider) : base(p_oCopriServer, sessionCookie, mail, dateTimeProvider)
{ {
} }
@ -36,14 +36,14 @@ namespace TINK.Model.Connector
/// If communication fails an TINK.Repository.Exception is thrown. /// If communication fails an TINK.Repository.Exception is thrown.
/// </summary> /// </summary>
/// <param name="p_oAccount">Account to use for login.</param> /// <param name="p_oAccount">Account to use for login.</param>
public Task<IAccount> DoLogin(string p_strMail, string p_strPassword, string p_strDeviceId) public Task<IAccount> DoLogin(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."); throw new ArgumentNullException("Can not loging user. Mail address must not be null or empty.");
} }
throw new Exception($"Fehler beim Anmelden von unter {p_strMail}. Benutzer {Mail} ist bereits angemeldet."); throw new Exception($"Fehler beim Anmelden von unter {mail}. Benutzer {Mail} ist bereits angemeldet.");
} }
/// <summary> Logs user out. </summary> /// <summary> Logs user out. </summary>

View file

@ -25,12 +25,12 @@ namespace TINK.Model.Connector
ICachedCopriServer server = null ) ICachedCopriServer server = null )
{ {
Command = GetCommand( Command = GetCommand(
server ?? new CopriProviderHttps(activeUri, TinkApp.MerchantId, appContextInfo, sessionCookie), server ?? new CopriProviderHttps(activeUri, appContextInfo.MerchantId, appContextInfo, sessionCookie),
sessionCookie, sessionCookie,
mail); mail);
Query = GetQuery( Query = GetQuery(
server ?? new CopriProviderHttps(activeUri, TinkApp.MerchantId, appContextInfo, sessionCookie, expiresAfter), server ?? new CopriProviderHttps(activeUri, appContextInfo.MerchantId, appContextInfo, sessionCookie, expiresAfter),
sessionCookie, sessionCookie,
mail); mail);
} }

View file

@ -14,18 +14,19 @@ namespace TINK.Model.Connector
/// <param name="p_strMail">Mail of user.</param> /// <param name="p_strMail">Mail of user.</param>
/// <param name="server"> Provides addess to copri.</param> /// <param name="server"> Provides addess to copri.</param>
public ConnectorCache( public ConnectorCache(
AppContextInfo appContextInfo,
string sessionCookie, string sessionCookie,
string mail, string mail,
ICopriServer server = null) ICopriServer server = null)
{ {
Command = Connector.GetCommand( Command = Connector.GetCommand(
server ?? new CopriProviderMonkeyStore(TinkApp.MerchantId, sessionCookie), server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, sessionCookie),
sessionCookie, sessionCookie,
mail); mail);
Query = GetQuery( Query = GetQuery(
server ?? new CopriProviderMonkeyStore(TinkApp.MerchantId, sessionCookie), server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, sessionCookie),
sessionCookie, sessionCookie,
mail); mail);
} }

View file

@ -21,7 +21,7 @@ namespace TINK.Model.Connector
{ {
return isConnected return isConnected
? new Connector(activeUri, appContextInfo, sessionCookie, mail, expiresAfter: expiresAfter) as IConnector ? new Connector(activeUri, appContextInfo, sessionCookie, mail, expiresAfter: expiresAfter) as IConnector
: new ConnectorCache(sessionCookie, mail); : new ConnectorCache(appContextInfo, sessionCookie, mail);
} }
} }
} }

View file

@ -16,24 +16,24 @@ namespace TINK.Model.Connector
protected readonly Func<DateTime> DateTimeProvider; protected readonly Func<DateTime> DateTimeProvider;
/// <summary>Constructs a copri query object.</summary> /// <summary>Constructs a copri query object.</summary>
/// <param name="p_oCopriServer">Server which implements communication.</param> /// <param name="copriServer">Server which implements communication.</param>
public BaseLoggedIn(ICopriServerBase p_oCopriServer, public BaseLoggedIn(ICopriServerBase copriServer,
string p_strSessionCookie, string sessionCookie,
string p_strMail, string mail,
Func<DateTime> p_oDateTimeProvider) : base(p_oCopriServer) Func<DateTime> p_oDateTimeProvider) : base(copriServer)
{ {
if (string.IsNullOrEmpty(p_strSessionCookie)) if (string.IsNullOrEmpty(sessionCookie))
throw new ArgumentException("Can not instantiate query object- object. Session cookie must never be null or emtpy."); throw new ArgumentException("Can not instantiate query object- object. Session cookie must never be null or emtpy.");
if (string.IsNullOrEmpty(p_strMail)) if (string.IsNullOrEmpty(mail))
throw new ArgumentException("Can not instantiate query object- object. Mail address must never be null or emtpy."); throw new ArgumentException("Can not instantiate query object- object. Mail address must never be null or emtpy.");
DateTimeProvider = p_oDateTimeProvider DateTimeProvider = p_oDateTimeProvider
?? throw new ArgumentException("Can not instantiate connector- object. No date time provider object available."); ?? throw new ArgumentException("Can not instantiate connector- object. No date time provider object available.");
SessionCookie = p_strSessionCookie; SessionCookie = sessionCookie;
Mail = p_strMail; Mail = mail;
} }
} }
} }

View file

@ -26,30 +26,30 @@ namespace TINK.Model.Connector
/// <summary> /// <summary>
/// Gets the position from StationInfo object. /// Gets the position from StationInfo object.
/// </summary> /// </summary>
/// <param name="p_oStationInfo">Object to get information from.</param> /// <param name="stationInfo">Object to get information from.</param>
/// <returns>Position information.</returns> /// <returns>Position information.</returns>
public static Station.Position GetPosition(this StationsAvailableResponse.StationInfo p_oStationInfo) public static Station.Position GetPosition(this StationsAvailableResponse.StationInfo stationInfo)
{ {
return GetPosition(p_oStationInfo.gps); return GetPosition(stationInfo.gps);
} }
/// <summary> Gets the position from StationInfo object. </summary> /// <summary> Gets the position from StationInfo object. </summary>
/// <param name="p_oAuthorizationResponse">Object to get information from.</param> /// <param name="authorizationResponse">Object to get information from.</param>
/// <returns>Position information.</returns> /// <returns>Position information.</returns>
public static IEnumerable<string> GetGroup(this AuthorizationResponse p_oAuthorizationResponse) public static IEnumerable<string> GetGroup(this AuthorizationResponse authorizationResponse)
{ {
try try
{ {
return p_oAuthorizationResponse.user_group.GetGroup(); return authorizationResponse.user_group.GetGroup();
} }
catch (Exception l_oException) catch (Exception l_oException)
{ {
throw new Exception($"Can not get group of user from text \"{p_oAuthorizationResponse.user_group}\".", l_oException); throw new Exception($"Can not get group of user from text \"{authorizationResponse.user_group}\".", l_oException);
} }
} }
/// <summary> Gets the position from StationInfo object. </summary> /// <summary> Gets the position from StationInfo object. </summary>
/// <param name="p_oAuthorizationResponse">Object to get information from.</param> /// <param name="group">Object to get information from.</param>
/// <returns>Position information.</returns> /// <returns>Position information.</returns>
public static IEnumerable<string> GetGroup(this string[] group) public static IEnumerable<string> GetGroup(this string[] group)
{ {
@ -63,43 +63,50 @@ namespace TINK.Model.Connector
return new HashSet<string>(group).ToList(); return new HashSet<string>(group).ToList();
} }
/// <summary> Gets the position from StationInfo object. </summary> /// <summary> Gets if user acknowldged ags or not. </summary>
/// <param name="p_oAuthorizationResponse">Object to get information from.</param> /// <param name="authorizationResponse">Object to get information from.</param>
/// <returns>Position information.</returns> /// <returns>Position information.</returns>
public static string GetGroup(this IEnumerable<string> p_oGroup) public static bool GetIsAgbAcknowledged(this AuthorizationResponse authorizationResponse)
=> int.TryParse(authorizationResponse?.agb_checked, out int result)
&& result != 0;
/// <summary> Gets the position from StationInfo object. </summary>
/// <param name="group">Object to get information from.</param>
/// <returns>Position information.</returns>
public static string GetGroup(this IEnumerable<string> group)
{ {
return string.Join(",", p_oGroup); return string.Join(",", group);
} }
/// <summary> Gets the position from StationInfo object. </summary> /// <summary> Gets the position from StationInfo object. </summary>
/// <param name="p_oStationInfo">Object to get information from.</param> /// <param name="stationInfo">Object to get information from.</param>
/// <returns>Position information.</returns> /// <returns>Position information.</returns>
public static IEnumerable<string> GetGroup(this StationsAvailableResponse.StationInfo p_oStationInfo) public static IEnumerable<string> GetGroup(this StationsAvailableResponse.StationInfo stationInfo)
{ {
try try
{ {
return p_oStationInfo.station_group.GetGroup(); return stationInfo.station_group.GetGroup();
} }
catch (Exception l_oException) catch (Exception l_oException)
{ {
throw new Exception($"Can not get group of stations from text \"{p_oStationInfo.station_group}\".", l_oException); throw new Exception($"Can not get group of stations from text \"{stationInfo.station_group}\".", l_oException);
} }
} }
/// <summary> /// <summary>
/// Gets the position from StationInfo object. /// Gets the position from StationInfo object.
/// </summary> /// </summary>
/// <param name="p_oBikeInfo">Object to get information from.</param> /// <param name="bikeInfo">Object to get information from.</param>
/// <returns>Position information.</returns> /// <returns>Position information.</returns>
public static InUseStateEnum GetState(this BikeInfoBase p_oBikeInfo) public static InUseStateEnum GetState(this BikeInfoBase bikeInfo)
{ {
var l_oState = p_oBikeInfo.state; var l_oState = bikeInfo.state;
if (string.IsNullOrEmpty(l_oState)) if (string.IsNullOrEmpty(l_oState))
{ {
throw new InvalidResponseException<BikeInfoBase>( throw new InvalidResponseException<BikeInfoBase>(
string.Format("Unknown reservation state detected. Member {0}.{1}.", typeof(BikeInfoBase), nameof(BikeInfoBase.state)), string.Format("Unknown reservation state detected. Member {0}.{1}.", typeof(BikeInfoBase), nameof(BikeInfoBase.state)),
p_oBikeInfo); bikeInfo);
} }
if (l_oState == "available") if (l_oState == "available")
@ -123,58 +130,58 @@ namespace TINK.Model.Connector
/// <summary> /// <summary>
/// Gets the from date information from JSON. /// Gets the from date information from JSON.
/// </summary> /// </summary>
/// <param name="p_oBikeInfo">JSON to get information from..</param> /// <param name="bikeInfo">JSON to get information from..</param>
/// <returns>From information.</returns> /// <returns>From information.</returns>
public static DateTime GetFrom(this BikeInfoReservedOrBooked p_oBikeInfo) public static DateTime GetFrom(this BikeInfoReservedOrBooked bikeInfo)
{ {
return DateTime.Parse(p_oBikeInfo.start_time); return DateTime.Parse(bikeInfo.start_time);
} }
/// <summary> /// <summary>
/// Gets whether the bike is a trike or not. /// Gets whether the bike is a trike or not.
/// </summary> /// </summary>
/// <param name="p_oBikeInfo">JSON to get information from..</param> /// <param name="bikeInfo">JSON to get information from..</param>
/// <returns>From information.</returns> /// <returns>From information.</returns>
public static bool? GetIsDemo(this BikeInfoBase p_oBikeInfo) public static bool? GetIsDemo(this BikeInfoBase bikeInfo)
{ {
return p_oBikeInfo?.description != null return bikeInfo?.description != null
? p_oBikeInfo.description.ToUpper().Contains(DEMOBIKEMARKER) ? bikeInfo.description.ToUpper().Contains(DEMOBIKEMARKER)
: (bool?) null; : (bool?) null;
} }
/// <summary> /// <summary>
/// Gets whether the bike is a trike or not. /// Gets whether the bike is a trike or not.
/// </summary> /// </summary>
/// <param name="p_oBikeInfo">JSON to get information from..</param> /// <param name="bikeInfo">JSON to get information from.</param>
/// <returns>From information.</returns> /// <returns>From information.</returns>
public static IEnumerable<string> GetGroup(this BikeInfoBase p_oBikeInfo) public static IEnumerable<string> GetGroup(this BikeInfoBase bikeInfo)
{ {
try try
{ {
return p_oBikeInfo?.bike_group?.GetGroup()?.ToList() ?? new List<string>(); return bikeInfo?.bike_group?.GetGroup()?.ToList() ?? new List<string>();
} }
catch (System.Exception l_oException) catch (System.Exception l_oException)
{ {
throw new System.Exception($"Can not get group of user from text \"{p_oBikeInfo.bike_group}\".", l_oException); throw new System.Exception($"Can not get group of user from text \"{bikeInfo.bike_group}\".", l_oException);
} }
} }
/// <summary> Gets whether the bike has a bord computer or not. </summary> /// <summary> Gets whether the bike has a bord computer or not. </summary>
/// <param name="p_oBikeInfo">JSON to get information from.</param> /// <param name="bikeInfo">JSON to get information from.</param>
/// <returns>From information.</returns> /// <returns>From information.</returns>
public static bool GetIsManualLockBike(this BikeInfoBase p_oBikeInfo) public static bool GetIsManualLockBike(this BikeInfoBase bikeInfo)
{ {
return !string.IsNullOrEmpty(p_oBikeInfo.system) return !string.IsNullOrEmpty(bikeInfo.system)
&& p_oBikeInfo.system.ToUpper().StartsWith("LOCK"); && bikeInfo.system.ToUpper().StartsWith("LOCK");
} }
/// <summary> Gets whether the bike has a bord computer or not. </summary> /// <summary> Gets whether the bike has a bord computer or not. </summary>
/// <param name="p_oBikeInfo">JSON to get information from..</param> /// <param name="bikeInfo">JSON to get information from..</param>
/// <returns>From information.</returns> /// <returns>From information.</returns>
public static bool GetIsBluetoothLockBike(this BikeInfoBase p_oBikeInfo) public static bool GetIsBluetoothLockBike(this BikeInfoBase bikeInfo)
{ {
return !string.IsNullOrEmpty(p_oBikeInfo.system) return !string.IsNullOrEmpty(bikeInfo.system)
&& p_oBikeInfo.system.ToUpper().StartsWith("ILOCKIT"); && bikeInfo.system.ToUpper().StartsWith("ILOCKIT");
} }
/// <summary> Gets whether the bike has a bord computer or not. </summary> /// <summary> Gets whether the bike has a bord computer or not. </summary>
@ -342,13 +349,22 @@ namespace TINK.Model.Connector
: null; : null;
} }
/// <summary> Tries to get the copriversion from response.</summary>
/// <param name="response">Response to get version info from.</param>
/// <returns>COPRI version</returns>
public static bool TryGetCopriVersion(this CopriVersion response, out Version copriVersion)
{
copriVersion = new Version(0, 0);
return response != null
&& !string.IsNullOrEmpty(response.copri_version)
&& Version.TryParse(response.copri_version, out copriVersion);
}
/// <summary> Gets the copriversion from.</summary> /// <summary> Gets the copriversion from.</summary>
/// <param name="response">Response to get version info from.</param> /// <param name="response">Response to get version info from.</param>
/// <returns>COPRI version</returns> /// <returns>COPRI version</returns>
public static Version GetCopriVersion(this CopriVersion response) public static Version GetCopriVersion(this CopriVersion response)
=> response!= null => response.TryGetCopriVersion(out Version copriVersion)
&& !string.IsNullOrEmpty(response.copri_version)
&& Version.TryParse(response.copri_version, out Version copriVersion)
? copriVersion ? copriVersion
: throw new InvalidResponseException($"Can not get version info from copri response {response?.copri_version}."); : throw new InvalidResponseException($"Can not get version info from copri response {response?.copri_version}.");
} }

View file

@ -85,7 +85,9 @@ namespace TINK.Model.Connector
/// <param name="response">Response to get data from.</param> /// <param name="response">Response to get data from.</param>
/// <returns>General data object initialized form COPRI response.</returns> /// <returns>General data object initialized form COPRI response.</returns>
public static GeneralData GetGeneralData(this ResponseBase response) public static GeneralData GetGeneralData(this ResponseBase response)
=> new GeneralData(response.merchant_message, response.GetCopriVersion()); => new GeneralData(response.merchant_message, response.TryGetCopriVersion(out Version copriVersion)
? new Version(0,0)
: copriVersion);
/// <summary> Gets account object from login response.</summary> /// <summary> Gets account object from login response.</summary>
/// <param name="merchantId">Needed to extract cookie from autorization response.</param> /// <param name="merchantId">Needed to extract cookie from autorization response.</param>
@ -106,6 +108,7 @@ namespace TINK.Model.Connector
return new Account( return new Account(
mail, mail,
password, password,
loginResponse.GetIsAgbAcknowledged(),
loginResponse.authcookie?.Replace(merchantId, ""), loginResponse.authcookie?.Replace(merchantId, ""),
loginResponse.GetGroup(), loginResponse.GetGroup(),
loginResponse.debuglevel == 1 loginResponse.debuglevel == 1

View file

@ -36,7 +36,7 @@ namespace TINK.Model
public delegate bool SetCredentialsDelegate(string p_strMailAddress, string p_strPassword); public delegate bool SetCredentialsDelegate(string p_strMailAddress, string p_strPassword);
/// <summary>Returns the id of the app (sharee.bike) to be identified by copri.</summary> /// <summary>Returns the id of the app (sharee.bike) to be identified by copri.</summary>
public static string MerchantId => "oiF2kahH"; public static string MerchantId { get; private set; }
/// <summary> /// <summary>
/// Holds status about whants new page. /// Holds status about whants new page.
@ -160,6 +160,7 @@ namespace TINK.Model
Settings.Settings settings, Settings.Settings settings,
IStore accountStore, IStore accountStore,
Func<bool, Uri, string /* session cookie*/, string /* mail address*/, TimeSpan, IConnector> connectorFactory, Func<bool, Uri, string /* session cookie*/, string /* mail address*/, TimeSpan, IConnector> connectorFactory,
string merchantId,
IServicesContainer<IGeolocation> geolocationServicesContainer, IServicesContainer<IGeolocation> geolocationServicesContainer,
ILocksService locksService, ILocksService locksService,
ISmartDevice device, ISmartDevice device,
@ -179,6 +180,9 @@ namespace TINK.Model
ConnectorFactory = connectorFactory ConnectorFactory = connectorFactory
?? throw new ArgumentException("Can not instantiate TinkApp- object. No connector factory object available."); ?? throw new ArgumentException("Can not instantiate TinkApp- object. No connector factory object available.");
MerchantId = merchantId
?? throw new ArgumentException($"Can not instantiate {nameof(TinkApp)}. No merchant id available.");
Cipher = cipher ?? new Cipher(); Cipher = cipher ?? new Cipher();
var locksServices = locksService != null var locksServices = locksService != null

View file

@ -49,6 +49,8 @@ namespace TINK.Model.User.Account
/// </summary> /// </summary>
public class Account : IAccount public class Account : IAccount
{ {
public const bool DEFAULTISAGBACKNOWLEDGED = false;
/// <summary> Constructs an account object.</summary> /// <summary> Constructs an account object.</summary>
/// <param name="mail">Mail address of the account holder.</param> /// <param name="mail">Mail address of the account holder.</param>
/// <param name="password">Password.</param> /// <param name="password">Password.</param>
@ -58,12 +60,14 @@ namespace TINK.Model.User.Account
public Account( public Account(
string mail, string mail,
string password, string password,
bool isAgbAcknowledged,
string sessionCookie, string sessionCookie,
IEnumerable<string> bikeGroup, IEnumerable<string> bikeGroup,
Permissions debugLevel = Permissions.None) Permissions debugLevel = Permissions.None)
{ {
Mail = mail; Mail = mail;
Pwd = password; Pwd = password;
IsAgbAcknowledged = isAgbAcknowledged;
SessionCookie = sessionCookie; SessionCookie = sessionCookie;
DebugLevel = debugLevel; DebugLevel = debugLevel;
Group = bikeGroup != null Group = bikeGroup != null
@ -71,7 +75,7 @@ namespace TINK.Model.User.Account
: throw new ArgumentException("Can not instantiate account object. Reference to group list must not be empty."); : throw new ArgumentException("Can not instantiate account object. Reference to group list must not be empty.");
} }
public Account(IAccount p_oSource) : this(p_oSource?.Mail, p_oSource?.Pwd, p_oSource?.SessionCookie, p_oSource?.Group, p_oSource?.DebugLevel ?? Permissions.None) public Account(IAccount source) : this(source?.Mail, source?.Pwd, source?.IsAgbAcknowledged ?? DEFAULTISAGBACKNOWLEDGED, source?.SessionCookie, source?.Group, source?.DebugLevel ?? Permissions.None)
{ {
} }
@ -81,6 +85,9 @@ namespace TINK.Model.User.Account
/// <summary>Password of to authenticate.</summary> /// <summary>Password of to authenticate.</summary>
public string Pwd { get; } public string Pwd { get; }
/// <summary>True if user acknowleged agbs.</summary>
public bool IsAgbAcknowledged { get; }
/// <summary>Session cookie used to sign in to copri.</summary> /// <summary>Session cookie used to sign in to copri.</summary>
public string SessionCookie { get; } public string SessionCookie { get; }

View file

@ -29,7 +29,7 @@ namespace TINK.Model.User.Account
public string Mail public string Mail
{ {
get { return m_oAccount.Mail; } get { return m_oAccount.Mail; }
set { m_oAccount = new Account(value, m_oAccount.Pwd, m_oAccount.SessionCookie, m_oAccount.Group, m_oAccount.DebugLevel); } set { m_oAccount = new Account(value, m_oAccount.Pwd, m_oAccount.IsAgbAcknowledged, m_oAccount.SessionCookie, m_oAccount.Group, m_oAccount.DebugLevel); }
} }
/// <summary> /// <summary>
@ -38,16 +38,19 @@ namespace TINK.Model.User.Account
public string Pwd public string Pwd
{ {
get { return m_oAccount.Pwd; } get { return m_oAccount.Pwd; }
set { m_oAccount = new Account(m_oAccount.Mail, value, m_oAccount.SessionCookie, m_oAccount.Group, m_oAccount.DebugLevel); } set { m_oAccount = new Account(m_oAccount.Mail, value, m_oAccount.IsAgbAcknowledged, m_oAccount.SessionCookie, m_oAccount.Group, m_oAccount.DebugLevel); }
} }
/// <summary>True if user acknowleged agbs.</summary>
public bool IsAgbAcknowledged => m_oAccount.IsAgbAcknowledged;
/// <summary> /// <summary>
/// Session cookie used to sign in to copri. /// Session cookie used to sign in to copri.
/// </summary> /// </summary>
public string SessionCookie public string SessionCookie
{ {
get { return m_oAccount.SessionCookie; } get { return m_oAccount.SessionCookie; }
set { m_oAccount = new Account(m_oAccount.Mail, m_oAccount.Pwd, value, m_oAccount.Group, m_oAccount.DebugLevel); } set { m_oAccount = new Account(m_oAccount.Mail, m_oAccount.Pwd, m_oAccount.IsAgbAcknowledged, value, m_oAccount.Group, m_oAccount.DebugLevel); }
} }
/// <summary> /// <summary>
@ -64,7 +67,7 @@ namespace TINK.Model.User.Account
public Permissions DebugLevel public Permissions DebugLevel
{ {
get { return m_oAccount.DebugLevel; } get { return m_oAccount.DebugLevel; }
set { m_oAccount = new Account(m_oAccount.Mail, m_oAccount.Pwd, m_oAccount.SessionCookie, m_oAccount.Group, value); } set { m_oAccount = new Account(m_oAccount.Mail, m_oAccount.Pwd, m_oAccount.IsAgbAcknowledged, m_oAccount.SessionCookie, m_oAccount.Group, value); }
} }
} }
} }

View file

@ -9,6 +9,8 @@ namespace TINK.Model.User.Account
public string Pwd => null; public string Pwd => null;
public bool IsAgbAcknowledged => false;
public string SessionCookie => null; public string SessionCookie => null;
public Permissions DebugLevel => Permissions.None; public Permissions DebugLevel => Permissions.None;

View file

@ -13,6 +13,9 @@ namespace TINK.Model.User.Account
/// <summary>Password of the account.</summary> /// <summary>Password of the account.</summary>
string Pwd { get; } string Pwd { get; }
/// <summary>True if user acknowleged agbs.</summary>
bool IsAgbAcknowledged { get; }
/// <summary>Session cookie used to sign in to copri.</summary> /// <summary>Session cookie used to sign in to copri.</summary>
string SessionCookie { get; } string SessionCookie { get; }

View file

@ -17,6 +17,9 @@ namespace TINK.Model.User.Account
/// <summary> Holds id of the mail address key. </summary> /// <summary> Holds id of the mail address key. </summary>
private const string KEY_MAILADDRESS = "MailAddress"; private const string KEY_MAILADDRESS = "MailAddress";
/// <summary> Holds key for flag is agb acknowledged. </summary>
private const string KEY_ISAGBACKNOWLEDGED = "IsAgbAcknowledged";
public IAccount Delete(IAccount account) public IAccount Delete(IAccount account)
{ {
SecureStorage.RemoveAll(); SecureStorage.RemoveAll();
@ -27,15 +30,16 @@ namespace TINK.Model.User.Account
{ {
var mail = string.Empty; var mail = string.Empty;
var isAgbAcknowledged = Account.DEFAULTISAGBACKNOWLEDGED;
var sessionCookie = string.Empty; var sessionCookie = string.Empty;
var debugLevel = Permissions.None; var debugLevel = Permissions.None;
try try
{ {
mail = await SecureStorage.GetAsync(KEY_MAILADDRESS); mail = await SecureStorage.GetAsync(KEY_MAILADDRESS);
bool.TryParse(await SecureStorage.GetAsync(KEY_ISAGBACKNOWLEDGED), out isAgbAcknowledged);
sessionCookie = await SecureStorage.GetAsync(KEY_SESSIONCOOKIE); sessionCookie = await SecureStorage.GetAsync(KEY_SESSIONCOOKIE);
Enum.TryParse(await SecureStorage.GetAsync(KEY_DEBUGLEVEL), out debugLevel); Enum.TryParse(await SecureStorage.GetAsync(KEY_DEBUGLEVEL), out debugLevel);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -45,6 +49,7 @@ namespace TINK.Model.User.Account
return new Account( return new Account(
mail, mail,
string.Empty, string.Empty,
isAgbAcknowledged,
sessionCookie, sessionCookie,
new List<string>(), new List<string>(),
debugLevel); debugLevel);
@ -55,6 +60,7 @@ namespace TINK.Model.User.Account
try try
{ {
await SecureStorage.SetAsync(KEY_MAILADDRESS, mailAndPwd.Mail); await SecureStorage.SetAsync(KEY_MAILADDRESS, mailAndPwd.Mail);
await SecureStorage.SetAsync(KEY_ISAGBACKNOWLEDGED, mailAndPwd.IsAgbAcknowledged.ToString());
await SecureStorage.SetAsync(KEY_SESSIONCOOKIE, mailAndPwd.SessionCookie); await SecureStorage.SetAsync(KEY_SESSIONCOOKIE, mailAndPwd.SessionCookie);
await SecureStorage.SetAsync(KEY_DEBUGLEVEL, mailAndPwd.DebugLevel.ToString()); await SecureStorage.SetAsync(KEY_DEBUGLEVEL, mailAndPwd.DebugLevel.ToString());
} }

View file

@ -476,7 +476,7 @@ namespace TINK.Model
AppResources.ChangeLog3_0_266 AppResources.ChangeLog3_0_266
}, },
{ {
new Version(3, 0, 267), new Version(3, 0, 270),
AppResources.ChangeLog3_0_231 // Minor improvements. AppResources.ChangeLog3_0_231 // Minor improvements.
} }
}; };

View file

@ -767,29 +767,29 @@ namespace TINK.Repository
var l_strHost = uRL; var l_strHost = uRL;
// Returns a http request. // Returns a http request.
var l_oRequest = WebRequest.CreateHttp(l_strHost); var request = WebRequest.CreateHttp(l_strHost);
l_oRequest.Method = "POST"; request.Method = "POST";
l_oRequest.ContentType = "application/x-www-form-urlencoded"; request.ContentType = "application/x-www-form-urlencoded";
l_oRequest.UserAgent = userAgent; request.UserAgent = userAgent;
// Workaround for issue https://bugzilla.xamarin.com/show_bug.cgi?id=57705 // Workaround for issue https://bugzilla.xamarin.com/show_bug.cgi?id=57705
// If not KeepAlive is set to true Stream.Write leads arbitrarily to an object disposed exception. // If not KeepAlive is set to true Stream.Write leads arbitrarily to an object disposed exception.
l_oRequest.KeepAlive = true; request.KeepAlive = true;
byte[] l_oPostData = Encoding.UTF8.GetBytes(p_strCommand); byte[] l_oPostData = Encoding.UTF8.GetBytes(p_strCommand);
l_oRequest.ContentLength = l_oPostData.Length; request.ContentLength = l_oPostData.Length;
// Get the request stream. // Get the request stream.
using (Stream l_oDataStream = await l_oRequest.GetRequestStreamAsync()) using (Stream l_oDataStream = await request.GetRequestStreamAsync())
{ {
// Write the data to the request stream. // Write the data to the request stream.
await l_oDataStream.WriteAsync(l_oPostData, 0, l_oPostData.Length); await l_oDataStream.WriteAsync(l_oPostData, 0, l_oPostData.Length);
} }
// Get the response. // Get the response.
var l_oResponse = await l_oRequest.GetResponseAsync() as HttpWebResponse; var l_oResponse = await request.GetResponseAsync() as HttpWebResponse;
if (l_oResponse == null) if (l_oResponse == null)
{ {

View file

@ -1380,7 +1380,7 @@ namespace TINK.Repository
get get
{ {
var l_iCount = 1; var l_iCount = 1;
while (GetBikesAvailable(CopriDevelHostUri, TinkApp.MerchantId, p_eSampleSet: ActiveSampleSet, p_lStageIndex: l_iCount) != null) while (GetBikesAvailable(CopriDevelHostUri, MerchantId, p_eSampleSet: ActiveSampleSet, p_lStageIndex: l_iCount) != null)
{ {
l_iCount++; l_iCount++;
} }

View file

@ -11,5 +11,9 @@ namespace TINK.Repository.Response
/// <summary> Holds the group of the bike (TINK, Konrad, ...).</summary> /// <summary> Holds the group of the bike (TINK, Konrad, ...).</summary>
[DataMember] [DataMember]
public string[] user_group { get; private set; } public string[] user_group { get; private set; }
/// <summary> Holds value of 0 if agb were not acknowledged.</summary>
[DataMember]
public string agb_checked { get; private set; }
} }
} }

View file

@ -195,13 +195,13 @@ namespace TINK.ViewModel.Bikes.Bike
case InUseStateEnum.Reserved: case InUseStateEnum.Reserved:
return GetReservedInfo( return GetReservedInfo(
bike.State.RemainingTime, bike.State.RemainingTime,
bike.CurrentStation, bike.StationId,
null); // Hide reservation code because no one but active user should see code null); // Hide reservation code because no one but active user should see code
case InUseStateEnum.Booked: case InUseStateEnum.Booked:
return GetBookedInfo( return GetBookedInfo(
bike.State.From, bike.State.From,
bike.CurrentStation, bike.StationId,
null); // Hide reservation code because no one but active user should see code null); // Hide reservation code because no one but active user should see code
default: default:
@ -215,7 +215,7 @@ namespace TINK.ViewModel.Bikes.Bike
return bike.State.MailAddress == ActiveUser.Mail return bike.State.MailAddress == ActiveUser.Mail
? GetReservedInfo( ? GetReservedInfo(
bike.State.RemainingTime, bike.State.RemainingTime,
bike.CurrentStation, bike.StationId,
bike.State.Code) bike.State.Code)
: "Fahrrad bereits reserviert durch anderen Nutzer."; : "Fahrrad bereits reserviert durch anderen Nutzer.";
@ -223,7 +223,7 @@ namespace TINK.ViewModel.Bikes.Bike
return bike.State.MailAddress == ActiveUser.Mail return bike.State.MailAddress == ActiveUser.Mail
? GetBookedInfo( ? GetBookedInfo(
bike.State.From, bike.State.From,
bike.CurrentStation, bike.StationId,
bike.State.Code) bike.State.Code)
: "Fahrrad bereits gebucht durch anderen Nutzer."; : "Fahrrad bereits gebucht durch anderen Nutzer.";

View file

@ -27,14 +27,11 @@ namespace TINK.ViewModel.Bikes.Bike
// No tariff description details available. // No tariff description details available.
return string.Empty; return string.Empty;
// Up to version MessageBikesManagementTariffDescriptionTariffHeaderNameId
#if USCSHARP9 #if USCSHARP9
return Tariff?.Number != null return string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
? string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeaderNameId, Tariff?.Name ?? "-", Tariff?.Number != null ? Tariff.Number : "-");
: string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
#else #else
return Tariff?.Number != null return string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
? string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeaderNameId, Tariff?.Name ?? "-", Tariff?.Number != null ? Tariff.Number.ToString() : "-")
: string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-");
#endif #endif
} }
} }

View file

@ -266,7 +266,7 @@ namespace TINK.ViewModel.BikesAtStation
if (!dialogResult) if (!dialogResult)
{ {
// User decided not to give access to locations permissions. // User decided not to give access to locations permissions.
BikeCollection.Update(bikesAtStation); BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation});
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -287,7 +287,7 @@ namespace TINK.ViewModel.BikesAtStation
AppResources.MessageBikesManagementLocationActivation, AppResources.MessageBikesManagementLocationActivation,
AppResources.MessageAnswerOk); AppResources.MessageAnswerOk);
BikeCollection.Update(bikesAtStation); BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation });
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -303,7 +303,7 @@ namespace TINK.ViewModel.BikesAtStation
AppResources.MessageBikesManagementBluetoothActivation, AppResources.MessageBikesManagementBluetoothActivation,
AppResources.MessageAnswerOk); AppResources.MessageAnswerOk);
BikeCollection.Update(bikesAtStation); BikeCollection.Update(bikesAtStation, new List<IStation> { m_oStation });
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -330,7 +330,7 @@ namespace TINK.ViewModel.BikesAtStation
var locksInfo = lockIdList.UpdateById(locksInfoTdo); var locksInfo = lockIdList.UpdateById(locksInfoTdo);
BikeCollection.Update(bikesAtStation.UpdateLockInfo(locksInfo)); BikeCollection.Update(bikesAtStation.UpdateLockInfo(locksInfo), new List<IStation> { m_oStation });
// Backup GUI synchronization context. // Backup GUI synchronization context.
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -363,7 +363,7 @@ namespace TINK.ViewModel.BikesAtStation
PostAction( PostAction(
unused => unused =>
{ {
BikeCollection.Update(bikes); BikeCollection.Update(bikes, new List<IStation> { m_oStation });
Exception = result.Exception; Exception = result.Exception;
ActionText = string.Empty; ActionText = string.Empty;
}, },

View file

@ -508,7 +508,7 @@ namespace TINK.ViewModel.Contact
foreach (var stationId in stationsId) foreach (var stationId in stationsId)
{ {
// Get color of given station. // Get color of given station.
var bikesAtStation = bikesAll.Where(x => x.CurrentStation == stationId).ToList(); var bikesAtStation = bikesAll.Where(x => x.StationId == stationId).ToList();
if (bikesAtStation.FirstOrDefault(x => x.State.Value != Model.State.InUseStateEnum.Disposable) != null) if (bikesAtStation.FirstOrDefault(x => x.State.Value != Model.State.InUseStateEnum.Disposable) != null)
{ {
// There is at least one requested or booked bike // There is at least one requested or booked bike

View file

@ -4,16 +4,23 @@ namespace TINK.ViewModel.CopriWebView
{ {
public class RegisterPageViewModel public class RegisterPageViewModel
{ {
/// <summary> Holds the merchant id.</summary>
private string MerchantId { get; }
/// <summary> Holds the name of the host.</summary> /// <summary> Holds the name of the host.</summary>
private string HostName { get; } private string HostName { get; }
public RegisterPageViewModel( public RegisterPageViewModel(
string merchantId,
string hostName) string hostName)
{ {
HostName = hostName; HostName = hostName;
} /// <summary>Get Uri of web view for creating account.</summary> MerchantId = merchantId;
}
/// <summary>Get Uri of web view for creating account.</summary>
public string Uri => public string Uri =>
$"https://{HostName}/{HostName.GetAppFolderName()}/Account/1.%20Kundendaten"; $"https://{HostName}/{HostName.GetAppFolderName()}/Account/1.%20Kundendaten?sessionid={MerchantId}";
} }
} }

View file

@ -23,6 +23,7 @@ using TINK.Services.Permissions;
using Plugin.BLE.Abstractions.Contracts; using Plugin.BLE.Abstractions.Contracts;
using TINK.MultilingualResources; using TINK.MultilingualResources;
using TINK.Model.Device; using TINK.Model.Device;
using TINK.Model.Station;
namespace TINK.ViewModel.FindBike namespace TINK.ViewModel.FindBike
{ {
@ -55,6 +56,9 @@ namespace TINK.ViewModel.FindBike
/// <summary> Hide id input fields as soon as bike is found.</summary> /// <summary> Hide id input fields as soon as bike is found.</summary>
public bool IsSelectBikeVisible => BikeCollection != null && BikeCollection.Count == 0; public bool IsSelectBikeVisible => BikeCollection != null && BikeCollection.Count == 0;
/// <summary> Holds the stations to get station names form station ids. </summary>
private IEnumerable<IStation> Stations { get; }
/// <summary> /// <summary>
/// Constructs bike collection view model in case information about occupied bikes is available. /// Constructs bike collection view model in case information about occupied bikes is available.
/// </summary> /// </summary>
@ -66,6 +70,7 @@ namespace TINK.ViewModel.FindBike
/// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param> /// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param>
/// <param name="connectorFactory">Connects system to copri.</param> /// <param name="connectorFactory">Connects system to copri.</param>
/// <param name="lockService">Service to control lock retrieve info.</param> /// <param name="lockService">Service to control lock retrieve info.</param>
/// <param name="stations">Stations to get station name from station id.</param>
/// <param name="polling"> Holds whether to poll or not and the periode leght is polling is on. </param> /// <param name="polling"> Holds whether to poll or not and the periode leght is polling is on. </param>
/// <param name="postAction">Executes actions on GUI thread.</param> /// <param name="postAction">Executes actions on GUI thread.</param>
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param> /// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
@ -79,6 +84,7 @@ namespace TINK.ViewModel.FindBike
Func<bool, IConnector> connectorFactory, Func<bool, IConnector> connectorFactory,
IGeolocation geolocation, IGeolocation geolocation,
ILocksService lockService, ILocksService lockService,
IEnumerable<IStation> stations,
PollingParameters polling, PollingParameters polling,
Action<SendOrPostCallback, object> postAction, Action<SendOrPostCallback, object> postAction,
ISmartDevice smartDevice, ISmartDevice smartDevice,
@ -88,6 +94,8 @@ namespace TINK.ViewModel.FindBike
{ {
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelectBikeVisible))); OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelectBikeVisible)));
}; };
Stations = stations ?? throw new ArgumentException(nameof(stations));
} }
/// <summary> /// <summary>
@ -159,7 +167,7 @@ namespace TINK.ViewModel.FindBike
if (!dialogResult) if (!dialogResult)
{ {
// User decided not to give access to locations permissions. // User decided not to give access to locations permissions.
BikeCollection.Update(bikeCollection); BikeCollection.Update(bikeCollection, Stations);
//await OnAppearing(() => UpdateTask()); //await OnAppearing(() => UpdateTask());
@ -181,7 +189,7 @@ namespace TINK.ViewModel.FindBike
AppResources.MessageBikesManagementLocationActivation, AppResources.MessageBikesManagementLocationActivation,
AppResources.MessageAnswerOk); AppResources.MessageAnswerOk);
BikeCollection.Update(bikeCollection); BikeCollection.Update(bikeCollection, Stations);
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -198,7 +206,7 @@ namespace TINK.ViewModel.FindBike
AppResources.MessageBikesManagementBluetoothActivation, AppResources.MessageBikesManagementBluetoothActivation,
AppResources.MessageAnswerOk); AppResources.MessageAnswerOk);
BikeCollection.Update(bikeCollection); BikeCollection.Update(bikeCollection, Stations);
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -225,7 +233,7 @@ namespace TINK.ViewModel.FindBike
var locksInfo = lockIdList.UpdateById(locksInfoTdo); var locksInfo = lockIdList.UpdateById(locksInfoTdo);
BikeCollection.Update(bikeCollection.UpdateLockInfo(locksInfo)); BikeCollection.Update(bikeCollection.UpdateLockInfo(locksInfo), Stations);
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -265,7 +273,7 @@ namespace TINK.ViewModel.FindBike
PostAction( PostAction(
unused => unused =>
{ {
BikeCollection.Update(bikes); // Updating collection leads to update of GUI. BikeCollection.Update(bikes, Stations); // Updating collection leads to update of GUI.
Exception = result.Exception; Exception = result.Exception;
ActionText = string.Empty; ActionText = string.Empty;
}, },

View file

@ -214,6 +214,7 @@ namespace TINK.ViewModel
public async Task Login() public async Task Login()
#endif #endif
{ {
IAccount account = new EmptyAccount();
try try
{ {
Log.ForContext<LoginPageViewModel>().Information("User taped login button."); Log.ForContext<LoginPageViewModel>().Information("User taped login button.");
@ -223,9 +224,9 @@ namespace TINK.ViewModel
TinkApp.ActiveUser.CheckIsPasswordValid(MailAddress, Password); TinkApp.ActiveUser.CheckIsPasswordValid(MailAddress, Password);
// Do login. // Do login.
var l_oAccount = await TinkApp.GetConnector(CrossConnectivity.Current.IsConnected).Command.DoLogin(MailAddress, Password, TinkApp.ActiveUser.DeviceId); account = await TinkApp.GetConnector(CrossConnectivity.Current.IsConnected).Command.DoLogin(MailAddress, Password, TinkApp.ActiveUser.DeviceId);
await TinkApp.ActiveUser.Login(l_oAccount); await TinkApp.ActiveUser.Login(account);
// Update map page filter because user might be of both groups TINK an Konrad. // Update map page filter because user might be of both groups TINK an Konrad.
TinkApp.GroupFilterMapPage = TinkApp.GroupFilterMapPage =
@ -318,7 +319,8 @@ namespace TINK.ViewModel
{ {
// No need to show "Anleitung TINK Räder" because user can not use tink. // No need to show "Anleitung TINK Räder" because user can not use tink.
#if USEFLYOUT #if USEFLYOUT
m_oViewService.ShowPage(ViewTypes.MapPage);
m_oViewService.ShowPage(account.IsAgbAcknowledged ? ViewTypes.MapPage : ViewTypes.ManageAccountPage);
#else #else
await m_oViewService.ShowPage("//MapPage"); await m_oViewService.ShowPage("//MapPage");
#endif #endif

View file

@ -34,6 +34,10 @@ namespace TINK.ViewModel.Map
{ {
public class MapPageViewModel : INotifyPropertyChanged public class MapPageViewModel : INotifyPropertyChanged
{ {
/// <summary> True if message was already shown to user. </summary>
private static bool WasMerchantMessageAlreadyShown { get; set; } = false;
/// <summary> Holds the count of custom icons availalbe.</summary> /// <summary> Holds the count of custom icons availalbe.</summary>
private const int CUSTOM_ICONS_COUNT = 30; private const int CUSTOM_ICONS_COUNT = 30;
@ -322,6 +326,16 @@ namespace TINK.ViewModel.Map
TinkApp.Stations = resultStationsAndBikes.Response.StationsAll; TinkApp.Stations = resultStationsAndBikes.Response.StationsAll;
if (!string.IsNullOrEmpty(resultStationsAndBikes?.GeneralData?.MerchantMessage)
&& !WasMerchantMessageAlreadyShown)
{
await ViewService.DisplayAlert(
"Information",
resultStationsAndBikes.GeneralData.MerchantMessage,
"OK");
WasMerchantMessageAlreadyShown = true;
}
await SetStationsOnMap(resultStationsAndBikes.Response.StationsAll); await SetStationsOnMap(resultStationsAndBikes.Response.StationsAll);
await HandleAuthCookieNotDefinedException(resultStationsAndBikes.Exception); await HandleAuthCookieNotDefinedException(resultStationsAndBikes.Exception);
@ -677,7 +691,7 @@ namespace TINK.ViewModel.Map
foreach (var stationId in stationsId) foreach (var stationId in stationsId)
{ {
// Get color of given station. // Get color of given station.
var bikesAtStation = bikesAll.Where(x => x.CurrentStation == stationId).ToList(); var bikesAtStation = bikesAll.Where(x => x.StationId == stationId).ToList();
if (bikesAtStation.FirstOrDefault(x => x.State.Value != Model.State.InUseStateEnum.Disposable) != null) if (bikesAtStation.FirstOrDefault(x => x.State.Value != Model.State.InUseStateEnum.Disposable) != null)
{ {
// There is at least one requested or booked bike // There is at least one requested or booked bike

View file

@ -22,11 +22,15 @@ using TINK.Services.Permissions;
using Plugin.BLE.Abstractions.Contracts; using Plugin.BLE.Abstractions.Contracts;
using TINK.MultilingualResources; using TINK.MultilingualResources;
using TINK.Model.Device; using TINK.Model.Device;
using TINK.Model.Station;
namespace TINK.ViewModel.MyBikes namespace TINK.ViewModel.MyBikes
{ {
public class MyBikesPageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged public class MyBikesPageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged
{ {
/// <summary> Holds the stations to get station names form station ids. </summary>
private IEnumerable<IStation> Stations { get; }
/// <summary> /// <summary>
/// Constructs bike collection view model in case information about occupied bikes is available. /// Constructs bike collection view model in case information about occupied bikes is available.
/// </summary> /// </summary>
@ -38,6 +42,7 @@ namespace TINK.ViewModel.MyBikes
/// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param> /// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param>
/// <param name="connectorFactory">Connects system to copri.</param> /// <param name="connectorFactory">Connects system to copri.</param>
/// <param name="lockService">Service to control lock retrieve info.</param> /// <param name="lockService">Service to control lock retrieve info.</param>
/// <param name="stations">Stations to get station name from station id.</param>
/// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param> /// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param>
/// <param name="postAction">Executes actions on GUI thread.</param> /// <param name="postAction">Executes actions on GUI thread.</param>
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param> /// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
@ -51,6 +56,7 @@ namespace TINK.ViewModel.MyBikes
Func<bool, IConnector> connectorFactory, Func<bool, IConnector> connectorFactory,
IGeolocation geolocation, IGeolocation geolocation,
ILocksService lockService, ILocksService lockService,
IEnumerable<IStation> stations,
PollingParameters p_oPolling, PollingParameters p_oPolling,
Action<SendOrPostCallback, object> postAction, Action<SendOrPostCallback, object> postAction,
ISmartDevice smartDevice, ISmartDevice smartDevice,
@ -61,6 +67,8 @@ namespace TINK.ViewModel.MyBikes
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsNoBikesOccupiedVisible))); OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsNoBikesOccupiedVisible)));
OnPropertyChanged(new PropertyChangedEventArgs(nameof(NoBikesOccupiedText))); OnPropertyChanged(new PropertyChangedEventArgs(nameof(NoBikesOccupiedText)));
}; };
Stations = stations ?? throw new ArgumentException(nameof(stations));
} }
/// <summary> Returns if info about the fact that user did not request or book any bikes is visible or not.<summary> /// <summary> Returns if info about the fact that user did not request or book any bikes is visible or not.<summary>
@ -134,7 +142,7 @@ namespace TINK.ViewModel.MyBikes
if (!dialogResult) if (!dialogResult)
{ {
// User decided not to give access to locations permissions. // User decided not to give access to locations permissions.
BikeCollection.Update(bikesOccupied.Response); BikeCollection.Update(bikesOccupied.Response, Stations);
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -156,7 +164,7 @@ namespace TINK.ViewModel.MyBikes
AppResources.MessageBikesManagementLocationActivation, AppResources.MessageBikesManagementLocationActivation,
AppResources.MessageAnswerOk); AppResources.MessageAnswerOk);
BikeCollection.Update(bikesOccupied.Response); BikeCollection.Update(bikesOccupied.Response, Stations);
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -173,7 +181,7 @@ namespace TINK.ViewModel.MyBikes
AppResources.MessageBikesManagementBluetoothActivation, AppResources.MessageBikesManagementBluetoothActivation,
AppResources.MessageAnswerOk); AppResources.MessageAnswerOk);
BikeCollection.Update(bikesOccupied.Response); BikeCollection.Update(bikesOccupied.Response, Stations);
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -200,7 +208,7 @@ namespace TINK.ViewModel.MyBikes
var locksInfo = lockIdList.UpdateById(locksInfoTdo); var locksInfo = lockIdList.UpdateById(locksInfoTdo);
BikeCollection.Update(bikesOccupied.Response.UpdateLockInfo(locksInfo)); BikeCollection.Update(bikesOccupied.Response.UpdateLockInfo(locksInfo), Stations);
await OnAppearing(() => UpdateTask()); await OnAppearing(() => UpdateTask());
@ -251,7 +259,7 @@ namespace TINK.ViewModel.MyBikes
PostAction( PostAction(
unused => unused =>
{ {
BikeCollection.Update(bikes); // Updating collection leads to update of GUI. BikeCollection.Update(bikes, Stations); // Updating collection leads to update of GUI.
Exception = result.Exception; Exception = result.Exception;
ActionText = string.Empty; ActionText = string.Empty;
}, },

View file

@ -158,21 +158,20 @@ namespace TestFramework.Repository
public bool IsConnected => false; public bool IsConnected => false;
/// <summary> Logs user in. </summary> /// <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="p_strDeviceId">Id specifying user and hardware.</param> /// <param name="mailAddress">Mailaddress of user to log in.</param>
/// <param name="p_strMailAddress">Mailaddress of user to log in.</param> /// <param name="password">Password to log in.</param>
/// <param name="p_strPassword">Password to log in.</param>
/// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks> /// <remarks>Response which holds auth cookie <see cref="ResponseBase.authcookie"/></remarks>
public static AuthorizationResponse DoAuthorize( public static AuthorizationResponse DoAuthorize(
string DoAuthResponse, string doAuthResponse,
string p_strMailAddress, string mailAddress,
string p_strPassword, string password,
string p_strDeviceId) string deviceId)
{ {
return p_strMailAddress == "javaminister@gmail.com" return mailAddress == "javaminister@gmail.com"
&& p_strPassword == "*********" && && password == "*********" &&
p_strDeviceId == "HwId1000000000000" deviceId == "HwId1000000000000"
? JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(DoAuthResponse).shareejson ? JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(doAuthResponse).shareejson
: JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(DO_AUTH_Unknown_User_FILE).shareejson; : JsonConvertRethrow.DeserializeObject<ResponseContainer<AuthorizationResponse>>(DO_AUTH_Unknown_User_FILE).shareejson;
} }

View file

@ -45,7 +45,7 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001()), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001()),
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -98,7 +98,7 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new Account("javaminister@gmail.com", "javaminister" /* password */, "4da3044c8657a04ba60e2eaa753bc51a" /* session cookie */, new List<string> { FilterHelper.FILTERTINKGENERAL, FilterHelper.FILTERKONRAD })), new StoreMock(new Account("javaminister@gmail.com", "javaminister" /* password */, "4da3044c8657a04ba60e2eaa753bc51a" /* session cookie */, new List<string> { FilterHelper.FILTERTINKGENERAL, FilterHelper.FILTERKONRAD })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001("6103_112e96b36ba33de245943c5ffaf369cd_")), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001("6103_112e96b36ba33de245943c5ffaf369cd_")),
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -159,7 +159,7 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new Account("mgrimm@gmail.com", "123456789" /* password */, "1234" /* session cookie */, new List<string> { FilterHelper.FILTERTINKGENERAL, FilterHelper.FILTERKONRAD })), new StoreMock(new Account("mgrimm@gmail.com", "123456789" /* password */, "1234" /* session cookie */, new List<string> { FilterHelper.FILTERTINKGENERAL, FilterHelper.FILTERKONRAD })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001()), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001()),
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -214,7 +214,7 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new Account("mgrimm@gmail.com", "123456789" /* password */, "1234" /* session cookie */, new List<string> { FilterHelper.FILTERTINKGENERAL, FilterHelper.FILTERKONRAD })), new StoreMock(new Account("mgrimm@gmail.com", "123456789" /* password */, "1234" /* session cookie */, new List<string> { FilterHelper.FILTERTINKGENERAL, FilterHelper.FILTERKONRAD })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001()), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001()),
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -270,7 +270,7 @@ namespace TestShareeLib.UseCases.Startup
new TINK.Settings.PollingParameters(new TimeSpan(10000), true), new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error), Serilog.Events.LogEventLevel.Error),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)),
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
null, // use default locks service null, // use default locks service
new DeviceMock(), new DeviceMock(),
@ -313,7 +313,7 @@ namespace TestShareeLib.UseCases.Startup
new TINK.Settings.PollingParameters(new TimeSpan(10000), true), new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error), Serilog.Events.LogEventLevel.Error),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)),
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
null, // use default locks service null, // use default locks service
new DeviceMock(), new DeviceMock(),
@ -358,7 +358,7 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(TINK.Services.BluetoothLock.BLE.LockItByGuidService).FullName, activeLockService: typeof(TINK.Services.BluetoothLock.BLE.LockItByGuidService).FullName,
activeGeolocationService: typeof(TINK.Model.Services.Geolocation.LastKnownGeolocationService).FullName), activeGeolocationService: typeof(TINK.Model.Services.Geolocation.LastKnownGeolocationService).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)),
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
null, // use default locks service null, // use default locks service
new DeviceMock(), new DeviceMock(),

View file

@ -19,11 +19,12 @@ namespace TestTINKLib
WheelType? wheelType = null, WheelType? wheelType = null,
TypeOfBike? typeOfBike = null, TypeOfBike? typeOfBike = null,
string description = null, string description = null,
string currentStationId = null, string stationId = null,
string stationName = null,
Uri operatorUri = null, Uri operatorUri = null,
TariffDescription tariffDescription = null, TariffDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null, Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription, dateTimeProvider, stateInfo) IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
{ {
} }
} }
@ -43,7 +44,7 @@ namespace TestTINKLib
Assert.AreEqual(WheelType.Two, l_oBike.WheelType); Assert.AreEqual(WheelType.Two, l_oBike.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBike.TypeOfBike); Assert.AreEqual(TypeOfBike.Cargo, l_oBike.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value); Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value);
Assert.IsNull(l_oBike.CurrentStation); Assert.IsNull(l_oBike.StationId);
l_oBike = new BikeInfoMutable( l_oBike = new BikeInfoMutable(
"17", "17",
@ -59,7 +60,7 @@ namespace TestTINKLib
Assert.AreEqual(WheelType.Mono, l_oBike.WheelType); Assert.AreEqual(WheelType.Mono, l_oBike.WheelType);
Assert.AreEqual(TypeOfBike.Allround, l_oBike.TypeOfBike); Assert.AreEqual(TypeOfBike.Allround, l_oBike.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value); Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value);
Assert.AreEqual("1", l_oBike.CurrentStation); Assert.AreEqual("1", l_oBike.StationId);
} }
[Test] [Test]

View file

@ -24,7 +24,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
public void TestCtorAvailable() public void TestCtorAvailable()
{ {
Assert.AreEqual ("12",new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").Id); Assert.AreEqual ("12",new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").Id);
Assert.AreEqual("13", new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").CurrentStation); Assert.AreEqual("13", new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").StationId);
Assert.AreEqual(InUseStateEnum.Disposable, new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value); Assert.AreEqual(InUseStateEnum.Disposable, new BikeInfo("12", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "13").State.Value);
} }

View file

@ -0,0 +1,18 @@
using NUnit.Framework;
using System;
using TINK.Model.Bike.BluetoothLock;
namespace TestShareeLib.Model.Bike.BluetoothLock
{
[TestFixture]
public class TestBikeInfoMutalbe
{
[Test]
public void TestCtor()
{
Assert.That(
new BikeInfoMutable(new BikeInfo("MyBikeId", 42, new Guid(), "17"), "My Station Name").StationName,
Is.EqualTo("My Station Name"));
}
}
}

View file

@ -4,9 +4,8 @@ using System.Collections.Generic;
using TINK.Model.Bike; using TINK.Model.Bike;
using TINK.Model.Bikes.Bike; using TINK.Model.Bikes.Bike;
using TINK.Model.State; using TINK.Model.State;
using TINK.Model.Station;
using BikeInfo = TINK.Model.Bike.BC.BikeInfo; using BikeInfo = TINK.Model.Bike.BC.BikeInfo;
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
namespace TestTINKLib namespace TestTINKLib
{ {
@ -23,11 +22,12 @@ namespace TestTINKLib
WheelType? wheelType = null, WheelType? wheelType = null,
TypeOfBike? typeOfBike = null, TypeOfBike? typeOfBike = null,
string description = null, string description = null,
string currentStationId = null, string stationId = null,
string stationName = null,
Uri operatorUri = null, Uri operatorUri = null,
TariffDescription tariffDescription = null, TariffDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null, Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription, dateTimeProvider, stateInfo) IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
{ {
} }
} }
@ -62,7 +62,7 @@ namespace TestTINKLib
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById("20").State.Value); Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById("20").State.Value);
Assert.Null(l_oBikeColl.GetById("33")); Assert.Null(l_oBikeColl.GetById("33"));
l_oBikeColl.Update(null); l_oBikeColl.Update(null, null );
// Verify modified state // Verify modified state
Assert.Null(l_oBikeColl.GetById("63")); Assert.Null(l_oBikeColl.GetById("63"));
@ -74,36 +74,114 @@ namespace TestTINKLib
[Test] [Test]
public void TestUpdate() public void TestUpdate()
{ {
var l_oBikeRequested = new BikeInfoMutable("20", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround); var bikeRequested = new BikeInfoMutable("20", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Allround);
l_oBikeRequested.State.Load(new StateInfo(() => DateTime.Now, DateTime.Now, "john@long", "1234")); bikeRequested.State.Load(new StateInfo(() => DateTime.Now, DateTime.Now, "john@long", "1234"));
var l_oBikeColl = new BikeCollectionMutable var bikeColl = new BikeCollectionMutable
{ {
new BikeInfoMutable("63", false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Allround), new BikeInfoMutable("63", false, new List<string> { "TINK" }, WheelType.Two, TypeOfBike.Allround),
new BikeInfoMutable("57", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo), new BikeInfoMutable("57", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo),
l_oBikeRequested, bikeRequested,
}; };
// Verify initial state // Verify initial state
Assert.NotNull(l_oBikeColl.GetById("63")); // Will be removed Assert.NotNull(bikeColl.GetById("63")); // Will be removed
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeColl.GetById("57").State.Value); // Will be requested Assert.AreEqual(InUseStateEnum.Disposable, bikeColl.GetById("57").State.Value); // Will be requested
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById("20").State.Value); // Will be booked Assert.AreEqual(InUseStateEnum.Reserved, bikeColl.GetById("20").State.Value); // Will be booked
Assert.Null(l_oBikeColl.GetById("33")); // Assert.Null(bikeColl.GetById("33")); //
var l_oBikeResponse = new List<BikeInfo> var l_oBikeResponse = new List<BikeInfo>
{ {
new BikeInfo("57", false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7", null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"), new BikeInfo("57" /* bike id*/, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
new BikeInfo("20", false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7", null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"), new BikeInfo("20", false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7", null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
new BikeInfo("33", "7", null /*operator uri*/, null, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround), new BikeInfo("33", "7", null /*operator uri*/, null, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround),
}; };
l_oBikeColl.Update(l_oBikeResponse);
bikeColl.Update(l_oBikeResponse, new List<IStation>());
// Verify modified state // Verify modified state
Assert.Null(l_oBikeColl.GetById("63")); Assert.Null(bikeColl.GetById("63"), "Bike not contained in response must not exist.");
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeColl.GetById("57").State.Value); Assert.AreEqual(InUseStateEnum.Booked, bikeColl.GetById("57").State.Value);
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeColl.GetById("20").State.Value); Assert.AreEqual(InUseStateEnum.Booked, bikeColl.GetById("20").State.Value);
Assert.NotNull(l_oBikeColl.GetById("33")); Assert.NotNull(bikeColl.GetById("33"));
}
/// <summary>
/// Bike for which station name is updated is not contained in bike collection when calling update.
/// </summary>
[Test]
public void TestUpdate_StationName_NewBike()
{
var bikeColl = new BikeCollectionMutable();
// Verify initial state
Assert.That(bikeColl.GetById("57"), Is.Null);
var l_oBikeResponse = new List<BikeInfo>
{
new BikeInfo("57" /* bike id*/, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
};
var stations = new List<IStation>
{
new Station("7", new List<string>(), null, "My facy station")
};
bikeColl.Update(l_oBikeResponse, stations);
// Verify modified state
Assert.That(bikeColl.GetById("57").StationId, Is.EqualTo("7"));
Assert.That(bikeColl.GetById("57").StationName, Is.EqualTo("My facy station"));
}
[Test]
public void TestUpdate_StationName_UpdateExistingBike()
{
var bikeColl = new BikeCollectionMutable
{
new BikeInfoMutable("57", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo),
};
// Verify initial state
Assert.That(bikeColl.GetById("57"), Is.Not.Null);
var bikeResponse = new List<BikeInfo>
{
new BikeInfo("57" /* bike id*/, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
};
var stations = new List<IStation>
{
new Station("7", new List<string>(), null, "My facy station")
};
bikeColl.Update(bikeResponse, stations);
// Verify modified state
Assert.That(bikeColl.GetById("57").StationId, Is.Null, "Station id is only set when update creates BikeInfo object, not when updating object BikeInfo because station name does not change.");
Assert.That(bikeColl.GetById("57").StationName, Is.Null, "Station name is only set when update creates BikeInfo object, not when updating object BikeInfo because station name does not change.");
}
[Test]
public void TestUpdate_StationName_Nullstations()
{
var bikeColl = new BikeCollectionMutable();
var l_oBikeResponse = new List<BikeInfo>
{
new BikeInfo("57" /* bike id*/, false, new List<string> {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"),
};
bikeColl.Update(l_oBikeResponse, null);
// Verify modified state
Assert.That(bikeColl.GetById("57").StationId, Is.EqualTo("7"));
Assert.That(bikeColl.GetById("57").StationName, Is.EqualTo(""));
} }
} }
} }

View file

@ -352,7 +352,7 @@ namespace TestTINKLib.Fixtures.Connector
Assert.That(btBikeReserved.TariffDescription.MaxFeeEuroPerDay, Is.EqualTo(10)); Assert.That(btBikeReserved.TariffDescription.MaxFeeEuroPerDay, Is.EqualTo(10));
Assert.That(btBikeReserved.TariffDescription.Number, Is.EqualTo(5494)); Assert.That(btBikeReserved.TariffDescription.Number, Is.EqualTo(5494));
Assert.That(btBikeReserved.TariffDescription.Name, Is.EqualTo("Tester Basic")); Assert.That(btBikeReserved.TariffDescription.Name, Is.EqualTo("Tester Basic"));
Assert.That(btBikeReserved.CurrentStation, Is.EqualTo("FR_103")); Assert.That(btBikeReserved.StationId, Is.EqualTo("FR_103"));
Assert.That(btBikeReserved.LockInfo.Id, Is.EqualTo(2302373)); Assert.That(btBikeReserved.LockInfo.Id, Is.EqualTo(2302373));
Assert.That(btBikeReserved.OperatorUri.AbsoluteUri, Does.Contain("https://shareeapp-fr01.copri.eu")); Assert.That(btBikeReserved.OperatorUri.AbsoluteUri, Does.Contain("https://shareeapp-fr01.copri.eu"));
Assert.That(btBikeReserved.Group.Count, Is.EqualTo(1)); Assert.That(btBikeReserved.Group.Count, Is.EqualTo(1));
@ -373,7 +373,7 @@ namespace TestTINKLib.Fixtures.Connector
Assert.That(btBikeRented.TariffDescription.MaxFeeEuroPerDay, Is.EqualTo(10)); Assert.That(btBikeRented.TariffDescription.MaxFeeEuroPerDay, Is.EqualTo(10));
Assert.That(btBikeRented.TariffDescription.Number, Is.EqualTo(5494)); Assert.That(btBikeRented.TariffDescription.Number, Is.EqualTo(5494));
Assert.That(btBikeRented.TariffDescription.Name, Is.EqualTo("Tester Basic")); Assert.That(btBikeRented.TariffDescription.Name, Is.EqualTo("Tester Basic"));
Assert.That(btBikeRented.CurrentStation, Is.EqualTo("103")); Assert.That(btBikeRented.StationId, Is.EqualTo("103"));
Assert.That(btBikeRented.LockInfo.Id, Is.EqualTo(2200537)); Assert.That(btBikeRented.LockInfo.Id, Is.EqualTo(2200537));
Assert.That(btBikeRented.OperatorUri.AbsoluteUri, Does.Contain("https://shareeapp-fr01.copri.eu")); Assert.That(btBikeRented.OperatorUri.AbsoluteUri, Does.Contain("https://shareeapp-fr01.copri.eu"));
Assert.That(btBikeRented.Group.Count, Is.EqualTo(1)); Assert.That(btBikeRented.Group.Count, Is.EqualTo(1));
@ -662,23 +662,24 @@ namespace TestTINKLib.Fixtures.Connector
{ {
// Construct requested bike. // Construct requested bike.
var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo( var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo(
"17", "17",
22, 22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"), new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new [] { (byte) 1, (byte)3, (byte)4 }, new [] { (byte) 1, (byte)3, (byte)4 },
new [] { (byte)11, (byte)3, (byte)1 }, new [] { (byte)11, (byte)3, (byte)1 },
new [] { (byte)12, (byte)7, (byte)4 }, new [] { (byte)12, (byte)7, (byte)4 },
DateTime.Now, DateTime.Now,
"a@b", "a@b",
"1", "1",
null, null,
null, null,
() => DateTime.Now, () => DateTime.Now,
false, /*isDemo*/ false, /*isDemo*/
null, /*group*/ null, /*group*/
null, /*wheelType*/ null, /*wheelType*/
null, /*typeOfBike*/ null, /*typeOfBike*/
null /*description*/)); null /*description*/),
"My Station Name");
var response = JsonConvert.DeserializeObject<BikeInfoReservedOrBooked>(@" var response = JsonConvert.DeserializeObject<BikeInfoReservedOrBooked>(@"
{ {
@ -702,16 +703,17 @@ namespace TestTINKLib.Fixtures.Connector
{ {
// Construct occupied bike. // Construct occupied bike.
var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo( var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo(
"17", "17",
22, 22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"), new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new[] { (byte)1, (byte)3, (byte)4 }, new[] { (byte)1, (byte)3, (byte)4 },
new[] { (byte)11, (byte)3, (byte)1 }, new[] { (byte)11, (byte)3, (byte)1 },
new[] { (byte)12, (byte)7, (byte)4 }, new[] { (byte)12, (byte)7, (byte)4 },
DateTime.Now, DateTime.Now,
"a@b", "a@b",
"1", "1",
null /*operator uri*/)); null /*operator uri*/),
"My Station Name");
var response = JsonConvert.DeserializeObject<BikeInfoReservedOrBooked>(@" var response = JsonConvert.DeserializeObject<BikeInfoReservedOrBooked>(@"
{ {
@ -735,23 +737,24 @@ namespace TestTINKLib.Fixtures.Connector
{ {
// Construct requested bike. // Construct requested bike.
var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo( var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo(
"17", "17",
22, 22,
new Guid("0000f00d-1212-efde-1523-785fef13d123"), new Guid("0000f00d-1212-efde-1523-785fef13d123"),
new[] { (byte)1, (byte)3, (byte)4 }, new[] { (byte)1, (byte)3, (byte)4 },
new[] { (byte)11, (byte)3, (byte)1 }, new[] { (byte)11, (byte)3, (byte)1 },
new[] { (byte)12, (byte)7, (byte)4 }, new[] { (byte)12, (byte)7, (byte)4 },
DateTime.Now, DateTime.Now,
"a@b", "a@b",
"1", "1",
null, null,
null, null,
() => DateTime.Now, () => DateTime.Now,
false, /*isDemo*/ false, /*isDemo*/
null, /*group*/ null, /*group*/
null, /*wheelType*/ null, /*wheelType*/
null, /*typeOfBike*/ null, /*typeOfBike*/
null /*description*/)); null /*description*/),
"My Station Name");
Assert.AreEqual(InUseStateEnum.Reserved, bike.State.Value); Assert.AreEqual(InUseStateEnum.Reserved, bike.State.Value);

View file

@ -13,6 +13,7 @@ using Plugin.Permissions.Abstractions;
using TestShareeLib.Repository; using TestShareeLib.Repository;
using TestFramework.Repository; using TestFramework.Repository;
using TINK.Repository;
namespace TestTINKLib.Fixtures.UseCases.Logout namespace TestTINKLib.Fixtures.UseCases.Logout
{ {
@ -42,8 +43,9 @@ namespace TestTINKLib.Fixtures.UseCases.Logout
activeUri: new Uri(CopriServerUriList.TINK_DEVEL)), activeUri: new Uri(CopriServerUriList.TINK_DEVEL)),
accountStore, accountStore,
(isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie) (isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie)
? new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001()) ? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001())
: new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), : new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
device, device,

View file

@ -12,6 +12,7 @@ using TINK.Model.User.Account;
using Plugin.Permissions.Abstractions; using Plugin.Permissions.Abstractions;
using System.Threading.Tasks; using System.Threading.Tasks;
using TestFramework.Repository; using TestFramework.Repository;
using TINK.Repository;
namespace TestShareeLib.UseCases.Login namespace TestShareeLib.UseCases.Login
{ {
@ -28,15 +29,16 @@ namespace TestShareeLib.UseCases.Login
var permissions = Substitute.For<IPermissions>(); var permissions = Substitute.For<IPermissions>();
// No user logged in is initial state to verify. // No user logged in is initial state to verify.
var l_oTinkApp = new TinkApp( var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings( new TINK.Model.Settings.Settings(
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: "NotRelevantActiveGeoloactionServiceName", activeGeolocationService: "NotRelevantActiveGeoloactionServiceName",
activeUri: new Uri(CopriServerUriList.TINK_DEVEL)), activeUri: new Uri(CopriServerUriList.TINK_DEVEL)),
accountStore, accountStore,
(isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie) (isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie)
? new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001()) as IConnector ? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001())
: new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), : new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
device, device,
@ -47,31 +49,32 @@ namespace TestShareeLib.UseCases.Login
currentVersion: new Version(3, 2, 0, 115), currentVersion: new Version(3, 2, 0, 115),
lastVersion: new Version(3, 0, 173) /* Current app version. Must be larger or equal 3.0.173 to lastVersion*/); lastVersion: new Version(3, 0, 173) /* Current app version. Must be larger or equal 3.0.173 to lastVersion*/);
Assert.IsFalse(l_oTinkApp.ActiveUser.IsLoggedIn); // Verifiy initial state.
Assert.IsFalse(tinkApp.ActiveUser.IsLoggedIn);
Assert.AreEqual( Assert.AreEqual(
8, 8,
l_oTinkApp.GetConnector(true).Query.GetBikesAsync().Result.Response.Count, tinkApp.GetConnector(true).Query.GetBikesAsync().Result.Response.Count,
"Sum of bikes is 6 occupied, no one occupied because no user is logged in"); "Sum of bikes is 6 occupied, no one occupied because no user is logged in");
Assert.AreEqual( Assert.AreEqual(
0, 0,
l_oTinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count, tinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count,
"If no user is logged in no occupied bikes are shown."); "If no user is logged in no occupied bikes are shown.");
Assert.IsNull(l_oTinkApp.GetConnector(true).Command.SessionCookie); Assert.IsNull(tinkApp.GetConnector(true).Command.SessionCookie);
// Log user out. // Log in user.
var l_oAccount = l_oTinkApp.GetConnector(true).Command.DoLogin("javaminister@gmail.com", "*********", "HwId1000000000000").Result; var account = tinkApp.GetConnector(true).Command.DoLogin("javaminister@gmail.com", "*********", "HwId1000000000000").Result;
await l_oTinkApp.ActiveUser.Login(l_oAccount); await tinkApp.ActiveUser.Login(account);
Assert.IsTrue(l_oTinkApp.ActiveUser.IsLoggedIn); Assert.IsTrue(tinkApp.ActiveUser.IsLoggedIn);
Assert.AreEqual( Assert.AreEqual(
10, 10,
l_oTinkApp.GetConnector(true).Query.GetBikesAsync().Result.Response.Count, tinkApp.GetConnector(true).Query.GetBikesAsync().Result.Response.Count,
"Sum of bikes is 6 occupied plus 2 occupied."); "Sum of bikes is 6 occupied plus 2 occupied.");
Assert.AreEqual( Assert.AreEqual(
2, 2,
l_oTinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count, tinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count,
"Javaminster occupies 2 bikes."); "Javaminster occupies 2 bikes.");
Assert.AreEqual("6103_112e96b36ba33de245943c5ffaf369cd_", l_oTinkApp.GetConnector(true).Command.SessionCookie); Assert.AreEqual("6103_112e96b36ba33de245943c5ffaf369cd_oiF2kahH", tinkApp.GetConnector(true).Command.SessionCookie);
} }
} }
} }

View file

@ -1,35 +1,34 @@
using NUnit.Framework; using NSubstitute;
using NSubstitute.ExceptionExtensions;
using NUnit.Framework;
using Plugin.BLE.Abstractions.Contracts;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using TestFramework.Model.Device;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Model.User.Account;
using TestFramework.Repository;
using TestFramework.Services.CopriApi.Connector;
using TestFramework.Services.Permissions;
using TINK.Model; using TINK.Model;
using TINK.Model.Connector; using TINK.Model.Connector;
using TINK.Repository.Exception; using TINK.Model.Device;
using TINK.View;
using TINK.Model.Services.CopriApi; using TINK.Model.Services.CopriApi;
using TINK.Model.Services.Geolocation;
using TINK.Repository; using TINK.Repository;
using TINK.Repository.Exception;
using static TINK.Repository.CopriCallsMemory; using TINK.Services;
using TINK.ViewModel.Map;
using TINK.ViewModel.Settings;
using Plugin.BLE.Abstractions.Contracts;
using TINK.Services.BluetoothLock; using TINK.Services.BluetoothLock;
using NSubstitute;
using TINK.ViewModel.BikesAtStation;
using Xamarin.Forms;
using TINK.Services.BluetoothLock.Tdo; using TINK.Services.BluetoothLock.Tdo;
using TINK.Services.Permissions; using TINK.Services.Permissions;
using TINK.Model.Services.Geolocation; using TINK.View;
using NSubstitute.ExceptionExtensions; using TINK.ViewModel.BikesAtStation;
using TINK.Services; using TINK.ViewModel.Map;
using TINK.Model.Device; using TINK.ViewModel.Settings;
using TestFramework.Model.Device; using Xamarin.Forms;
using TestFramework.Repository; using static TINK.Repository.CopriCallsMemory;
using TestFramework.Model.User.Account;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.Permissions;
using TestFramework.Services.CopriApi.Connector;
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
{ {
@ -48,15 +47,16 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp( var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings( new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true), new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("", null, null, new List<string>())), new StoreMock(new TINK.Model.User.Account.Account("", null, false, null, new List<string>())),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -127,8 +127,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -204,8 +205,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, // Instance geolocation mocks both parts geolocation, // Instance geolocation mocks both parts
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -257,8 +259,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1315.StateText);
Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Available.", bike1543.StateText);
Assert.AreEqual("Close lock", bike1545.LockitButtonText); Assert.AreEqual("Close lock", bike1545.LockitButtonText);
@ -296,6 +298,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
} }
); );
bluetooth.State.Returns(BluetoothState.On);
var tinkApp = new TinkApp( var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings( new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }),
@ -305,8 +309,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -363,8 +368,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1315.StateText);
Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Available.", bike1543.StateText);
Assert.AreEqual("Search lock", bike1545.LockitButtonText); Assert.AreEqual("Search lock", bike1545.LockitButtonText);
@ -412,8 +417,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -469,8 +475,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1315.StateText);
Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Available.", bike1543.StateText);
Assert.AreEqual("Search lock", bike1545.LockitButtonText); Assert.AreEqual("Search lock", bike1545.LockitButtonText);
@ -516,8 +522,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -571,8 +578,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1315.StateText);
Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Available.", bike1543.StateText);
Assert.AreEqual("Search lock", bike1545.LockitButtonText); Assert.AreEqual("Search lock", bike1545.LockitButtonText);
@ -618,8 +625,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -674,8 +682,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1315.StateText);
Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Available.", bike1543.StateText);
Assert.AreEqual("Search lock", bike1545.LockitButtonText); Assert.AreEqual("Search lock", bike1545.LockitButtonText);
@ -705,7 +713,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp( var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings( new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true), new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
@ -713,7 +721,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -786,7 +795,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -846,7 +856,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp( var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings( new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true), new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
@ -856,9 +866,11 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
new StoreMock(new TINK.Model.User.Account.Account( new StoreMock(new TINK.Model.User.Account.Account(
LoginSessionCopriInfo.JavaministerHardwareNr1.Mail, LoginSessionCopriInfo.JavaministerHardwareNr1.Mail,
LoginSessionCopriInfo.JavaministerHardwareNr1.Pwd, LoginSessionCopriInfo.JavaministerHardwareNr1.Pwd,
false,
"6103_112e96b36ba33de245943c5ffaf369cd_", // Was 4da3044c8657a04ba60e2eaa753bc51a before switching from data provider CopriCallsMemory(SampleSets.Set2, 1, ...) "6103_112e96b36ba33de245943c5ffaf369cd_", // Was 4da3044c8657a04ba60e2eaa753bc51a before switching from data provider CopriCallsMemory(SampleSets.Set2, 1, ...)
new List<string> { FilterHelper.CARGOBIKE })), new List<string> { FilterHelper.CARGOBIKE })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -899,7 +911,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText); Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText); Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText);
Assert.AreEqual("Max. reservation time of 15 minutes expired.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1004").StateText); Assert.AreEqual("Max. reservation time of 15 minutes expired.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1004").StateText);
Assert.AreEqual("Rented since 06. November 18:57.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1544").StateText); // Was 7 Assert.AreEqual($"Rented since {DateTime.Parse("2021-11-06 18:57:25.445447+01"):dd. MMMM HH:mm}.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1544").StateText); // Was 7
// Login hint/ no bikes frame // Login hint/ no bikes frame
Assert.IsFalse(bikesAtStation.IsLoginRequiredHintVisible); Assert.IsFalse(bikesAtStation.IsLoginRequiredHintVisible);
@ -923,7 +935,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp( var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings( new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true), new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
@ -931,7 +943,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -994,7 +1007,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp( var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings( new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true), new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
@ -1014,6 +1027,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
sessionCookie: sessionCookie, sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))), httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -1079,7 +1093,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp( var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings( new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), new TINK.Settings.PollingParameters(new TimeSpan(10000),
@ -1100,6 +1114,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
sessionCookie: sessionCookie, sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new Exception(msg)))), httpsServer: new ExceptionServer((msg) => new Exception(msg)))),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),

View file

@ -1,20 +0,0 @@
using NUnit.Framework;
using TINK.Model.Bike.BC;
namespace TestTINKLib.Fixtures.ObjectTests.Bike.BC
{
/// <summary>
/// Moved to TestShareeLib (.Net Core)
/// </summary>
[TestFixture]
public class TestBikeInfo
{
[Test]
public void TestCtorCopyNull()
{
Assert.Throws<System.ArgumentException>(
() => new BikeInfo(null),
"Verify that no unspecific reference not set to... exception is thrown");
}
}
}

View file

@ -22,11 +22,12 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
WheelType? wheelType = null, WheelType? wheelType = null,
TypeOfBike? typeOfBike = null, TypeOfBike? typeOfBike = null,
string description = null, string description = null,
string currentStationId = null, string stationId = null,
string stationName = null,
Uri operatorUri = null, Uri operatorUri = null,
TariffDescription tariffDescription = null, TariffDescription tariffDescription = null,
Func<DateTime> dateTimeProvider = null, Func<DateTime> dateTimeProvider = null,
IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, currentStationId, operatorUri, tariffDescription, dateTimeProvider, stateInfo) IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, tariffDescription, dateTimeProvider, stateInfo)
{ {
} }
} }
@ -36,7 +37,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
{ {
var l_oBikeInfo = new BikeInfoMutable("17"); var l_oBikeInfo = new BikeInfoMutable("17");
Assert.AreEqual("17", l_oBikeInfo.Id); Assert.AreEqual("17", l_oBikeInfo.Id);
Assert.IsNull(l_oBikeInfo.CurrentStation); Assert.IsNull(l_oBikeInfo.StationId);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value); Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.AreEqual(null, l_oBikeInfo.WheelType); Assert.AreEqual(null, l_oBikeInfo.WheelType);
Assert.AreEqual(null, l_oBikeInfo.TypeOfBike); Assert.AreEqual(null, l_oBikeInfo.TypeOfBike);
@ -44,7 +45,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
l_oBikeInfo = new BikeInfoMutable("22", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo, "Test description", "23"); l_oBikeInfo = new BikeInfoMutable("22", false, new List<string> { "TINK" }, WheelType.Trike, TypeOfBike.Cargo, "Test description", "23");
Assert.AreEqual("22", l_oBikeInfo.Id); Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.IsFalse(l_oBikeInfo.IsDemo); Assert.IsFalse(l_oBikeInfo.IsDemo);
Assert.AreEqual("23", l_oBikeInfo.CurrentStation); Assert.AreEqual("23", l_oBikeInfo.StationId);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value); Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType); Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike); Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
@ -60,18 +61,19 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
l_oBikeInfoMock.Stub(x => x.Id).Return("22"); l_oBikeInfoMock.Stub(x => x.Id).Return("22");
l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo); l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo);
l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike); l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike);
l_oBikeInfoMock.Stub(x => x.CurrentStation).Return("23"); l_oBikeInfoMock.Stub(x => x.StationId).Return("23");
l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock); l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock);
l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Booked); l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Booked);
l_oStateInfoMock.Stub(x => x.From).Return(new System.DateTime(2018, 01, 03)); l_oStateInfoMock.Stub(x => x.From).Return(new System.DateTime(2018, 01, 03));
l_oStateInfoMock.Stub(x => x.MailAddress).Return("a@b"); l_oStateInfoMock.Stub(x => x.MailAddress).Return("a@b");
l_oStateInfoMock.Stub(x => x.Code).Return("234"); l_oStateInfoMock.Stub(x => x.Code).Return("234");
var l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock); var l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeInfo.State.Value); Assert.AreEqual(InUseStateEnum.Booked, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id); Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.AreEqual("23", l_oBikeInfo.CurrentStation); Assert.AreEqual("23", l_oBikeInfo.StationId);
Assert.AreEqual("My Station Name", l_oBikeInfo.StationName);
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType); Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike); Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Booked, l_oBikeInfo.State.Value); Assert.AreEqual(InUseStateEnum.Booked, l_oBikeInfo.State.Value);
@ -85,18 +87,18 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
l_oBikeInfoMock.Stub(x => x.Id).Return("22"); l_oBikeInfoMock.Stub(x => x.Id).Return("22");
l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo); l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo);
l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike); l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike);
l_oBikeInfoMock.Stub(x => x.CurrentStation).Return("23"); l_oBikeInfoMock.Stub(x => x.StationId).Return("23");
l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock); l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock);
l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Reserved); l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Reserved);
l_oStateInfoMock.Stub(x => x.From).Return(new System.DateTime(2018, 01, 03)); l_oStateInfoMock.Stub(x => x.From).Return(new System.DateTime(2018, 01, 03));
l_oStateInfoMock.Stub(x => x.MailAddress).Return("a@b"); l_oStateInfoMock.Stub(x => x.MailAddress).Return("a@b");
l_oStateInfoMock.Stub(x => x.Code).Return("234"); l_oStateInfoMock.Stub(x => x.Code).Return("234");
l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock); l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeInfo.State.Value); Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id); Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.AreEqual("23", l_oBikeInfo.CurrentStation); Assert.AreEqual("23", l_oBikeInfo.StationId);
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType); Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike); Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeInfo.State.Value); Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeInfo.State.Value);
@ -110,15 +112,15 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike
l_oBikeInfoMock.Stub(x => x.Id).Return("22"); l_oBikeInfoMock.Stub(x => x.Id).Return("22");
l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo); l_oBikeInfoMock.Stub(x => x.TypeOfBike).Return(TypeOfBike.Cargo);
l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike); l_oBikeInfoMock.Stub(x => x.WheelType).Return(WheelType.Trike);
l_oBikeInfoMock.Stub(x => x.CurrentStation).Return("23"); l_oBikeInfoMock.Stub(x => x.StationId).Return("23");
l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock); l_oBikeInfoMock.Stub(x => x.State).Return(l_oStateInfoMock);
l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Disposable); l_oStateInfoMock.Stub(x => x.Value).Return(InUseStateEnum.Disposable);
l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock); l_oBikeInfo = new TINK.Model.Bike.BC.BikeInfoMutable(l_oBikeInfoMock, "My Station Name");
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value); Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);
Assert.AreEqual("22", l_oBikeInfo.Id); Assert.AreEqual("22", l_oBikeInfo.Id);
Assert.AreEqual("23", l_oBikeInfo.CurrentStation); Assert.AreEqual("23", l_oBikeInfo.StationId);
Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType); Assert.AreEqual(WheelType.Trike, l_oBikeInfo.WheelType);
Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike); Assert.AreEqual(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike);
Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value); Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value);

View file

@ -1,5 +1,6 @@
using NUnit.Framework; using NUnit.Framework;
using Rhino.Mocks; using Rhino.Mocks;
using System;
using TINK.Model.Connector; using TINK.Model.Connector;
using TINK.Repository; using TINK.Repository;
@ -18,6 +19,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
// Construct not logged in version of connector. // Construct not logged in version of connector.
var l_oCommand = new ConnectorCache( var l_oCommand = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
"", // Not logged in "", // Not logged in
"", "",
l_oCopri).Command; l_oCopri).Command;
@ -34,6 +36,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
var l_oCopri = MockRepository.GenerateStub<ICopriServer>(); var l_oCopri = MockRepository.GenerateStub<ICopriServer>();
var l_oCommand = new ConnectorCache( var l_oCommand = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
"123", // Logged in "123", // Logged in
"a@b", "a@b",
l_oCopri).Command; l_oCopri).Command;
@ -50,6 +53,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
var l_oCopri = MockRepository.GenerateStub<ICopriServer>(); var l_oCopri = MockRepository.GenerateStub<ICopriServer>();
var l_oQuery = new ConnectorCache( var l_oQuery = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
"", "",
"", "",
l_oCopri).Query; l_oCopri).Query;
@ -66,6 +70,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
var l_oCopri = MockRepository.GenerateStub<ICopriServer>(); var l_oCopri = MockRepository.GenerateStub<ICopriServer>();
var l_oQuery = new ConnectorCache( var l_oQuery = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
"123", "123",
"a@b", "a@b",
l_oCopri).Query; l_oCopri).Query;

View file

@ -5,6 +5,7 @@ using TINK.Model.Connector;
using System.Linq; using System.Linq;
using TINK.Repository; using TINK.Repository;
using TestFramework.Repository; using TestFramework.Repository;
using System;
namespace TestTINKLib.Fixtures.ObjectTests.Connector namespace TestTINKLib.Fixtures.ObjectTests.Connector
{ {
@ -17,6 +18,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
public void TestGetStationsAll() public void TestGetStationsAll()
{ {
var connector = new ConnectorCache( var connector = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
string.Empty, string.Empty,
string.Empty, string.Empty,
new CopriCallsMemory001()); new CopriCallsMemory001());
@ -51,6 +53,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
public void TestGetBikesAll() public void TestGetBikesAll()
{ {
var l_oConnector = new ConnectorCache( var l_oConnector = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
string.Empty, string.Empty,
string.Empty, string.Empty,
new CopriCallsMemory001()); new CopriCallsMemory001());

View file

@ -614,5 +614,56 @@ namespace TestTINKLib.Fixtures.Connector
() => version.GetCopriVersion(), () => version.GetCopriVersion(),
Throws.InstanceOf<InvalidResponseException>()); Throws.InstanceOf<InvalidResponseException>());
} }
[Test]
public void TestGetIsAgbAcknowledged()
{
var response = JsonConvertRethrow.DeserializeObject<AuthorizationResponse>(@"
{
""agb_checked"" : ""1""
}");
Assert.That(
() => response.GetIsAgbAcknowledged(),
Is.True);
}
[Test]
public void TestGetIsAgbAcknowledged_No()
{
var response = JsonConvertRethrow.DeserializeObject<AuthorizationResponse>(@"
{
""agb_checked"" : ""0""
}");
Assert.That(
() => response.GetIsAgbAcknowledged(),
Is.False);
}
[Test]
public void TestGetIsAgbAcknowledged_Invalid()
{
var response = JsonConvertRethrow.DeserializeObject<AuthorizationResponse>(@"
{
""agb_checked"" : ""ä""
}");
Assert.That(
() => response.GetIsAgbAcknowledged(),
Is.False);
}
[Test]
public void TestGetIsAgbAcknowledged_Empty()
{
var response = JsonConvertRethrow.DeserializeObject<AuthorizationResponse>(@"
{
}");
Assert.That(
() => response.GetIsAgbAcknowledged(),
Is.False);
}
} }
} }

View file

@ -14,6 +14,7 @@ namespace UITest.Fixtures.ObjectTests.User.Account
var account = new TINK.Model.User.Account.Account( var account = new TINK.Model.User.Account.Account(
"hans.musterman@hotmail.com", // Mail "hans.musterman@hotmail.com", // Mail
"myPasswd", // Pwd "myPasswd", // Pwd
false,
"aktuellerKeks", // Cookie "aktuellerKeks", // Cookie
new List<string> { "Honkey", "Tonkey" }, // Group new List<string> { "Honkey", "Tonkey" }, // Group
TINK.Model.User.Account.Permissions.None); TINK.Model.User.Account.Permissions.None);
@ -21,6 +22,7 @@ namespace UITest.Fixtures.ObjectTests.User.Account
// Assert // Assert
Assert.AreEqual("hans.musterman@hotmail.com", account.Mail); Assert.AreEqual("hans.musterman@hotmail.com", account.Mail);
Assert.AreEqual("myPasswd", account.Pwd); Assert.AreEqual("myPasswd", account.Pwd);
Assert.That(account.IsAgbAcknowledged, Is.False);
Assert.AreEqual("aktuellerKeks", account.SessionCookie); Assert.AreEqual("aktuellerKeks", account.SessionCookie);
Assert.AreEqual("Honkey,Tonkey", String.Join(",", account.Group)); Assert.AreEqual("Honkey,Tonkey", String.Join(",", account.Group));
Assert.AreEqual(TINK.Model.User.Account.Permissions.None, account.DebugLevel); Assert.AreEqual(TINK.Model.User.Account.Permissions.None, account.DebugLevel);
@ -29,19 +31,26 @@ namespace UITest.Fixtures.ObjectTests.User.Account
[Test] [Test]
public void TestConstruct_Copy() public void TestConstruct_Copy()
{ {
var l_oAccount = new TINK.Model.User.Account.Account(new TINK.Model.User.Account.Account("a@b", "112", "3330", new List<string> { "Honkey", "Tonkey" },TINK.Model.User.Account.Permissions.None)); var account = new TINK.Model.User.Account.Account(new TINK.Model.User.Account.Account(
"a@b",
"112",
true, // Agbs have been acknowledged
"3330",
new List<string> { "Honkey", "Tonkey" },
TINK.Model.User.Account.Permissions.None));
Assert.AreEqual("a@b", l_oAccount.Mail); Assert.AreEqual("a@b", account.Mail);
Assert.AreEqual("112", l_oAccount.Pwd); Assert.AreEqual("112", account.Pwd);
Assert.AreEqual("3330", l_oAccount.SessionCookie); Assert.That(account.IsAgbAcknowledged, Is.False);
Assert.AreEqual("Honkey,Tonkey", String.Join(",", l_oAccount.Group)); Assert.AreEqual("3330", account.SessionCookie);
Assert.AreEqual(TINK.Model.User.Account.Permissions.None, l_oAccount.DebugLevel); Assert.AreEqual("Honkey,Tonkey", String.Join(",", account.Group));
Assert.AreEqual(TINK.Model.User.Account.Permissions.None, account.DebugLevel);
} }
[Test] [Test]
public void TestConstruct_InvalidGroup() public void TestConstruct_InvalidGroup()
{ {
Assert.Throws<ArgumentException>(() => new TINK.Model.User.Account.Account("a@b", "112", "3330", null, TINK.Model.User.Account.Permissions.None)); Assert.Throws<ArgumentException>(() => new TINK.Model.User.Account.Account("a@b", "112", false, "3330", null, TINK.Model.User.Account.Permissions.None));
Assert.Throws<ArgumentException>(() => new TINK.Model.User.Account.Account(null)); Assert.Throws<ArgumentException>(() => new TINK.Model.User.Account.Account(null));
} }

View file

@ -8,6 +8,8 @@ using TINK.Repository;
using static TINK.Repository.CopriCallsMemory; using static TINK.Repository.CopriCallsMemory;
using TestFramework.Model.User.Account; using TestFramework.Model.User.Account;
using System;
using System.Threading.Tasks;
namespace TestTINKLib namespace TestTINKLib
{ {
@ -18,11 +20,11 @@ namespace TestTINKLib
[Test] [Test]
public void TestConstruct_NotLoggedIn_NoUsername() public void TestConstruct_NotLoggedIn_NoUsername()
{ {
var l_oStoreMock = new StoreMock(); // Account without user name, password and cookie var storeMock = new StoreMock(); // Account without user name, password and cookie
var l_oUser = new User( var l_oUser = new User(
l_oStoreMock, storeMock,
l_oStoreMock.Load().Result, storeMock.Load().Result,
"HwId1000000000000"); "HwId1000000000000");
Assert.IsFalse(l_oUser.IsLoggedIn); Assert.IsFalse(l_oUser.IsLoggedIn);
@ -34,23 +36,23 @@ namespace TestTINKLib
[Test] [Test]
public void TestConstruct_NotLoggedIn_NoCookie() public void TestConstruct_NotLoggedIn_NoCookie()
{ {
var l_oStoreMock = new StoreMock(new Account("John", "123", null, new List<string>())); // Account without session cookie. var storeMock = new StoreMock(new Account("John", "123", true, null, new List<string>())); // Account without session cookie.
var l_oUser = new User( var user = new User(
l_oStoreMock, storeMock,
l_oStoreMock.Load().Result, storeMock.Load().Result,
"123456789"); "123456789");
Assert.IsFalse(l_oUser.IsLoggedIn); Assert.IsFalse(user.IsLoggedIn);
Assert.AreEqual("John", l_oUser.Mail); Assert.AreEqual("John", user.Mail);
Assert.AreEqual("123", l_oUser.Password); Assert.AreEqual("123", user.Password);
Assert.IsNull(l_oUser.SessionCookie); Assert.IsNull(user.SessionCookie);
} }
[Test] [Test]
public void TestConstruct_LoggedIn() public void TestConstruct_LoggedIn()
{ {
var l_oStoreMock = new StoreMock(new Account("John", "123", "9512", new List<string> { "TINK" })); var l_oStoreMock = new StoreMock(new Account("John", "123", false, "9512", new List<string> { "TINK" }));
var l_oUser = new User( var l_oUser = new User(
l_oStoreMock, l_oStoreMock,
@ -66,9 +68,10 @@ namespace TestTINKLib
/// <summary>Test logging in. </summary> /// <summary>Test logging in. </summary>
[Test] [Test]
public void TestSetCredentials() public async Task TestSetCredentials()
{ {
var l_oConnector = new ConnectorCache( var l_oConnector = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
string.Empty, string.Empty,
string.Empty, string.Empty,
new CopriCallsMemory(SampleSets.Set2, 1)); new CopriCallsMemory(SampleSets.Set2, 1));
@ -88,7 +91,7 @@ namespace TestTINKLib
LoginSessionCopriInfo.JavaministerHardwareNr1.Pwd, LoginSessionCopriInfo.JavaministerHardwareNr1.Pwd,
l_oUser.DeviceId).Result; l_oUser.DeviceId).Result;
l_oUser.Login(l_oAccount); await l_oUser.Login(l_oAccount);
Assert.IsTrue(l_oUser.IsLoggedIn); Assert.IsTrue(l_oUser.IsLoggedIn);
Assert.AreEqual(LoginSessionCopriInfo.JavaministerHardwareNr1.Mail, l_oUser.Mail); Assert.AreEqual(LoginSessionCopriInfo.JavaministerHardwareNr1.Mail, l_oUser.Mail);

View file

@ -43,7 +43,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -81,8 +82,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "UnknownCookie", new List<string> { "TINK" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "UnknownCookie", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -121,8 +123,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -160,8 +163,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -199,7 +203,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector( (isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector(
uri, uri,
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
@ -212,6 +216,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
sessionCookie: sessionCookie, sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))), httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),

View file

@ -24,7 +24,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
public void TestCreate() public void TestCreate()
{ {
// Verify handler for disposable bike. // Verify handler for disposable bike.
var bike = new BikeInfoMutable(new BikeInfo("22", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "12")); var bike = new BikeInfoMutable(
new BikeInfo("22", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "12"),
"My Station Name");
Assert.AreEqual(InUseStateEnum.Disposable, bike.State.Value); Assert.AreEqual(InUseStateEnum.Disposable, bike.State.Value);
Assert.AreEqual(LockingState.Disconnected, bike.LockInfo.State); Assert.AreEqual(LockingState.Disconnected, bike.LockInfo.State);
Assert.AreEqual( Assert.AreEqual(
@ -42,7 +44,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
MockRepository.GenerateStub<IUser>()).GetType()); MockRepository.GenerateStub<IUser>()).GetType());
// Verify handler for requested bike with state unknown. // Verify handler for requested bike with state unknown.
bike = new BikeInfoMutable(new BikeInfo("22", 0 /* lock Id */, new Guid(), /*K User*/ null, /*K Admin*/ null, /*K Seed*/ null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround)); bike = new BikeInfoMutable(
new BikeInfo("22", 0 /* lock Id */, new Guid(), /*K User*/ null, /*K Admin*/ null, /*K Seed*/ null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround),
"My Station Name");
Assert.AreEqual( Assert.AreEqual(
typeof(ReservedDisconnected), typeof(ReservedDisconnected),
RequestHandlerFactory.Create( RequestHandlerFactory.Create(
@ -58,7 +62,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
MockRepository.GenerateStub<IUser>()).GetType()); MockRepository.GenerateStub<IUser>()).GetType());
// Verify handler for requested bike with state closed. // Verify handler for requested bike with state closed.
bike = new BikeInfoMutable(new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround)); bike = new BikeInfoMutable(
new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround),
"My Station Name");
bike.LockInfo.State = LockingState.Closed; bike.LockInfo.State = LockingState.Closed;
Assert.AreEqual( Assert.AreEqual(
typeof(ReservedClosed), typeof(ReservedClosed),
@ -75,7 +81,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
MockRepository.GenerateStub<IUser>()).GetType()); MockRepository.GenerateStub<IUser>()).GetType());
// Verify handler for requested bike with state open. // Verify handler for requested bike with state open.
bike = new BikeInfoMutable(new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround)); bike = new BikeInfoMutable(
new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new DateTime(2020, 1, 1), "a@b.com", "12", null, null, () => new DateTime(2020, 1, 1), false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround),
"My Station Name");
bike.LockInfo.State = LockingState.Open; bike.LockInfo.State = LockingState.Open;
Assert.AreEqual( Assert.AreEqual(
typeof(ReservedOpen), typeof(ReservedOpen),
@ -92,7 +100,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
MockRepository.GenerateStub<IUser>()).GetType()); MockRepository.GenerateStub<IUser>()).GetType());
// Verify handler for booked bike with state closed. // Verify handler for booked bike with state closed.
bike = new BikeInfoMutable(new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround)); bike = new BikeInfoMutable(
new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround),
"My Station Name");
bike.LockInfo.State = LockingState.Closed; bike.LockInfo.State = LockingState.Closed;
Assert.AreEqual( Assert.AreEqual(
typeof(BookedClosed), typeof(BookedClosed),
@ -109,7 +119,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
MockRepository.GenerateStub<IUser>()).GetType()); MockRepository.GenerateStub<IUser>()).GetType());
// Verify handler for booked bike with state open. // Verify handler for booked bike with state open.
bike = new BikeInfoMutable(new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround)); bike = new BikeInfoMutable(
new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround),
"My Station Name");
bike.LockInfo.State = LockingState.Open; bike.LockInfo.State = LockingState.Open;
Assert.AreEqual( Assert.AreEqual(
typeof(BookedOpen), typeof(BookedOpen),
@ -126,7 +138,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock
MockRepository.GenerateStub<IUser>()).GetType()); MockRepository.GenerateStub<IUser>()).GetType());
// Verify handler for booked bike with state unknown. // Verify handler for booked bike with state unknown.
bike = new BikeInfoMutable(new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround)); bike = new BikeInfoMutable(
new BikeInfo("22", 0 /* lock Id*/, new Guid(), null, null, null, new System.DateTime(2020, 1, 1), "a@b.com", "12", null /*operator uri*/, null, false, new List<string>(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround),
"My Station Name");
Assert.AreEqual( Assert.AreEqual(
typeof(BookedDisconnected), typeof(BookedDisconnected),

View file

@ -43,7 +43,8 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -120,7 +121,8 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -194,7 +196,8 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -263,7 +266,8 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001( sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001( sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -332,7 +336,8 @@ namespace TestShareeLib.UseCases.Startup
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001( sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001( sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -416,6 +421,7 @@ namespace TestShareeLib.UseCases.Startup
sessionCookie: sessionCookie, sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))), httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -500,6 +506,7 @@ namespace TestShareeLib.UseCases.Startup
sessionCookie: sessionCookie, sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new Exception(msg)))), httpsServer: new ExceptionServer((msg) => new Exception(msg)))),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),

View file

@ -24,16 +24,17 @@ namespace UITest.Fixtures.ViewModel
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
{ {
public BikeInfoMutable( public BikeInfoMutable(
string p_iId, string id,
bool p_bIsDemo = false, bool isDemo = false,
IEnumerable<string> p_oGroup = null, IEnumerable<string> group = null,
WheelType? p_eWheelType = null, WheelType? wheelType = null,
TypeOfBike? p_eTypeOfBike = null, TypeOfBike? typeOfBike = null,
string description = null, string description = null,
string p_strCurrentStationName = null, string stationId = null,
string stationName = null,
Uri operatorUri = null, Uri operatorUri = null,
Func<DateTime> p_oDateTimeProvider = null, Func<DateTime> p_oDateTimeProvider = null,
IStateInfo stateInfo = null) : base(p_iId, p_bIsDemo, p_oGroup, p_eWheelType, p_eTypeOfBike, description, p_strCurrentStationName, operatorUri, null, p_oDateTimeProvider, stateInfo) IStateInfo stateInfo = null) : base(id, isDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, null, p_oDateTimeProvider, stateInfo)
{ {
} }
} }
@ -158,7 +159,7 @@ namespace UITest.Fixtures.ViewModel
"ragu@gnu-systems.de", "ragu@gnu-systems.de",
"4asdfA"); "4asdfA");
var l_oStoreMock = new StoreMock(new Account("john@long", "123456789" /* password */, "987654321" /* session cookie */, new List<string> { "TINK" })); var l_oStoreMock = new StoreMock(new Account("john@long", "123456789" /* password */, false, "987654321" /* session cookie */, new List<string> { "TINK" }));
var l_oViewModel = new TINK.ViewModel.Bikes.Bike.BC.BikeViewModel( var l_oViewModel = new TINK.ViewModel.Bikes.Bike.BC.BikeViewModel(
null, null,
@ -196,7 +197,7 @@ namespace UITest.Fixtures.ViewModel
"ragu@gnu-systems.de", "ragu@gnu-systems.de",
"4asdfA"); "4asdfA");
var l_oStoreMock = new StoreMock(new Account("john@long", "123456789" /* password */, "987654321" /* session cookie */, new List<string> { "TINK" })); var l_oStoreMock = new StoreMock(new Account("john@long", "123456789" /* password */, false, "987654321" /* session cookie */, new List<string> { "TINK" }));
var l_oViewModel = new TINK.ViewModel.Bikes.Bike.BC.BikeViewModel( var l_oViewModel = new TINK.ViewModel.Bikes.Bike.BC.BikeViewModel(
null, null,

View file

@ -17,16 +17,17 @@ namespace UITest.Fixtures.ViewModel
private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable
{ {
public BikeInfoMutable( public BikeInfoMutable(
string p_iId, string id,
bool p_bIsDemo = false, bool pisDemo = false,
IEnumerable<string> p_oGroup = null, IEnumerable<string> group = null,
WheelType? p_eWheelType = null, WheelType? wheelType = null,
TypeOfBike? p_eTypeOfBike = null, TypeOfBike? typeOfBike = null,
string description = null, string description = null,
string p_strCurrentStationName = null, string stationId = null,
string stationName = null,
Uri operatorUri = null, Uri operatorUri = null,
Func<DateTime> p_oDateTimeProvider = null, Func<DateTime> p_oDateTimeProvider = null,
IStateInfo stateInfo = null) : base(p_iId, p_bIsDemo, p_oGroup, p_eWheelType, p_eTypeOfBike, description, p_strCurrentStationName, operatorUri, null, p_oDateTimeProvider, stateInfo) IStateInfo stateInfo = null) : base(id, pisDemo, group, wheelType, typeOfBike, description, stationId, stationName, operatorUri, null, p_oDateTimeProvider, stateInfo)
{ {
} }
} }
@ -43,6 +44,7 @@ namespace UITest.Fixtures.ViewModel
TypeOfBike.Cargo, TypeOfBike.Cargo,
"Test description", "Test description",
"3", "3",
"Radstation",
null, null,
() => new DateTime(1980, 1, 1)); // Now time stamp () => new DateTime(1980, 1, 1)); // Now time stamp
@ -52,7 +54,7 @@ namespace UITest.Fixtures.ViewModel
new DateTime(1980, 1, 1), // Date when bike was booked. new DateTime(1980, 1, 1), // Date when bike was booked.
"ragu@gnu-systems.de"); // Owner from Copri. "ragu@gnu-systems.de"); // Owner from Copri.
var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, "987654321" /* session cookie */, new List<string> { "TINK" })); var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, false, "987654321" /* session cookie */, new List<string> { "TINK" }));
var l_oUser = new User( var l_oUser = new User(
l_oStoreMock, l_oStoreMock,
l_oStoreMock.Load().Result, l_oStoreMock.Load().Result,
@ -82,6 +84,7 @@ namespace UITest.Fixtures.ViewModel
TypeOfBike.Cargo, TypeOfBike.Cargo,
"Test description", "Test description",
"3", "3",
"Radstation",
null, null,
() => (new DateTime(1980, 1, 1)).Add(new TimeSpan(0, 8, 0))); () => (new DateTime(1980, 1, 1)).Add(new TimeSpan(0, 8, 0)));
@ -92,7 +95,7 @@ namespace UITest.Fixtures.ViewModel
"ragu@gnu-systems.de", // Owner from Copri. "ragu@gnu-systems.de", // Owner from Copri.
"4asdfA"); // Reservation code from Copri "4asdfA"); // Reservation code from Copri
var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, "987654321" /* session cookie */, new List<string> { "TINK" })); var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, false, "987654321" /* session cookie */, new List<string> { "TINK" }));
var l_oUser = new User( var l_oUser = new User(
l_oStoreMock, // Mocks account store functionality. l_oStoreMock, // Mocks account store functionality.
l_oStoreMock.Load().Result, l_oStoreMock.Load().Result,
@ -124,7 +127,7 @@ namespace UITest.Fixtures.ViewModel
var l_oCopriServer = new CopriCallsMemory(SampleSets.Set1, 1); var l_oCopriServer = new CopriCallsMemory(SampleSets.Set1, 1);
var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, "987654321" /* session cookie */, new List<string> { "TINK" })); var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, false, "987654321" /* session cookie */, new List<string> { "TINK" }));
var l_oUser = new User( var l_oUser = new User(
l_oStoreMock, l_oStoreMock,
l_oStoreMock.Load().Result, l_oStoreMock.Load().Result,

View file

@ -28,7 +28,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
null, // viewUpdateManager null, // viewUpdateManager
NSubstitute.Substitute.For<ISmartDevice>(), NSubstitute.Substitute.For<ISmartDevice>(),
null, // viewService null, // viewService
new TINK.Model.Bike.BC.BikeInfoMutable(new TINK.Model.Bike.BluetoothLock.BikeInfo("42", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42")), new TINK.Model.Bike.BC.BikeInfoMutable(new TINK.Model.Bike.BluetoothLock.BikeInfo("42", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42"), "My Station Name"),
MockRepository.GenerateStub<IUser>(), // user MockRepository.GenerateStub<IUser>(), // user
MockRepository.GenerateStub<IInUseStateInfoProvider>(), MockRepository.GenerateStub<IInUseStateInfoProvider>(),
MockRepository.GenerateStub<IBikesViewModel>()).GetType()); // stateInfoProvider MockRepository.GenerateStub<IBikesViewModel>()).GetType()); // stateInfoProvider
@ -44,7 +44,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
null, // viewUpdateManager null, // viewUpdateManager
NSubstitute.Substitute.For<ISmartDevice>(), NSubstitute.Substitute.For<ISmartDevice>(),
null, // viewService null, // viewService
new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new TINK.Model.Bike.BluetoothLock.BikeInfo("42", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42")), new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new TINK.Model.Bike.BluetoothLock.BikeInfo("42", 5200544, new Guid("00000000-0000-0000-0000-000000000001"), "42"), "My Station Name"),
MockRepository.GenerateStub<IUser>(), // user MockRepository.GenerateStub<IUser>(), // user
MockRepository.GenerateStub<IInUseStateInfoProvider>(), MockRepository.GenerateStub<IInUseStateInfoProvider>(),
MockRepository.GenerateStub<IBikesViewModel>()).GetType()); // stateInfoProvider MockRepository.GenerateStub<IBikesViewModel>()).GetType()); // stateInfoProvider

View file

@ -70,8 +70,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" } )), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" } )),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -93,6 +94,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
geolocation.Active, // geolocation geolocation.Active, // geolocation
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),
@ -117,8 +119,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Close lock", bike1545.LockitButtonText); Assert.AreEqual("Close lock", bike1545.LockitButtonText);
Assert.AreEqual("Open lock & continue renting", bike1537.LockitButtonText); Assert.AreEqual("Open lock & continue renting", bike1537.LockitButtonText);
@ -161,8 +163,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -184,6 +187,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
geolocation.Active, // geolocation geolocation.Active, // geolocation
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),
@ -213,8 +217,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Search lock", bike1545.LockitButtonText); Assert.AreEqual("Search lock", bike1545.LockitButtonText);
Assert.AreEqual("Search lock", bike1537.LockitButtonText); Assert.AreEqual("Search lock", bike1537.LockitButtonText);
@ -260,8 +264,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -283,6 +288,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
geolocation.Active, // geolocation geolocation.Active, // geolocation
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),
@ -311,8 +317,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Search lock", bike1545.LockitButtonText); Assert.AreEqual("Search lock", bike1545.LockitButtonText);
Assert.AreEqual("Search lock", bike1537.LockitButtonText); Assert.AreEqual("Search lock", bike1537.LockitButtonText);
@ -354,8 +360,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -377,6 +384,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
geolocation.Active, // geolocation geolocation.Active, // geolocation
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),
@ -403,8 +411,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Search lock", bike1545.LockitButtonText); Assert.AreEqual("Search lock", bike1545.LockitButtonText);
Assert.AreEqual("Search lock", bike1537.LockitButtonText); Assert.AreEqual("Search lock", bike1537.LockitButtonText);
@ -446,8 +454,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List<string> { "300001", "300029" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
"MyMerchId",
geolocation, geolocation,
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -469,6 +478,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
geolocation.Active, // geolocation geolocation.Active, // geolocation
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),
@ -499,8 +509,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1545 = myBikes.FirstOrDefault(x => x.Id == "1545") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; var bike1537 = myBikes.FirstOrDefault(x => x.Id == "1537") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
Assert.AreEqual("Rented since 06. November 17:53.", bike1545.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-11-06 17:53:22.784681+01"):dd. MMMM HH:mm}.", bike1545.StateText);
Assert.AreEqual("Rented since 12. October 08:38.", bike1537.StateText); Assert.AreEqual($"Rented since {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText);
Assert.AreEqual("Search lock", bike1545.LockitButtonText); Assert.AreEqual("Search lock", bike1545.LockitButtonText);
Assert.AreEqual("Search lock", bike1537.LockitButtonText); Assert.AreEqual("Search lock", bike1537.LockitButtonText);
@ -532,8 +542,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "Invalid_SessionCookie", new List<string> { "TINK" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "Invalid_SessionCookie", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -555,6 +566,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(), new GeolocationMock(),
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),
@ -593,8 +605,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "TINK" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -616,6 +629,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(), new GeolocationMock(),
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),
@ -657,7 +671,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "TINK" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector( (isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector(
uri, uri,
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
@ -670,6 +684,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
sessionCookie: sessionCookie, sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie), cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))), httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -691,6 +706,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(), new GeolocationMock(),
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),
@ -735,7 +751,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Serilog.Events.LogEventLevel.Error, Serilog.Events.LogEventLevel.Error,
activeLockService: locksService.GetType().FullName, activeLockService: locksService.GetType().FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "TINK" })), new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector( (isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector(
uri, uri,
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
@ -748,6 +764,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
sessionCookie: sessionCookie, sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie), cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new Exception(msg)))), httpsServer: new ExceptionServer((msg) => new Exception(msg)))),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
locksService, locksService,
new DeviceMock(), new DeviceMock(),
@ -769,6 +786,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
(isConnected) => tinkApp.GetConnector(isConnected), (isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(), new GeolocationMock(),
locksService, locksService,
tinkApp.Stations,
tinkApp.Polling, tinkApp.Polling,
(d, obj) => d(obj), (d, obj) => d(obj),
Substitute.For<ISmartDevice>(), Substitute.For<ISmartDevice>(),

View file

@ -27,7 +27,8 @@ namespace TestTINKLib.Fixtures.UseCases.ConnectedOffline
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)),
"MyMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),

View file

@ -25,6 +25,7 @@ namespace TestTINKLib.Fixtures.UseCases.SelectStation
public void TestBikesAtStation_AccountStoreMock_NoUser_CopriMock_Set2() public void TestBikesAtStation_AccountStoreMock_NoUser_CopriMock_Set2()
{ {
var l_oConnector = new ConnectorCache( var l_oConnector = new ConnectorCache(
new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)),
string.Empty, string.Empty,
string.Empty, string.Empty,
new CopriCallsMemory(SampleSets.Set2, 1)); new CopriCallsMemory(SampleSets.Set2, 1));
@ -39,7 +40,8 @@ namespace TestTINKLib.Fixtures.UseCases.SelectStation
activeLockService: typeof(LocksServiceMock).FullName, activeLockService: typeof(LocksServiceMock).FullName,
activeGeolocationService: typeof(GeolocationMock).FullName), activeGeolocationService: typeof(GeolocationMock).FullName),
new StoreMock(), new StoreMock(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)), (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)),
"myMerchId",
Substitute.For<IServicesContainer<IGeolocation>>(), Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(), new LocksServiceMock(),
new DeviceMock(), new DeviceMock(),
@ -50,25 +52,25 @@ namespace TestTINKLib.Fixtures.UseCases.SelectStation
currentVersion: new Version(3, 2, 0, 115), currentVersion: new Version(3, 2, 0, 115),
lastVersion: new Version(3, 0, 173)); // Current app version. Must be larger or equal 3.0.173 to lastVersion: new Version(3, 0, 173)); // Current app version. Must be larger or equal 3.0.173 to
Assert.AreEqual(0, TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.SelectedStation.Id).Result.Count); Assert.AreEqual(0, TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.Stations, l_oTinkApp.SelectedStation.Id).Result.Count);
l_oTinkApp.SelectedStation = new TINK.Model.Station.Station("5", new List<string>(), null); l_oTinkApp.SelectedStation = new TINK.Model.Station.Station("5", new List<string>(), null);
Assert.AreEqual(3, TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.SelectedStation.Id).Result.Count); Assert.AreEqual(3, TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.Stations, l_oTinkApp.SelectedStation.Id).Result.Count);
Assert.AreEqual("25", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.SelectedStation.Id).Result.GetById("25").Id); Assert.AreEqual("25", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.Stations, l_oTinkApp.SelectedStation.Id).Result.GetById("25").Id);
Assert.AreEqual("11", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.SelectedStation.Id).Result.GetById("11").Id); Assert.AreEqual("11", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.Stations, l_oTinkApp.SelectedStation.Id).Result.GetById("11").Id);
Assert.AreEqual("2", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.SelectedStation.Id).Result.GetById("2").Id); Assert.AreEqual("2", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.Stations, l_oTinkApp.SelectedStation.Id).Result.GetById("2").Id);
l_oTinkApp.SelectedStation = new TINK.Model.Station.Station("10", new List<string>(), null); l_oTinkApp.SelectedStation = new TINK.Model.Station.Station("10", new List<string>(), null);
Assert.AreEqual( Assert.AreEqual(
1, 1,
TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.SelectedStation.Id).Result.Count); TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.Stations, l_oTinkApp.SelectedStation.Id).Result.Count);
Assert.AreEqual("18", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.SelectedStation.Id).Result.GetById("18").Id); Assert.AreEqual("18", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.Stations, l_oTinkApp.SelectedStation.Id).Result.GetById("18").Id);
l_oTinkApp.SelectedStation = new TINK.Model.Station.Station("91345", new List<string>(), null); l_oTinkApp.SelectedStation = new TINK.Model.Station.Station("91345", new List<string>(), null);
Assert.AreEqual(0, TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.SelectedStation.Id).Result.Count); Assert.AreEqual(0, TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, l_oTinkApp.Stations, l_oTinkApp.SelectedStation.Id).Result.Count);
} }
} }
} }

View file

@ -1,7 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using TINK.Model; using TINK.Model;
using TINK.Model.Bike; using TINK.Model.Bike;
using TINK.Model.Station;
using TINK.Model.User; using TINK.Model.User;
namespace TestTINKLib.Fixtures.UseCases namespace TestTINKLib.Fixtures.UseCases
@ -14,13 +16,14 @@ namespace TestTINKLib.Fixtures.UseCases
public static async Task<BikeCollectionMutable> GetBikesAtStation( public static async Task<BikeCollectionMutable> GetBikesAtStation(
User user, User user,
TINK.Model.Connector.IConnector connector, TINK.Model.Connector.IConnector connector,
string selectedStation) IEnumerable<IStation> stations,
string selectedStationId)
{ {
var l_oBikesAtStation = new BikeCollectionMutable(); var l_oBikesAtStation = new BikeCollectionMutable();
var l_oBikesAvailable = (await connector.Query.GetBikesAsync()).Response; var l_oBikesAvailable = (await connector.Query.GetBikesAsync()).Response;
l_oBikesAtStation.Update(l_oBikesAvailable.GetAtStation(selectedStation)); l_oBikesAtStation.Update(l_oBikesAvailable.GetAtStation(selectedStationId), stations);
return l_oBikesAtStation; return l_oBikesAtStation;
} }

View file

@ -47,7 +47,6 @@
<Compile Include="Fixtures\ObjectTests\Services\TestServicesContainerMutable.cs" /> <Compile Include="Fixtures\ObjectTests\Services\TestServicesContainerMutable.cs" />
<Compile Include="Fixtures\ObjectTests\Settings\BluetoothLock\TestLockIt.cs" /> <Compile Include="Fixtures\ObjectTests\Settings\BluetoothLock\TestLockIt.cs" />
<Compile Include="Fixtures\ObjectTests\ViewModel\Account\TestAccountPageViewModel.cs" /> <Compile Include="Fixtures\ObjectTests\ViewModel\Account\TestAccountPageViewModel.cs" />
<None Include="Fixtures\ObjectTests\Bike\BC\TestBikeInfo.cs" />
<None Include="Fixtures\ObjectTests\Bike\BluetoothLock\TestBikeInfo.cs" /> <None Include="Fixtures\ObjectTests\Bike\BluetoothLock\TestBikeInfo.cs" />
<None Include="Fixtures\ObjectTests\Bike\BluetoothLock\TestLockInfo.cs" /> <None Include="Fixtures\ObjectTests\Bike\BluetoothLock\TestLockInfo.cs" />
<None Include="Fixtures\ObjectTests\Bike\BluetoothLock\TestLockInfoHelper.cs" /> <None Include="Fixtures\ObjectTests\Bike\BluetoothLock\TestLockInfoHelper.cs" />
@ -107,7 +106,6 @@
<Compile Include="Fixtures\ObjectTests\ViewModel\Settings\TestFilterCollectionMutable.cs" /> <Compile Include="Fixtures\ObjectTests\ViewModel\Settings\TestFilterCollectionMutable.cs" />
<Compile Include="Fixtures\ObjectTests\ViewModel\TestBikeAtStationInUseStateInfoProvider.cs" /> <Compile Include="Fixtures\ObjectTests\ViewModel\TestBikeAtStationInUseStateInfoProvider.cs" />
<Compile Include="Fixtures\ObjectTests\ViewModel\TestBikeAtStationViewModel.cs" /> <Compile Include="Fixtures\ObjectTests\ViewModel\TestBikeAtStationViewModel.cs" />
<Compile Include="Fixtures\ObjectTests\ViewModel\TestBikesAtStationPageViewModel.cs" />
<Compile Include="Fixtures\ObjectTests\ViewModel\TestBikeViewModel.cs" /> <Compile Include="Fixtures\ObjectTests\ViewModel\TestBikeViewModel.cs" />
<Compile Include="Fixtures\ObjectTests\ViewModel\TestBikeViewModelFactory.cs" /> <Compile Include="Fixtures\ObjectTests\ViewModel\TestBikeViewModelFactory.cs" />
<Compile Include="Fixtures\ObjectTests\ViewModel\TestMyBikeInUseStateInfoProvider.cs" /> <Compile Include="Fixtures\ObjectTests\ViewModel\TestMyBikeInUseStateInfoProvider.cs" />
@ -116,7 +114,6 @@
<Compile Include="Fixtures\ObjectTests\ViewModel\TestViewModelHelper.cs" /> <Compile Include="Fixtures\ObjectTests\ViewModel\TestViewModelHelper.cs" />
<Compile Include="Fixtures\UseCases\ConnectedOffline\TestTinkApp.cs" /> <Compile Include="Fixtures\UseCases\ConnectedOffline\TestTinkApp.cs" />
<Compile Include="Fixtures\UseCases\TestHelper.cs" /> <Compile Include="Fixtures\UseCases\TestHelper.cs" />
<Compile Include="LoginSessionCopriInfo.cs" />
<None Include="Fixtures\ObjectTests\Bike\TestBikeSerializeJSON.cs" /> <None Include="Fixtures\ObjectTests\Bike\TestBikeSerializeJSON.cs" />
<None Include="Fixtures\ObjectTests\Bike\TestBikeCollectionSerializeJSON.cs" /> <None Include="Fixtures\ObjectTests\Bike\TestBikeCollectionSerializeJSON.cs" />
<None Include="Fixtures\ObjectTests\Bike\TestStateBookedInfoSerializeJSON.cs" /> <None Include="Fixtures\ObjectTests\Bike\TestStateBookedInfoSerializeJSON.cs" />