diff --git a/LastenradBayern/TINK.Android/Properties/AndroidManifest.xml b/LastenradBayern/TINK.Android/Properties/AndroidManifest.xml index 491c5b2..e16ee5e 100644 --- a/LastenradBayern/TINK.Android/Properties/AndroidManifest.xml +++ b/LastenradBayern/TINK.Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/LastenradBayern/TINK.iOS/Info.plist b/LastenradBayern/TINK.iOS/Info.plist index 1bb444a..56e7e0b 100644 --- a/LastenradBayern/TINK.iOS/Info.plist +++ b/LastenradBayern/TINK.iOS/Info.plist @@ -49,8 +49,8 @@ CFBundleDisplayName LastenradBayern CFBundleVersion - 267 + 270 CFBundleShortVersionString - 3.0.267 + 3.0.270 diff --git a/LastenradBayern/TINK/App.xaml.cs b/LastenradBayern/TINK/App.xaml.cs index b9d79be..a5e8ad7 100644 --- a/LastenradBayern/TINK/App.xaml.cs +++ b/LastenradBayern/TINK/App.xaml.cs @@ -141,12 +141,15 @@ namespace TINK var appInfoService = DependencyService.Get(); + const string MERCHANTID = "baei987w"; + // Create new app instnace. Log.Debug("Constructing main model..."); m_oModelRoot = new TinkApp( settings, 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, null, /* locksService */ DependencyService.Get(), diff --git a/LastenradBayern/TINK/View/CopriWebView/RegisterPage.xaml.cs b/LastenradBayern/TINK/View/CopriWebView/RegisterPage.xaml.cs index b953a13..61fc10b 100644 --- a/LastenradBayern/TINK/View/CopriWebView/RegisterPage.xaml.cs +++ b/LastenradBayern/TINK/View/CopriWebView/RegisterPage.xaml.cs @@ -26,6 +26,7 @@ namespace TINK.View.CopriWebView }; RegisterView.BindingContext = new RegisterPageViewModel( + Model.TinkApp.MerchantId, App.ModelRoot.NextActiveUri.Host); } diff --git a/LastenradBayern/TINK/View/FindBike/FindBikePage.xaml.cs b/LastenradBayern/TINK/View/FindBike/FindBikePage.xaml.cs index 3d667fc..5f10035 100644 --- a/LastenradBayern/TINK/View/FindBike/FindBikePage.xaml.cs +++ b/LastenradBayern/TINK/View/FindBike/FindBikePage.xaml.cs @@ -47,6 +47,7 @@ namespace TINK.View.FindBike (isConnected) => model.GetConnector(isConnected), App.GeolocationServicesContainer.Active, model.LocksServices.Active, + model.Stations, model.Polling, (d, obj) => synchronizationContext.Post(d, obj), model.SmartDevice, diff --git a/LastenradBayern/TINK/View/MyBikes/MyBikesPage.xaml.cs b/LastenradBayern/TINK/View/MyBikes/MyBikesPage.xaml.cs index 6df7bb8..38e220b 100644 --- a/LastenradBayern/TINK/View/MyBikes/MyBikesPage.xaml.cs +++ b/LastenradBayern/TINK/View/MyBikes/MyBikesPage.xaml.cs @@ -64,6 +64,7 @@ namespace TINK.View.MyBikes (isConnected) => model.GetConnector(isConnected), App.GeolocationServicesContainer.Active, model.LocksServices.Active, + model.Stations, model.Polling, (d, obj) => synchronizationContext.Post(d, obj), model.SmartDevice, diff --git a/Meinkonrad/TINK.Android/Properties/AndroidManifest.xml b/Meinkonrad/TINK.Android/Properties/AndroidManifest.xml index bfdb36d..9782529 100644 --- a/Meinkonrad/TINK.Android/Properties/AndroidManifest.xml +++ b/Meinkonrad/TINK.Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/Meinkonrad/TINK.iOS/Info.plist b/Meinkonrad/TINK.iOS/Info.plist index b89da58..3f16150 100644 --- a/Meinkonrad/TINK.iOS/Info.plist +++ b/Meinkonrad/TINK.iOS/Info.plist @@ -49,8 +49,8 @@ CFBundleDisplayName Mein konrad CFBundleVersion - 267 + 270 CFBundleShortVersionString - 3.0.267 + 3.0.270 diff --git a/Meinkonrad/TINK/App.xaml.cs b/Meinkonrad/TINK/App.xaml.cs index 2a03aaa..5ec0192 100644 --- a/Meinkonrad/TINK/App.xaml.cs +++ b/Meinkonrad/TINK/App.xaml.cs @@ -140,12 +140,15 @@ namespace TINK var appInfoService = DependencyService.Get(); + const string MERCHANTID = "mkef9BuN"; + // Create new app instnace. Log.Debug("Constructing main model..."); m_oModelRoot = new TinkApp( settings, 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, null, /* locksService */ DependencyService.Get(), diff --git a/Meinkonrad/TINK/View/CopriWebView/RegisterPage.xaml.cs b/Meinkonrad/TINK/View/CopriWebView/RegisterPage.xaml.cs index b953a13..61fc10b 100644 --- a/Meinkonrad/TINK/View/CopriWebView/RegisterPage.xaml.cs +++ b/Meinkonrad/TINK/View/CopriWebView/RegisterPage.xaml.cs @@ -26,6 +26,7 @@ namespace TINK.View.CopriWebView }; RegisterView.BindingContext = new RegisterPageViewModel( + Model.TinkApp.MerchantId, App.ModelRoot.NextActiveUri.Host); } diff --git a/Meinkonrad/TINK/View/FindBike/FindBikePage.xaml.cs b/Meinkonrad/TINK/View/FindBike/FindBikePage.xaml.cs index 11c1db2..91ce74c 100644 --- a/Meinkonrad/TINK/View/FindBike/FindBikePage.xaml.cs +++ b/Meinkonrad/TINK/View/FindBike/FindBikePage.xaml.cs @@ -47,6 +47,7 @@ namespace TINK.View.FindBike (isConnected) => model.GetConnector(isConnected), App.GeolocationServicesContainer.Active, model.LocksServices.Active, + model.Stations, model.Polling, (d, obj) => synchronizationContext.Post(d, obj), model.SmartDevice, diff --git a/Meinkonrad/TINK/View/MyBikes/MyBikesPage.xaml.cs b/Meinkonrad/TINK/View/MyBikes/MyBikesPage.xaml.cs index 6df7bb8..38e220b 100644 --- a/Meinkonrad/TINK/View/MyBikes/MyBikesPage.xaml.cs +++ b/Meinkonrad/TINK/View/MyBikes/MyBikesPage.xaml.cs @@ -64,6 +64,7 @@ namespace TINK.View.MyBikes (isConnected) => model.GetConnector(isConnected), App.GeolocationServicesContainer.Active, model.LocksServices.Active, + model.Stations, model.Polling, (d, obj) => synchronizationContext.Post(d, obj), model.SmartDevice, diff --git a/TINK/TINK.Android/Properties/AndroidManifest.xml b/TINK/TINK.Android/Properties/AndroidManifest.xml index 7845cfa..1efe0fb 100644 --- a/TINK/TINK.Android/Properties/AndroidManifest.xml +++ b/TINK/TINK.Android/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/TINK/TINK.iOS/Info.plist b/TINK/TINK.iOS/Info.plist index 4cbd259..3bbe60b 100644 --- a/TINK/TINK.iOS/Info.plist +++ b/TINK/TINK.iOS/Info.plist @@ -49,8 +49,8 @@ CFBundleDisplayName sharee.bike CFBundleVersion - 267 + 270 CFBundleShortVersionString - 3.0.267 + 3.0.270 diff --git a/TINK/TINK/App.xaml.cs b/TINK/TINK/App.xaml.cs index c71c2f3..e8d2834 100644 --- a/TINK/TINK/App.xaml.cs +++ b/TINK/TINK/App.xaml.cs @@ -140,12 +140,15 @@ namespace TINK var appInfoService = DependencyService.Get(); + const string MERCHANTID = "oiF2kahH"; + // Create new app instnace. Log.Debug("Constructing main model..."); m_oModelRoot = new TinkApp( settings, 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, null, /* locksService */ DependencyService.Get(), diff --git a/TINK/TINK/View/CopriWebView/RegisterPage.xaml.cs b/TINK/TINK/View/CopriWebView/RegisterPage.xaml.cs index b953a13..61fc10b 100644 --- a/TINK/TINK/View/CopriWebView/RegisterPage.xaml.cs +++ b/TINK/TINK/View/CopriWebView/RegisterPage.xaml.cs @@ -26,6 +26,7 @@ namespace TINK.View.CopriWebView }; RegisterView.BindingContext = new RegisterPageViewModel( + Model.TinkApp.MerchantId, App.ModelRoot.NextActiveUri.Host); } diff --git a/TINK/TINK/View/FindBike/FindBikePage.xaml.cs b/TINK/TINK/View/FindBike/FindBikePage.xaml.cs index 3d667fc..5f10035 100644 --- a/TINK/TINK/View/FindBike/FindBikePage.xaml.cs +++ b/TINK/TINK/View/FindBike/FindBikePage.xaml.cs @@ -47,6 +47,7 @@ namespace TINK.View.FindBike (isConnected) => model.GetConnector(isConnected), App.GeolocationServicesContainer.Active, model.LocksServices.Active, + model.Stations, model.Polling, (d, obj) => synchronizationContext.Post(d, obj), model.SmartDevice, diff --git a/TINK/TINK/View/MyBikes/MyBikesPage.xaml.cs b/TINK/TINK/View/MyBikes/MyBikesPage.xaml.cs index 6df7bb8..38e220b 100644 --- a/TINK/TINK/View/MyBikes/MyBikesPage.xaml.cs +++ b/TINK/TINK/View/MyBikes/MyBikesPage.xaml.cs @@ -64,6 +64,7 @@ namespace TINK.View.MyBikes (isConnected) => model.GetConnector(isConnected), App.GeolocationServicesContainer.Active, model.LocksServices.Active, + model.Stations, model.Polling, (d, obj) => synchronizationContext.Post(d, obj), model.SmartDevice, diff --git a/TINKLib/Model/Bikes/Bike/BC/BikeInfo.cs b/TINKLib/Model/Bikes/Bike/BC/BikeInfo.cs index bc7536c..8a3c841 100644 --- a/TINKLib/Model/Bikes/Bike/BC/BikeInfo.cs +++ b/TINKLib/Model/Bikes/Bike/BC/BikeInfo.cs @@ -27,7 +27,7 @@ namespace TINK.Model.Bike.BC WheelType? wheelType = null, TypeOfBike? typeOfBike = null, string description = null, - string currentStationId = null, + string stationId = null, Uri operatorUri = null, TariffDescription tariffDescription = null) { @@ -37,7 +37,7 @@ namespace TINK.Model.Bike.BC IsDemo = isDemo ?? DEFAULTVALUEISDEMO; Group = group ?? new List(); - CurrentStation = currentStationId; + StationId = stationId; OperatorUri = operatorUri; TariffDescription = tariffDescription; } @@ -50,7 +50,7 @@ namespace TINK.Model.Bike.BC bikeInfo.WheelType, bikeInfo.TypeOfBike, bikeInfo.Description, - bikeInfo.CurrentStation, + bikeInfo.StationId, bikeInfo.OperatorUri, bikeInfo.TariffDescription) { } @@ -58,13 +58,13 @@ namespace TINK.Model.Bike.BC /// Constructs a bike info object for a available bike. /// /// Unique id of bike. - /// Id of station where bike is located. + /// Id of station where bike is located. /// Holds the uri of the operator or null, in case of single operator setup. /// Hold tariff description of bike. /// public BikeInfo( string id, - string currentStationId, + string stationId, Uri operatorUri = null, TariffDescription tariffDescription = null, bool? isDemo = DEFAULTVALUEISDEMO, @@ -79,7 +79,7 @@ namespace TINK.Model.Bike.BC wheelType, typeOfBike, description, - currentStationId, + stationId, operatorUri, tariffDescription) { @@ -179,7 +179,7 @@ namespace TINK.Model.Bike.BC /// /// Station a which bike is located, null otherwise. /// - public string CurrentStation { get; } + public string StationId { get; } /// Holds description about the tarif. public TariffDescription TariffDescription { get; } @@ -210,7 +210,7 @@ namespace TINK.Model.Bike.BC /// 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}."; } } } diff --git a/TINKLib/Model/Bikes/Bike/BC/BikeInfoMutable.cs b/TINKLib/Model/Bikes/Bike/BC/BikeInfoMutable.cs index 16f8654..1798729 100644 --- a/TINKLib/Model/Bikes/Bike/BC/BikeInfoMutable.cs +++ b/TINKLib/Model/Bikes/Bike/BC/BikeInfoMutable.cs @@ -24,7 +24,7 @@ namespace TINK.Model.Bike.BC /// True if device is demo device, false otherwise. /// Provider for current date time to calculate remainig time on demand for state of type reserved. /// - /// Name of station where bike is located, null if bike is on the road. + /// Name of station where bike is located, null if bike is on the road. /// Holds the uri of the operator or null, in case of single operator setup. /// Hold tariff description of bike. /// Bike state info. @@ -35,7 +35,8 @@ namespace TINK.Model.Bike.BC WheelType? wheelType = null, TypeOfBike? typeOfBike = null, string description = null, - string currentStationId = null, + string stationId = null, + string stationName = null, Uri operatorUri = null, TariffDescription tariffDescription = null, Func dateTimeProvider = null, @@ -46,32 +47,36 @@ namespace TINK.Model.Bike.BC m_oBike = new Bike(id, wheelType, typeOfBike, description); m_oStateInfo = new StateInfoMutable(dateTimeProvider, stateInfo); m_oStateInfo.PropertyChanged += (sender, eventargs) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(eventargs.PropertyName)); - CurrentStation = currentStationId; + StationId = stationId; + StationName = stationName; OperatorUri = operatorUri; TariffDescription = tariffDescription; } /// Constructs a bike object from source. - public BikeInfoMutable(IBikeInfo p_oBike) : this( - p_oBike.Id, - p_oBike.IsDemo, - p_oBike.Group, - p_oBike.WheelType, - p_oBike.TypeOfBike, - p_oBike.Description, - p_oBike.CurrentStation, - p_oBike.OperatorUri, - p_oBike.TariffDescription, + public BikeInfoMutable(IBikeInfo bike, string stationName) : this( + bike.Id, + bike.IsDemo, + bike.Group, + bike.WheelType, + bike.TypeOfBike, + bike.Description, + bike.StationId, + stationName, + bike.OperatorUri, + bike.TariffDescription, null, - p_oBike.State) + bike.State) { } - /// - /// Station a which bike is located, null otherwise. - /// + /// Id of station a which bike is located, null otherwise. [DataMember] - public string CurrentStation { get; } + public string StationId { get; } + + /// Name of station a which bike is located, null otherwise. + [DataMember] + public string StationName { get; } /// Holds description about the tarif. [DataMember] @@ -118,7 +123,7 @@ namespace TINK.Model.Bike.BC /// 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")}."; } } } diff --git a/TINKLib/Model/Bikes/Bike/BC/IBikeInfo.cs b/TINKLib/Model/Bikes/Bike/BC/IBikeInfo.cs index cc02d31..736b11d 100644 --- a/TINKLib/Model/Bikes/Bike/BC/IBikeInfo.cs +++ b/TINKLib/Model/Bikes/Bike/BC/IBikeInfo.cs @@ -37,7 +37,7 @@ namespace TINK.Model.Bike.BC /// /// Station a which bike is located, null otherwise. /// - string CurrentStation { get; } + string StationId { get; } /// /// Uri of the operator or null, in case of single operator setup. diff --git a/TINKLib/Model/Bikes/Bike/BC/IBikeInfoMutable.cs b/TINKLib/Model/Bikes/Bike/BC/IBikeInfoMutable.cs index 3061481..5e5b103 100644 --- a/TINKLib/Model/Bikes/Bike/BC/IBikeInfoMutable.cs +++ b/TINKLib/Model/Bikes/Bike/BC/IBikeInfoMutable.cs @@ -35,7 +35,7 @@ namespace TINK.Model.Bikes.Bike.BC /// /// Station a which bike is located, null otherwise. /// - string CurrentStation { get; } + string StationId { get; } /// /// Holds the rent state of the bike. diff --git a/TINKLib/Model/Bikes/Bike/BluetoothLock/BikeInfoMutable.cs b/TINKLib/Model/Bikes/Bike/BluetoothLock/BikeInfoMutable.cs index fbc49cd..0001390 100644 --- a/TINKLib/Model/Bikes/Bike/BluetoothLock/BikeInfoMutable.cs +++ b/TINKLib/Model/Bikes/Bike/BluetoothLock/BikeInfoMutable.cs @@ -1,5 +1,4 @@ using System; -using TINK.Model.Bikes.Bike; using TINK.Model.Bikes.Bike.BluetoothLock; namespace TINK.Model.Bike.BluetoothLock @@ -7,14 +6,15 @@ namespace TINK.Model.Bike.BluetoothLock public class BikeInfoMutable : BC.BikeInfoMutable, IBikeInfoMutable { /// Constructs a bike object from source. - public BikeInfoMutable(BikeInfo bike) : base( + public BikeInfoMutable(BikeInfo bike, string stationName) : base( bike.Id, bike.IsDemo, bike.Group, bike.WheelType, bike.TypeOfBike, bike.Description, - bike.CurrentStation, + bike.StationId, + stationName, bike.OperatorUri, bike.TariffDescription, () => DateTime.Now, diff --git a/TINKLib/Model/Bikes/BikeCollectionFilter.cs b/TINKLib/Model/Bikes/BikeCollectionFilter.cs index 0c5b739..b31f3e2 100644 --- a/TINKLib/Model/Bikes/BikeCollectionFilter.cs +++ b/TINKLib/Model/Bikes/BikeCollectionFilter.cs @@ -17,7 +17,7 @@ namespace TINK.Model string selectedStation) { 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()); } diff --git a/TINKLib/Model/Bikes/BikeCollectionMutable.cs b/TINKLib/Model/Bikes/BikeCollectionMutable.cs index 7367dd4..4f92b96 100644 --- a/TINKLib/Model/Bikes/BikeCollectionMutable.cs +++ b/TINKLib/Model/Bikes/BikeCollectionMutable.cs @@ -1,8 +1,9 @@ -using System; +using Serilog; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; - +using TINK.Model.Station; using BikeInfo = TINK.Model.Bike.BC.BikeInfo; 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 /// - updates state of all bikes from state contained in bikes response /// - /// Object holding bikes info from copri to update from. + /// Object holding bikes info from copri to update from. Holds station id but not station name. + /// All stations to get station names from. /// Provices date time information. - public void Update( - IEnumerable bikesAll) + public void Update(IEnumerable bikesAll, + IEnumerable stations) { // Get list of current bikes by state(s) to update. // 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()) { - /// 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().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) { // Bike does not yet exist in list of bikes. - Add(BikeInfoMutableFactory.Create(bikeInfo)); + Add(BikeInfoMutableFactory.Create(bikeInfo, stationName)); continue; } // Update bike. - GetById(bikeInfo.Id).State.Load(bikeInfo.State); + GetById(bikeInfo.Id).State.Load(bikeInfo.State); if (bikesToBeRemoved.Contains(bikeInfo.Id)) { @@ -52,29 +59,29 @@ namespace TINK.Model.Bike } // Remove obsolete bikes. - foreach (var l_oId in bikesToBeRemoved) + foreach (var stationId in bikesToBeRemoved) { - RemoveById(l_oId); + RemoveById(stationId); } } /// /// Adds a new bike to collecion of bike. /// - /// New bike to add. + /// New bike to add. /// Thrown if bike is not unique. - public new void Add(BikeInfoMutable p_oNewBike) + public new void Add(BikeInfoMutable newBike) { // 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); } /// @@ -134,11 +141,11 @@ namespace TINK.Model.Bike /// private static class BikeInfoMutableFactory { - public static BikeInfoMutable Create(BikeInfo bikeInfo) + public static BikeInfoMutable Create(BikeInfo bikeInfo, string stationName) { return (bikeInfo is BluetoothLock.BikeInfo bluetoothLockBikeInfo) - ? new BluetoothLock.BikeInfoMutable(bluetoothLockBikeInfo) - : new BikeInfoMutable(bikeInfo); + ? new BluetoothLock.BikeInfoMutable(bluetoothLockBikeInfo, stationName) + : new BikeInfoMutable(bikeInfo, stationName); } } } diff --git a/TINKLib/Model/Connector/Command/Command.cs b/TINKLib/Model/Connector/Command/Command.cs index 4d67dcd..3da99eb 100644 --- a/TINKLib/Model/Connector/Command/Command.cs +++ b/TINKLib/Model/Connector/Command/Command.cs @@ -60,7 +60,7 @@ namespace TINK.Model.Connector { response = (await CopriServer.DoAuthorizationAsync(mail, password, deviceId)).GetIsResponseOk(mail); } - catch (System.Exception) + catch (Exception) { throw; } diff --git a/TINKLib/Model/Connector/Command/CommandLoggedIn.cs b/TINKLib/Model/Connector/Command/CommandLoggedIn.cs index cdeb2fd..68f93dc 100644 --- a/TINKLib/Model/Connector/Command/CommandLoggedIn.cs +++ b/TINKLib/Model/Connector/Command/CommandLoggedIn.cs @@ -23,9 +23,9 @@ namespace TINK.Model.Connector /// Constructs a copri query object. /// Server which implements communication. public CommandLoggedIn(ICopriServerBase p_oCopriServer, - string p_strSessionCookie, - string p_strMail, - Func p_oDateTimeProvider) : base(p_oCopriServer, p_strSessionCookie, p_strMail, p_oDateTimeProvider) + string sessionCookie, + string mail, + Func dateTimeProvider) : base(p_oCopriServer, sessionCookie, mail, dateTimeProvider) { } @@ -36,14 +36,14 @@ namespace TINK.Model.Connector /// If communication fails an TINK.Repository.Exception is thrown. /// /// Account to use for login. - public Task DoLogin(string p_strMail, string p_strPassword, string p_strDeviceId) + public Task 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 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."); } /// Logs user out. diff --git a/TINKLib/Model/Connector/Connector.cs b/TINKLib/Model/Connector/Connector.cs index f33a603..daa1971 100644 --- a/TINKLib/Model/Connector/Connector.cs +++ b/TINKLib/Model/Connector/Connector.cs @@ -25,12 +25,12 @@ namespace TINK.Model.Connector ICachedCopriServer server = null ) { Command = GetCommand( - server ?? new CopriProviderHttps(activeUri, TinkApp.MerchantId, appContextInfo, sessionCookie), + server ?? new CopriProviderHttps(activeUri, appContextInfo.MerchantId, appContextInfo, sessionCookie), sessionCookie, mail); Query = GetQuery( - server ?? new CopriProviderHttps(activeUri, TinkApp.MerchantId, appContextInfo, sessionCookie, expiresAfter), + server ?? new CopriProviderHttps(activeUri, appContextInfo.MerchantId, appContextInfo, sessionCookie, expiresAfter), sessionCookie, mail); } diff --git a/TINKLib/Model/Connector/ConnectorCache.cs b/TINKLib/Model/Connector/ConnectorCache.cs index b8b778f..54d2099 100644 --- a/TINKLib/Model/Connector/ConnectorCache.cs +++ b/TINKLib/Model/Connector/ConnectorCache.cs @@ -14,18 +14,19 @@ namespace TINK.Model.Connector /// Mail of user. /// Provides addess to copri. public ConnectorCache( + AppContextInfo appContextInfo, string sessionCookie, string mail, ICopriServer server = null) { Command = Connector.GetCommand( - server ?? new CopriProviderMonkeyStore(TinkApp.MerchantId, sessionCookie), + server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, sessionCookie), sessionCookie, mail); Query = GetQuery( - server ?? new CopriProviderMonkeyStore(TinkApp.MerchantId, sessionCookie), + server ?? new CopriProviderMonkeyStore(appContextInfo.MerchantId, sessionCookie), sessionCookie, mail); } diff --git a/TINKLib/Model/Connector/ConnectorFactory.cs b/TINKLib/Model/Connector/ConnectorFactory.cs index 8ad38a5..d0aa5a0 100644 --- a/TINKLib/Model/Connector/ConnectorFactory.cs +++ b/TINKLib/Model/Connector/ConnectorFactory.cs @@ -21,7 +21,7 @@ namespace TINK.Model.Connector { return isConnected ? new Connector(activeUri, appContextInfo, sessionCookie, mail, expiresAfter: expiresAfter) as IConnector - : new ConnectorCache(sessionCookie, mail); + : new ConnectorCache(appContextInfo, sessionCookie, mail); } } } diff --git a/TINKLib/Model/Connector/Query/BaseLoggedIn.cs b/TINKLib/Model/Connector/Query/BaseLoggedIn.cs index 7ceb20e..adb2ee2 100644 --- a/TINKLib/Model/Connector/Query/BaseLoggedIn.cs +++ b/TINKLib/Model/Connector/Query/BaseLoggedIn.cs @@ -16,24 +16,24 @@ namespace TINK.Model.Connector protected readonly Func DateTimeProvider; /// Constructs a copri query object. - /// Server which implements communication. - public BaseLoggedIn(ICopriServerBase p_oCopriServer, - string p_strSessionCookie, - string p_strMail, - Func p_oDateTimeProvider) : base(p_oCopriServer) + /// Server which implements communication. + public BaseLoggedIn(ICopriServerBase copriServer, + string sessionCookie, + string mail, + Func 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."); - 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."); DateTimeProvider = p_oDateTimeProvider ?? throw new ArgumentException("Can not instantiate connector- object. No date time provider object available."); - SessionCookie = p_strSessionCookie; + SessionCookie = sessionCookie; - Mail = p_strMail; + Mail = mail; } } } diff --git a/TINKLib/Model/Connector/TextToTypeHelper.cs b/TINKLib/Model/Connector/TextToTypeHelper.cs index af817ad..f5c1d85 100644 --- a/TINKLib/Model/Connector/TextToTypeHelper.cs +++ b/TINKLib/Model/Connector/TextToTypeHelper.cs @@ -26,30 +26,30 @@ namespace TINK.Model.Connector /// /// Gets the position from StationInfo object. /// - /// Object to get information from. + /// Object to get information from. /// Position information. - 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); } /// Gets the position from StationInfo object. - /// Object to get information from. + /// Object to get information from. /// Position information. - public static IEnumerable GetGroup(this AuthorizationResponse p_oAuthorizationResponse) + public static IEnumerable GetGroup(this AuthorizationResponse authorizationResponse) { try { - return p_oAuthorizationResponse.user_group.GetGroup(); + return authorizationResponse.user_group.GetGroup(); } 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); } } /// Gets the position from StationInfo object. - /// Object to get information from. + /// Object to get information from. /// Position information. public static IEnumerable GetGroup(this string[] group) { @@ -63,43 +63,50 @@ namespace TINK.Model.Connector return new HashSet(group).ToList(); } - /// Gets the position from StationInfo object. - /// Object to get information from. + /// Gets if user acknowldged ags or not. + /// Object to get information from. /// Position information. - public static string GetGroup(this IEnumerable p_oGroup) + public static bool GetIsAgbAcknowledged(this AuthorizationResponse authorizationResponse) + => int.TryParse(authorizationResponse?.agb_checked, out int result) + && result != 0; + + /// Gets the position from StationInfo object. + /// Object to get information from. + /// Position information. + public static string GetGroup(this IEnumerable group) { - return string.Join(",", p_oGroup); + return string.Join(",", group); } /// Gets the position from StationInfo object. - /// Object to get information from. + /// Object to get information from. /// Position information. - public static IEnumerable GetGroup(this StationsAvailableResponse.StationInfo p_oStationInfo) + public static IEnumerable GetGroup(this StationsAvailableResponse.StationInfo stationInfo) { try { - return p_oStationInfo.station_group.GetGroup(); + return stationInfo.station_group.GetGroup(); } 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); } } /// /// Gets the position from StationInfo object. /// - /// Object to get information from. + /// Object to get information from. /// Position information. - 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)) { throw new InvalidResponseException( string.Format("Unknown reservation state detected. Member {0}.{1}.", typeof(BikeInfoBase), nameof(BikeInfoBase.state)), - p_oBikeInfo); + bikeInfo); } if (l_oState == "available") @@ -123,58 +130,58 @@ namespace TINK.Model.Connector /// /// Gets the from date information from JSON. /// - /// JSON to get information from.. + /// JSON to get information from.. /// From information. - 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); } /// /// Gets whether the bike is a trike or not. /// - /// JSON to get information from.. + /// JSON to get information from.. /// From information. - public static bool? GetIsDemo(this BikeInfoBase p_oBikeInfo) + public static bool? GetIsDemo(this BikeInfoBase bikeInfo) { - return p_oBikeInfo?.description != null - ? p_oBikeInfo.description.ToUpper().Contains(DEMOBIKEMARKER) + return bikeInfo?.description != null + ? bikeInfo.description.ToUpper().Contains(DEMOBIKEMARKER) : (bool?) null; } /// /// Gets whether the bike is a trike or not. /// - /// JSON to get information from.. + /// JSON to get information from. /// From information. - public static IEnumerable GetGroup(this BikeInfoBase p_oBikeInfo) + public static IEnumerable GetGroup(this BikeInfoBase bikeInfo) { try { - return p_oBikeInfo?.bike_group?.GetGroup()?.ToList() ?? new List(); + return bikeInfo?.bike_group?.GetGroup()?.ToList() ?? new List(); } 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); } } /// Gets whether the bike has a bord computer or not. - /// JSON to get information from. + /// JSON to get information from. /// From information. - public static bool GetIsManualLockBike(this BikeInfoBase p_oBikeInfo) + public static bool GetIsManualLockBike(this BikeInfoBase bikeInfo) { - return !string.IsNullOrEmpty(p_oBikeInfo.system) - && p_oBikeInfo.system.ToUpper().StartsWith("LOCK"); + return !string.IsNullOrEmpty(bikeInfo.system) + && bikeInfo.system.ToUpper().StartsWith("LOCK"); } /// Gets whether the bike has a bord computer or not. - /// JSON to get information from.. + /// JSON to get information from.. /// From information. - public static bool GetIsBluetoothLockBike(this BikeInfoBase p_oBikeInfo) + public static bool GetIsBluetoothLockBike(this BikeInfoBase bikeInfo) { - return !string.IsNullOrEmpty(p_oBikeInfo.system) - && p_oBikeInfo.system.ToUpper().StartsWith("ILOCKIT"); + return !string.IsNullOrEmpty(bikeInfo.system) + && bikeInfo.system.ToUpper().StartsWith("ILOCKIT"); } /// Gets whether the bike has a bord computer or not. @@ -342,13 +349,22 @@ namespace TINK.Model.Connector : null; } + /// Tries to get the copriversion from response. + /// Response to get version info from. + /// COPRI version + 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); + } + /// Gets the copriversion from. /// Response to get version info from. /// COPRI version public static Version GetCopriVersion(this CopriVersion response) - => response!= null - && !string.IsNullOrEmpty(response.copri_version) - && Version.TryParse(response.copri_version, out Version copriVersion) + => response.TryGetCopriVersion(out Version copriVersion) ? copriVersion : throw new InvalidResponseException($"Can not get version info from copri response {response?.copri_version}."); } diff --git a/TINKLib/Model/Connector/Updater/UpdaterJSON.cs b/TINKLib/Model/Connector/Updater/UpdaterJSON.cs index d3bfc12..4140a7d 100644 --- a/TINKLib/Model/Connector/Updater/UpdaterJSON.cs +++ b/TINKLib/Model/Connector/Updater/UpdaterJSON.cs @@ -85,7 +85,9 @@ namespace TINK.Model.Connector /// Response to get data from. /// General data object initialized form COPRI 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); /// Gets account object from login response. /// Needed to extract cookie from autorization response. @@ -106,6 +108,7 @@ namespace TINK.Model.Connector return new Account( mail, password, + loginResponse.GetIsAgbAcknowledged(), loginResponse.authcookie?.Replace(merchantId, ""), loginResponse.GetGroup(), loginResponse.debuglevel == 1 diff --git a/TINKLib/Model/TinkApp.cs b/TINKLib/Model/TinkApp.cs index a433748..758d6f6 100644 --- a/TINKLib/Model/TinkApp.cs +++ b/TINKLib/Model/TinkApp.cs @@ -36,7 +36,7 @@ namespace TINK.Model public delegate bool SetCredentialsDelegate(string p_strMailAddress, string p_strPassword); /// Returns the id of the app (sharee.bike) to be identified by copri. - public static string MerchantId => "oiF2kahH"; + public static string MerchantId { get; private set; } /// /// Holds status about whants new page. @@ -160,6 +160,7 @@ namespace TINK.Model Settings.Settings settings, IStore accountStore, Func connectorFactory, + string merchantId, IServicesContainer geolocationServicesContainer, ILocksService locksService, ISmartDevice device, @@ -179,6 +180,9 @@ namespace TINK.Model ConnectorFactory = connectorFactory ?? 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(); var locksServices = locksService != null diff --git a/TINKLib/Model/User/Account/Account.cs b/TINKLib/Model/User/Account/Account.cs index ac8e451..a688a13 100644 --- a/TINKLib/Model/User/Account/Account.cs +++ b/TINKLib/Model/User/Account/Account.cs @@ -49,6 +49,8 @@ namespace TINK.Model.User.Account /// public class Account : IAccount { + public const bool DEFAULTISAGBACKNOWLEDGED = false; + /// Constructs an account object. /// Mail address of the account holder. /// Password. @@ -58,12 +60,14 @@ namespace TINK.Model.User.Account public Account( string mail, string password, + bool isAgbAcknowledged, string sessionCookie, IEnumerable bikeGroup, Permissions debugLevel = Permissions.None) { Mail = mail; Pwd = password; + IsAgbAcknowledged = isAgbAcknowledged; SessionCookie = sessionCookie; DebugLevel = debugLevel; 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."); } - 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 /// Password of to authenticate. public string Pwd { get; } + /// True if user acknowleged agbs. + public bool IsAgbAcknowledged { get; } + /// Session cookie used to sign in to copri. public string SessionCookie { get; } diff --git a/TINKLib/Model/User/Account/AccountMutable.cs b/TINKLib/Model/User/Account/AccountMutable.cs index d90947a..dbe7b1b 100644 --- a/TINKLib/Model/User/Account/AccountMutable.cs +++ b/TINKLib/Model/User/Account/AccountMutable.cs @@ -29,7 +29,7 @@ namespace TINK.Model.User.Account public string 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); } } /// @@ -38,16 +38,19 @@ namespace TINK.Model.User.Account public string 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); } } + /// True if user acknowleged agbs. + public bool IsAgbAcknowledged => m_oAccount.IsAgbAcknowledged; + /// /// Session cookie used to sign in to copri. /// public string 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); } } /// @@ -64,7 +67,7 @@ namespace TINK.Model.User.Account public Permissions 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); } } } } diff --git a/TINKLib/Model/User/Account/EmptyAccount.cs b/TINKLib/Model/User/Account/EmptyAccount.cs index 80a2745..12e164f 100644 --- a/TINKLib/Model/User/Account/EmptyAccount.cs +++ b/TINKLib/Model/User/Account/EmptyAccount.cs @@ -9,6 +9,8 @@ namespace TINK.Model.User.Account public string Pwd => null; + public bool IsAgbAcknowledged => false; + public string SessionCookie => null; public Permissions DebugLevel => Permissions.None; diff --git a/TINKLib/Model/User/Account/IAccount.cs b/TINKLib/Model/User/Account/IAccount.cs index ed826d6..d0b8166 100644 --- a/TINKLib/Model/User/Account/IAccount.cs +++ b/TINKLib/Model/User/Account/IAccount.cs @@ -13,6 +13,9 @@ namespace TINK.Model.User.Account /// Password of the account. string Pwd { get; } + /// True if user acknowleged agbs. + bool IsAgbAcknowledged { get; } + /// Session cookie used to sign in to copri. string SessionCookie { get; } diff --git a/TINKLib/Model/User/Account/Store.cs b/TINKLib/Model/User/Account/Store.cs index d7db191..09aec62 100644 --- a/TINKLib/Model/User/Account/Store.cs +++ b/TINKLib/Model/User/Account/Store.cs @@ -17,6 +17,9 @@ namespace TINK.Model.User.Account /// Holds id of the mail address key. private const string KEY_MAILADDRESS = "MailAddress"; + /// Holds key for flag is agb acknowledged. + private const string KEY_ISAGBACKNOWLEDGED = "IsAgbAcknowledged"; + public IAccount Delete(IAccount account) { SecureStorage.RemoveAll(); @@ -27,15 +30,16 @@ namespace TINK.Model.User.Account { var mail = string.Empty; + var isAgbAcknowledged = Account.DEFAULTISAGBACKNOWLEDGED; var sessionCookie = string.Empty; var debugLevel = Permissions.None; try { mail = await SecureStorage.GetAsync(KEY_MAILADDRESS); + bool.TryParse(await SecureStorage.GetAsync(KEY_ISAGBACKNOWLEDGED), out isAgbAcknowledged); sessionCookie = await SecureStorage.GetAsync(KEY_SESSIONCOOKIE); Enum.TryParse(await SecureStorage.GetAsync(KEY_DEBUGLEVEL), out debugLevel); - } catch (Exception exception) { @@ -45,6 +49,7 @@ namespace TINK.Model.User.Account return new Account( mail, string.Empty, + isAgbAcknowledged, sessionCookie, new List(), debugLevel); @@ -55,6 +60,7 @@ namespace TINK.Model.User.Account try { 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_DEBUGLEVEL, mailAndPwd.DebugLevel.ToString()); } diff --git a/TINKLib/Model/WhatsNew.cs b/TINKLib/Model/WhatsNew.cs index a768bfe..3d00643 100644 --- a/TINKLib/Model/WhatsNew.cs +++ b/TINKLib/Model/WhatsNew.cs @@ -476,7 +476,7 @@ namespace TINK.Model AppResources.ChangeLog3_0_266 }, { - new Version(3, 0, 267), + new Version(3, 0, 270), AppResources.ChangeLog3_0_231 // Minor improvements. } }; diff --git a/TINKLib/Repository/CopriCallsHttps.cs b/TINKLib/Repository/CopriCallsHttps.cs index b10b80d..6005617 100644 --- a/TINKLib/Repository/CopriCallsHttps.cs +++ b/TINKLib/Repository/CopriCallsHttps.cs @@ -767,29 +767,29 @@ namespace TINK.Repository var l_strHost = uRL; // Returns a http request. - var l_oRequest = WebRequest.CreateHttp(l_strHost); + var request = WebRequest.CreateHttp(l_strHost); - l_oRequest.Method = "POST"; - l_oRequest.ContentType = "application/x-www-form-urlencoded"; - l_oRequest.UserAgent = userAgent; + request.Method = "POST"; + request.ContentType = "application/x-www-form-urlencoded"; + request.UserAgent = userAgent; // 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. - l_oRequest.KeepAlive = true; + request.KeepAlive = true; byte[] l_oPostData = Encoding.UTF8.GetBytes(p_strCommand); - l_oRequest.ContentLength = l_oPostData.Length; + request.ContentLength = l_oPostData.Length; // 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. await l_oDataStream.WriteAsync(l_oPostData, 0, l_oPostData.Length); } // Get the response. - var l_oResponse = await l_oRequest.GetResponseAsync() as HttpWebResponse; + var l_oResponse = await request.GetResponseAsync() as HttpWebResponse; if (l_oResponse == null) { diff --git a/TINKLib/Repository/CopriCallsMemory.cs b/TINKLib/Repository/CopriCallsMemory.cs index ee8b3cd..eaf0370 100644 --- a/TINKLib/Repository/CopriCallsMemory.cs +++ b/TINKLib/Repository/CopriCallsMemory.cs @@ -1380,7 +1380,7 @@ namespace TINK.Repository get { 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++; } diff --git a/TINKLib/Repository/Response/AuthorizationResponse.cs b/TINKLib/Repository/Response/AuthorizationResponse.cs index e2c5179..146eecc 100644 --- a/TINKLib/Repository/Response/AuthorizationResponse.cs +++ b/TINKLib/Repository/Response/AuthorizationResponse.cs @@ -11,5 +11,9 @@ namespace TINK.Repository.Response /// Holds the group of the bike (TINK, Konrad, ...). [DataMember] public string[] user_group { get; private set; } + + /// Holds value of 0 if agb were not acknowledged. + [DataMember] + public string agb_checked { get; private set; } } } diff --git a/TINKLib/ViewModel/Bikes/Bike/BikeViewModelBase.cs b/TINKLib/ViewModel/Bikes/Bike/BikeViewModelBase.cs index c2e7523..4ca2734 100644 --- a/TINKLib/ViewModel/Bikes/Bike/BikeViewModelBase.cs +++ b/TINKLib/ViewModel/Bikes/Bike/BikeViewModelBase.cs @@ -195,13 +195,13 @@ namespace TINK.ViewModel.Bikes.Bike case InUseStateEnum.Reserved: return GetReservedInfo( bike.State.RemainingTime, - bike.CurrentStation, + bike.StationId, null); // Hide reservation code because no one but active user should see code case InUseStateEnum.Booked: return GetBookedInfo( bike.State.From, - bike.CurrentStation, + bike.StationId, null); // Hide reservation code because no one but active user should see code default: @@ -215,7 +215,7 @@ namespace TINK.ViewModel.Bikes.Bike return bike.State.MailAddress == ActiveUser.Mail ? GetReservedInfo( bike.State.RemainingTime, - bike.CurrentStation, + bike.StationId, bike.State.Code) : "Fahrrad bereits reserviert durch anderen Nutzer."; @@ -223,7 +223,7 @@ namespace TINK.ViewModel.Bikes.Bike return bike.State.MailAddress == ActiveUser.Mail ? GetBookedInfo( bike.State.From, - bike.CurrentStation, + bike.StationId, bike.State.Code) : "Fahrrad bereits gebucht durch anderen Nutzer."; diff --git a/TINKLib/ViewModel/Bikes/Bike/TariffDescriptionViewModel.cs b/TINKLib/ViewModel/Bikes/Bike/TariffDescriptionViewModel.cs index 6cdd6e0..e89a421 100644 --- a/TINKLib/ViewModel/Bikes/Bike/TariffDescriptionViewModel.cs +++ b/TINKLib/ViewModel/Bikes/Bike/TariffDescriptionViewModel.cs @@ -27,14 +27,11 @@ namespace TINK.ViewModel.Bikes.Bike // No tariff description details available. return string.Empty; + // Up to version MessageBikesManagementTariffDescriptionTariffHeaderNameId #if USCSHARP9 - return Tariff?.Number != null - ? string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeaderNameId, Tariff?.Name ?? "-", Tariff?.Number != null ? Tariff.Number : "-"); - : string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-"); + return string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-"); #else - return Tariff?.Number != null - ? string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeaderNameId, Tariff?.Name ?? "-", Tariff?.Number != null ? Tariff.Number.ToString() : "-") - : string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-"); + return string.Format(AppResources.MessageBikesManagementTariffDescriptionTariffHeader, Tariff?.Name ?? "-"); #endif } } diff --git a/TINKLib/ViewModel/BikesAtStation/BikesAtStationPageViewModel.cs b/TINKLib/ViewModel/BikesAtStation/BikesAtStationPageViewModel.cs index 768b02e..b69bdb5 100644 --- a/TINKLib/ViewModel/BikesAtStation/BikesAtStationPageViewModel.cs +++ b/TINKLib/ViewModel/BikesAtStation/BikesAtStationPageViewModel.cs @@ -266,7 +266,7 @@ namespace TINK.ViewModel.BikesAtStation if (!dialogResult) { // User decided not to give access to locations permissions. - BikeCollection.Update(bikesAtStation); + BikeCollection.Update(bikesAtStation, new List { m_oStation}); await OnAppearing(() => UpdateTask()); @@ -287,7 +287,7 @@ namespace TINK.ViewModel.BikesAtStation AppResources.MessageBikesManagementLocationActivation, AppResources.MessageAnswerOk); - BikeCollection.Update(bikesAtStation); + BikeCollection.Update(bikesAtStation, new List { m_oStation }); await OnAppearing(() => UpdateTask()); @@ -303,7 +303,7 @@ namespace TINK.ViewModel.BikesAtStation AppResources.MessageBikesManagementBluetoothActivation, AppResources.MessageAnswerOk); - BikeCollection.Update(bikesAtStation); + BikeCollection.Update(bikesAtStation, new List { m_oStation }); await OnAppearing(() => UpdateTask()); @@ -330,7 +330,7 @@ namespace TINK.ViewModel.BikesAtStation var locksInfo = lockIdList.UpdateById(locksInfoTdo); - BikeCollection.Update(bikesAtStation.UpdateLockInfo(locksInfo)); + BikeCollection.Update(bikesAtStation.UpdateLockInfo(locksInfo), new List { m_oStation }); // Backup GUI synchronization context. await OnAppearing(() => UpdateTask()); @@ -363,7 +363,7 @@ namespace TINK.ViewModel.BikesAtStation PostAction( unused => { - BikeCollection.Update(bikes); + BikeCollection.Update(bikes, new List { m_oStation }); Exception = result.Exception; ActionText = string.Empty; }, diff --git a/TINKLib/ViewModel/Contact/SelectStationPageViewModel.cs b/TINKLib/ViewModel/Contact/SelectStationPageViewModel.cs index d0b5e64..3dc3b1e 100644 --- a/TINKLib/ViewModel/Contact/SelectStationPageViewModel.cs +++ b/TINKLib/ViewModel/Contact/SelectStationPageViewModel.cs @@ -508,7 +508,7 @@ namespace TINK.ViewModel.Contact foreach (var stationId in stationsId) { // 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) { // There is at least one requested or booked bike diff --git a/TINKLib/ViewModel/CopriWebView/RegisterPageViewModel.cs b/TINKLib/ViewModel/CopriWebView/RegisterPageViewModel.cs index 083de14..ffc9fd7 100644 --- a/TINKLib/ViewModel/CopriWebView/RegisterPageViewModel.cs +++ b/TINKLib/ViewModel/CopriWebView/RegisterPageViewModel.cs @@ -4,16 +4,23 @@ namespace TINK.ViewModel.CopriWebView { public class RegisterPageViewModel { + /// Holds the merchant id. + private string MerchantId { get; } + /// Holds the name of the host. private string HostName { get; } public RegisterPageViewModel( + string merchantId, string hostName) { HostName = hostName; - } /// Get Uri of web view for creating account. + MerchantId = merchantId; + } + + /// Get Uri of web view for creating account. public string Uri => - $"https://{HostName}/{HostName.GetAppFolderName()}/Account/1.%20Kundendaten"; + $"https://{HostName}/{HostName.GetAppFolderName()}/Account/1.%20Kundendaten?sessionid={MerchantId}"; } } diff --git a/TINKLib/ViewModel/FindBike/FindBikePageViewModel.cs b/TINKLib/ViewModel/FindBike/FindBikePageViewModel.cs index eaf300a..ba60c61 100644 --- a/TINKLib/ViewModel/FindBike/FindBikePageViewModel.cs +++ b/TINKLib/ViewModel/FindBike/FindBikePageViewModel.cs @@ -23,6 +23,7 @@ using TINK.Services.Permissions; using Plugin.BLE.Abstractions.Contracts; using TINK.MultilingualResources; using TINK.Model.Device; +using TINK.Model.Station; namespace TINK.ViewModel.FindBike { @@ -55,6 +56,9 @@ namespace TINK.ViewModel.FindBike /// Hide id input fields as soon as bike is found. public bool IsSelectBikeVisible => BikeCollection != null && BikeCollection.Count == 0; + /// Holds the stations to get station names form station ids. + private IEnumerable Stations { get; } + /// /// Constructs bike collection view model in case information about occupied bikes is available. /// @@ -66,6 +70,7 @@ namespace TINK.ViewModel.FindBike /// Returns if mobile is connected to web or not. /// Connects system to copri. /// Service to control lock retrieve info. + /// Stations to get station name from station id. /// Holds whether to poll or not and the periode leght is polling is on. /// Executes actions on GUI thread. /// Provides info about the smart device (phone, tablet, ...). @@ -79,6 +84,7 @@ namespace TINK.ViewModel.FindBike Func connectorFactory, IGeolocation geolocation, ILocksService lockService, + IEnumerable stations, PollingParameters polling, Action postAction, ISmartDevice smartDevice, @@ -88,6 +94,8 @@ namespace TINK.ViewModel.FindBike { OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelectBikeVisible))); }; + + Stations = stations ?? throw new ArgumentException(nameof(stations)); } /// @@ -159,7 +167,7 @@ namespace TINK.ViewModel.FindBike if (!dialogResult) { // User decided not to give access to locations permissions. - BikeCollection.Update(bikeCollection); + BikeCollection.Update(bikeCollection, Stations); //await OnAppearing(() => UpdateTask()); @@ -181,7 +189,7 @@ namespace TINK.ViewModel.FindBike AppResources.MessageBikesManagementLocationActivation, AppResources.MessageAnswerOk); - BikeCollection.Update(bikeCollection); + BikeCollection.Update(bikeCollection, Stations); await OnAppearing(() => UpdateTask()); @@ -198,7 +206,7 @@ namespace TINK.ViewModel.FindBike AppResources.MessageBikesManagementBluetoothActivation, AppResources.MessageAnswerOk); - BikeCollection.Update(bikeCollection); + BikeCollection.Update(bikeCollection, Stations); await OnAppearing(() => UpdateTask()); @@ -225,7 +233,7 @@ namespace TINK.ViewModel.FindBike var locksInfo = lockIdList.UpdateById(locksInfoTdo); - BikeCollection.Update(bikeCollection.UpdateLockInfo(locksInfo)); + BikeCollection.Update(bikeCollection.UpdateLockInfo(locksInfo), Stations); await OnAppearing(() => UpdateTask()); @@ -265,7 +273,7 @@ namespace TINK.ViewModel.FindBike PostAction( 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; ActionText = string.Empty; }, diff --git a/TINKLib/ViewModel/Login/LoginPageViewModel.cs b/TINKLib/ViewModel/Login/LoginPageViewModel.cs index 40ddc2f..3c9a1dc 100644 --- a/TINKLib/ViewModel/Login/LoginPageViewModel.cs +++ b/TINKLib/ViewModel/Login/LoginPageViewModel.cs @@ -214,6 +214,7 @@ namespace TINK.ViewModel public async Task Login() #endif { + IAccount account = new EmptyAccount(); try { Log.ForContext().Information("User taped login button."); @@ -223,9 +224,9 @@ namespace TINK.ViewModel TinkApp.ActiveUser.CheckIsPasswordValid(MailAddress, Password); // 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. TinkApp.GroupFilterMapPage = @@ -318,7 +319,8 @@ namespace TINK.ViewModel { // No need to show "Anleitung TINK Räder" because user can not use tink. #if USEFLYOUT - m_oViewService.ShowPage(ViewTypes.MapPage); + + m_oViewService.ShowPage(account.IsAgbAcknowledged ? ViewTypes.MapPage : ViewTypes.ManageAccountPage); #else await m_oViewService.ShowPage("//MapPage"); #endif diff --git a/TINKLib/ViewModel/Map/MapPageViewModel.cs b/TINKLib/ViewModel/Map/MapPageViewModel.cs index 463b5b4..923ff09 100644 --- a/TINKLib/ViewModel/Map/MapPageViewModel.cs +++ b/TINKLib/ViewModel/Map/MapPageViewModel.cs @@ -34,6 +34,10 @@ namespace TINK.ViewModel.Map { public class MapPageViewModel : INotifyPropertyChanged { + /// True if message was already shown to user. + private static bool WasMerchantMessageAlreadyShown { get; set; } = false; + + /// Holds the count of custom icons availalbe. private const int CUSTOM_ICONS_COUNT = 30; @@ -322,6 +326,16 @@ namespace TINK.ViewModel.Map 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 HandleAuthCookieNotDefinedException(resultStationsAndBikes.Exception); @@ -677,7 +691,7 @@ namespace TINK.ViewModel.Map foreach (var stationId in stationsId) { // 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) { // There is at least one requested or booked bike diff --git a/TINKLib/ViewModel/MyBikes/MyBikesPageViewModel.cs b/TINKLib/ViewModel/MyBikes/MyBikesPageViewModel.cs index a3507d6..31275fb 100644 --- a/TINKLib/ViewModel/MyBikes/MyBikesPageViewModel.cs +++ b/TINKLib/ViewModel/MyBikes/MyBikesPageViewModel.cs @@ -22,11 +22,15 @@ using TINK.Services.Permissions; using Plugin.BLE.Abstractions.Contracts; using TINK.MultilingualResources; using TINK.Model.Device; +using TINK.Model.Station; namespace TINK.ViewModel.MyBikes { public class MyBikesPageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged { + /// Holds the stations to get station names form station ids. + private IEnumerable Stations { get; } + /// /// Constructs bike collection view model in case information about occupied bikes is available. /// @@ -38,6 +42,7 @@ namespace TINK.ViewModel.MyBikes /// Returns if mobile is connected to web or not. /// Connects system to copri. /// Service to control lock retrieve info. + /// Stations to get station name from station id. /// Holds whether to poll or not and the periode leght is polling is on. /// Executes actions on GUI thread. /// Provides info about the smart device (phone, tablet, ...). @@ -51,6 +56,7 @@ namespace TINK.ViewModel.MyBikes Func connectorFactory, IGeolocation geolocation, ILocksService lockService, + IEnumerable stations, PollingParameters p_oPolling, Action postAction, ISmartDevice smartDevice, @@ -61,6 +67,8 @@ namespace TINK.ViewModel.MyBikes OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsNoBikesOccupiedVisible))); OnPropertyChanged(new PropertyChangedEventArgs(nameof(NoBikesOccupiedText))); }; + + Stations = stations ?? throw new ArgumentException(nameof(stations)); } /// Returns if info about the fact that user did not request or book any bikes is visible or not. @@ -134,7 +142,7 @@ namespace TINK.ViewModel.MyBikes if (!dialogResult) { // User decided not to give access to locations permissions. - BikeCollection.Update(bikesOccupied.Response); + BikeCollection.Update(bikesOccupied.Response, Stations); await OnAppearing(() => UpdateTask()); @@ -156,7 +164,7 @@ namespace TINK.ViewModel.MyBikes AppResources.MessageBikesManagementLocationActivation, AppResources.MessageAnswerOk); - BikeCollection.Update(bikesOccupied.Response); + BikeCollection.Update(bikesOccupied.Response, Stations); await OnAppearing(() => UpdateTask()); @@ -173,7 +181,7 @@ namespace TINK.ViewModel.MyBikes AppResources.MessageBikesManagementBluetoothActivation, AppResources.MessageAnswerOk); - BikeCollection.Update(bikesOccupied.Response); + BikeCollection.Update(bikesOccupied.Response, Stations); await OnAppearing(() => UpdateTask()); @@ -200,7 +208,7 @@ namespace TINK.ViewModel.MyBikes var locksInfo = lockIdList.UpdateById(locksInfoTdo); - BikeCollection.Update(bikesOccupied.Response.UpdateLockInfo(locksInfo)); + BikeCollection.Update(bikesOccupied.Response.UpdateLockInfo(locksInfo), Stations); await OnAppearing(() => UpdateTask()); @@ -251,7 +259,7 @@ namespace TINK.ViewModel.MyBikes PostAction( 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; ActionText = string.Empty; }, diff --git a/TestTINKLib/LoginSessionCopriInfo.cs b/TestFramework/LoginSessionCopriInfo.cs similarity index 100% rename from TestTINKLib/LoginSessionCopriInfo.cs rename to TestFramework/LoginSessionCopriInfo.cs diff --git a/TestFramework/Repository/CopriCallMemoryBase.cs b/TestFramework/Repository/CopriCallMemoryBase.cs index 3ddbaa1..9b5ed8a 100644 --- a/TestFramework/Repository/CopriCallMemoryBase.cs +++ b/TestFramework/Repository/CopriCallMemoryBase.cs @@ -158,21 +158,20 @@ namespace TestFramework.Repository public bool IsConnected => false; /// Logs user in. - /// User to log in. - /// Id specifying user and hardware. - /// Mailaddress of user to log in. - /// Password to log in. + /// Id specifying user and hardware. + /// Mailaddress of user to log in. + /// Password to log in. /// Response which holds auth cookie public static AuthorizationResponse DoAuthorize( - string DoAuthResponse, - string p_strMailAddress, - string p_strPassword, - string p_strDeviceId) + string doAuthResponse, + string mailAddress, + string password, + string deviceId) { - return p_strMailAddress == "javaminister@gmail.com" - && p_strPassword == "*********" && - p_strDeviceId == "HwId1000000000000" - ? JsonConvertRethrow.DeserializeObject>(DoAuthResponse).shareejson + return mailAddress == "javaminister@gmail.com" + && password == "*********" && + deviceId == "HwId1000000000000" + ? JsonConvertRethrow.DeserializeObject>(doAuthResponse).shareejson : JsonConvertRethrow.DeserializeObject>(DO_AUTH_Unknown_User_FILE).shareejson; } diff --git a/TestSharee/UseCase/Startup/TestTinkApp.cs b/TestSharee/UseCase/Startup/TestTinkApp.cs index ee0320f..b4e29ac 100644 --- a/TestSharee/UseCase/Startup/TestTinkApp.cs +++ b/TestSharee/UseCase/Startup/TestTinkApp.cs @@ -45,7 +45,7 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), @@ -98,7 +98,7 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), new StoreMock(new Account("javaminister@gmail.com", "javaminister" /* password */, "4da3044c8657a04ba60e2eaa753bc51a" /* session cookie */, new List { 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>(), new LocksServiceMock(), new DeviceMock(), @@ -159,7 +159,7 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), new StoreMock(new Account("mgrimm@gmail.com", "123456789" /* password */, "1234" /* session cookie */, new List { 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>(), new LocksServiceMock(), new DeviceMock(), @@ -214,7 +214,7 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), new StoreMock(new Account("mgrimm@gmail.com", "123456789" /* password */, "1234" /* session cookie */, new List { 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>(), new LocksServiceMock(), new DeviceMock(), @@ -270,7 +270,7 @@ namespace TestShareeLib.UseCases.Startup new TINK.Settings.PollingParameters(new TimeSpan(10000), true), Serilog.Events.LogEventLevel.Error), 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>(), null, // use default locks service new DeviceMock(), @@ -313,7 +313,7 @@ namespace TestShareeLib.UseCases.Startup new TINK.Settings.PollingParameters(new TimeSpan(10000), true), Serilog.Events.LogEventLevel.Error), 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>(), null, // use default locks service new DeviceMock(), @@ -358,7 +358,7 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(TINK.Services.BluetoothLock.BLE.LockItByGuidService).FullName, activeGeolocationService: typeof(TINK.Model.Services.Geolocation.LastKnownGeolocationService).FullName), 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>(), null, // use default locks service new DeviceMock(), diff --git a/TestShareeLib/Model/Bike/BC/TestBikeMutable.cs b/TestShareeLib/Model/Bike/BC/TestBikeMutable.cs index 1601cfa..9f64a1b 100644 --- a/TestShareeLib/Model/Bike/BC/TestBikeMutable.cs +++ b/TestShareeLib/Model/Bike/BC/TestBikeMutable.cs @@ -19,11 +19,12 @@ namespace TestTINKLib WheelType? wheelType = null, TypeOfBike? typeOfBike = null, string description = null, - string currentStationId = null, + string stationId = null, + string stationName = null, Uri operatorUri = null, TariffDescription tariffDescription = null, Func 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(TypeOfBike.Cargo, l_oBike.TypeOfBike); Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value); - Assert.IsNull(l_oBike.CurrentStation); + Assert.IsNull(l_oBike.StationId); l_oBike = new BikeInfoMutable( "17", @@ -59,7 +60,7 @@ namespace TestTINKLib Assert.AreEqual(WheelType.Mono, l_oBike.WheelType); Assert.AreEqual(TypeOfBike.Allround, l_oBike.TypeOfBike); Assert.AreEqual(InUseStateEnum.Disposable, l_oBike.State.Value); - Assert.AreEqual("1", l_oBike.CurrentStation); + Assert.AreEqual("1", l_oBike.StationId); } [Test] diff --git a/TestShareeLib/Model/Bike/BluetoothLock/TestBikeInfo.cs b/TestShareeLib/Model/Bike/BluetoothLock/TestBikeInfo.cs index bf10b69..fae77cc 100644 --- a/TestShareeLib/Model/Bike/BluetoothLock/TestBikeInfo.cs +++ b/TestShareeLib/Model/Bike/BluetoothLock/TestBikeInfo.cs @@ -24,7 +24,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock public void TestCtorAvailable() { 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); } diff --git a/TestShareeLib/Model/Bike/BluetoothLock/TestBikeInfoMutalbe.cs b/TestShareeLib/Model/Bike/BluetoothLock/TestBikeInfoMutalbe.cs new file mode 100644 index 0000000..adca85c --- /dev/null +++ b/TestShareeLib/Model/Bike/BluetoothLock/TestBikeInfoMutalbe.cs @@ -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")); + } + } +} diff --git a/TestShareeLib/Model/Bike/TestBikeCollectionMutable.cs b/TestShareeLib/Model/Bike/TestBikeCollectionMutable.cs index 1dcdfbd..88400ca 100644 --- a/TestShareeLib/Model/Bike/TestBikeCollectionMutable.cs +++ b/TestShareeLib/Model/Bike/TestBikeCollectionMutable.cs @@ -4,9 +4,8 @@ using System.Collections.Generic; using TINK.Model.Bike; using TINK.Model.Bikes.Bike; using TINK.Model.State; - +using TINK.Model.Station; using BikeInfo = TINK.Model.Bike.BC.BikeInfo; -using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable; namespace TestTINKLib { @@ -23,11 +22,12 @@ namespace TestTINKLib WheelType? wheelType = null, TypeOfBike? typeOfBike = null, string description = null, - string currentStationId = null, + string stationId = null, + string stationName = null, Uri operatorUri = null, TariffDescription tariffDescription = null, Func 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.Null(l_oBikeColl.GetById("33")); - l_oBikeColl.Update(null); + l_oBikeColl.Update(null, null ); // Verify modified state Assert.Null(l_oBikeColl.GetById("63")); @@ -74,36 +74,114 @@ namespace TestTINKLib [Test] public void TestUpdate() { - var l_oBikeRequested = new BikeInfoMutable("20", false, new List { "TINK" }, WheelType.Trike, TypeOfBike.Allround); - l_oBikeRequested.State.Load(new StateInfo(() => DateTime.Now, DateTime.Now, "john@long", "1234")); + var bikeRequested = new BikeInfoMutable("20", false, new List { "TINK" }, WheelType.Trike, TypeOfBike.Allround); + 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 { "TINK" }, WheelType.Two, TypeOfBike.Allround), new BikeInfoMutable("57", false, new List { "TINK" }, WheelType.Trike, TypeOfBike.Cargo), - l_oBikeRequested, + bikeRequested, }; // Verify initial state - Assert.NotNull(l_oBikeColl.GetById("63")); // Will be removed - Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeColl.GetById("57").State.Value); // Will be requested - Assert.AreEqual(InUseStateEnum.Reserved, l_oBikeColl.GetById("20").State.Value); // Will be booked - Assert.Null(l_oBikeColl.GetById("33")); // + Assert.NotNull(bikeColl.GetById("63")); // Will be removed + Assert.AreEqual(InUseStateEnum.Disposable, bikeColl.GetById("57").State.Value); // Will be requested + Assert.AreEqual(InUseStateEnum.Reserved, bikeColl.GetById("20").State.Value); // Will be booked + Assert.Null(bikeColl.GetById("33")); // var l_oBikeResponse = new List { - new BikeInfo("57", false, new List {"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 {"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 {"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 {"TINK" }, WheelType.Trike, TypeOfBike.Allround), }; - l_oBikeColl.Update(l_oBikeResponse); + + bikeColl.Update(l_oBikeResponse, new List()); // Verify modified state - Assert.Null(l_oBikeColl.GetById("63")); - Assert.AreEqual(InUseStateEnum.Booked, l_oBikeColl.GetById("57").State.Value); - Assert.AreEqual(InUseStateEnum.Booked, l_oBikeColl.GetById("20").State.Value); - Assert.NotNull(l_oBikeColl.GetById("33")); + Assert.Null(bikeColl.GetById("63"), "Bike not contained in response must not exist."); + Assert.AreEqual(InUseStateEnum.Booked, bikeColl.GetById("57").State.Value); + Assert.AreEqual(InUseStateEnum.Booked, bikeColl.GetById("20").State.Value); + Assert.NotNull(bikeColl.GetById("33")); + } + + /// + /// Bike for which station name is updated is not contained in bike collection when calling update. + /// + [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 + { + new BikeInfo("57" /* bike id*/, false, new List {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"), + }; + + var stations = new List + { + new Station("7", new List(), 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 { "TINK" }, WheelType.Trike, TypeOfBike.Cargo), + }; + + // Verify initial state + Assert.That(bikeColl.GetById("57"), Is.Not.Null); + + var bikeResponse = new List + { + new BikeInfo("57" /* bike id*/, false, new List {"TINK" }, WheelType.Trike, TypeOfBike.Allround, "Test description", "7" /*station id*/, null /*operator uri*/, null, DateTime.Now, "john@long,", "1234"), + }; + + var stations = new List + { + new Station("7", new List(), 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 + { + new BikeInfo("57" /* bike id*/, false, new List {"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("")); } } } diff --git a/TestShareeLib/Model/Connector/TestUpdaterJSON.cs b/TestShareeLib/Model/Connector/TestUpdaterJSON.cs index 2e8e374..6ec7e0f 100644 --- a/TestShareeLib/Model/Connector/TestUpdaterJSON.cs +++ b/TestShareeLib/Model/Connector/TestUpdaterJSON.cs @@ -352,7 +352,7 @@ namespace TestTINKLib.Fixtures.Connector Assert.That(btBikeReserved.TariffDescription.MaxFeeEuroPerDay, Is.EqualTo(10)); Assert.That(btBikeReserved.TariffDescription.Number, Is.EqualTo(5494)); 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.OperatorUri.AbsoluteUri, Does.Contain("https://shareeapp-fr01.copri.eu")); 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.Number, Is.EqualTo(5494)); 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.OperatorUri.AbsoluteUri, Does.Contain("https://shareeapp-fr01.copri.eu")); Assert.That(btBikeRented.Group.Count, Is.EqualTo(1)); @@ -662,23 +662,24 @@ namespace TestTINKLib.Fixtures.Connector { // Construct requested bike. var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo( - "17", - 22, - new Guid("0000f00d-1212-efde-1523-785fef13d123"), - new [] { (byte) 1, (byte)3, (byte)4 }, - new [] { (byte)11, (byte)3, (byte)1 }, - new [] { (byte)12, (byte)7, (byte)4 }, - DateTime.Now, - "a@b", - "1", - null, - null, - () => DateTime.Now, - false, /*isDemo*/ - null, /*group*/ - null, /*wheelType*/ - null, /*typeOfBike*/ - null /*description*/)); + "17", + 22, + new Guid("0000f00d-1212-efde-1523-785fef13d123"), + new [] { (byte) 1, (byte)3, (byte)4 }, + new [] { (byte)11, (byte)3, (byte)1 }, + new [] { (byte)12, (byte)7, (byte)4 }, + DateTime.Now, + "a@b", + "1", + null, + null, + () => DateTime.Now, + false, /*isDemo*/ + null, /*group*/ + null, /*wheelType*/ + null, /*typeOfBike*/ + null /*description*/), + "My Station Name"); var response = JsonConvert.DeserializeObject(@" { @@ -702,16 +703,17 @@ namespace TestTINKLib.Fixtures.Connector { // Construct occupied bike. var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo( - "17", - 22, - new Guid("0000f00d-1212-efde-1523-785fef13d123"), - new[] { (byte)1, (byte)3, (byte)4 }, - new[] { (byte)11, (byte)3, (byte)1 }, - new[] { (byte)12, (byte)7, (byte)4 }, - DateTime.Now, - "a@b", - "1", - null /*operator uri*/)); + "17", + 22, + new Guid("0000f00d-1212-efde-1523-785fef13d123"), + new[] { (byte)1, (byte)3, (byte)4 }, + new[] { (byte)11, (byte)3, (byte)1 }, + new[] { (byte)12, (byte)7, (byte)4 }, + DateTime.Now, + "a@b", + "1", + null /*operator uri*/), + "My Station Name"); var response = JsonConvert.DeserializeObject(@" { @@ -735,23 +737,24 @@ namespace TestTINKLib.Fixtures.Connector { // Construct requested bike. var bike = new TINK.Model.Bike.BluetoothLock.BikeInfoMutable(new BikeInfo( - "17", - 22, - new Guid("0000f00d-1212-efde-1523-785fef13d123"), - new[] { (byte)1, (byte)3, (byte)4 }, - new[] { (byte)11, (byte)3, (byte)1 }, - new[] { (byte)12, (byte)7, (byte)4 }, - DateTime.Now, - "a@b", - "1", - null, - null, - () => DateTime.Now, - false, /*isDemo*/ - null, /*group*/ - null, /*wheelType*/ - null, /*typeOfBike*/ - null /*description*/)); + "17", + 22, + new Guid("0000f00d-1212-efde-1523-785fef13d123"), + new[] { (byte)1, (byte)3, (byte)4 }, + new[] { (byte)11, (byte)3, (byte)1 }, + new[] { (byte)12, (byte)7, (byte)4 }, + DateTime.Now, + "a@b", + "1", + null, + null, + () => DateTime.Now, + false, /*isDemo*/ + null, /*group*/ + null, /*wheelType*/ + null, /*typeOfBike*/ + null /*description*/), + "My Station Name"); Assert.AreEqual(InUseStateEnum.Reserved, bike.State.Value); diff --git a/TestShareeLib/Model/TestTinkApp.cs b/TestShareeLib/Model/TestTinkApp.cs index f55cca7..dea5b9c 100644 --- a/TestShareeLib/Model/TestTinkApp.cs +++ b/TestShareeLib/Model/TestTinkApp.cs @@ -13,6 +13,7 @@ using Plugin.Permissions.Abstractions; using TestShareeLib.Repository; using TestFramework.Repository; +using TINK.Repository; namespace TestTINKLib.Fixtures.UseCases.Logout { @@ -42,8 +43,9 @@ namespace TestTINKLib.Fixtures.UseCases.Logout activeUri: new Uri(CopriServerUriList.TINK_DEVEL)), accountStore, (isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie) - ? new ConnectorCache(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()) + : new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + "MyMerchId", Substitute.For>(), locksService, device, diff --git a/TestShareeLib/Model/TestTinkAppLogin.cs b/TestShareeLib/Model/TestTinkAppLogin.cs index 267bcf0..ee4e179 100644 --- a/TestShareeLib/Model/TestTinkAppLogin.cs +++ b/TestShareeLib/Model/TestTinkAppLogin.cs @@ -12,6 +12,7 @@ using TINK.Model.User.Account; using Plugin.Permissions.Abstractions; using System.Threading.Tasks; using TestFramework.Repository; +using TINK.Repository; namespace TestShareeLib.UseCases.Login { @@ -28,15 +29,16 @@ namespace TestShareeLib.UseCases.Login var permissions = Substitute.For(); // No user logged in is initial state to verify. - var l_oTinkApp = new TinkApp( + var tinkApp = new TinkApp( new TINK.Model.Settings.Settings( activeLockService: locksService.GetType().FullName, activeGeolocationService: "NotRelevantActiveGeoloactionServiceName", activeUri: new Uri(CopriServerUriList.TINK_DEVEL)), accountStore, (isConnected, uri, sessionCookie, mail, expiresAfter) => string.IsNullOrEmpty(sessionCookie) - ? new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001()) as IConnector - : new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + ? new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001()) + : new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + "MyMerchId", Substitute.For>(), locksService, device, @@ -47,31 +49,32 @@ namespace TestShareeLib.UseCases.Login 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*/); - Assert.IsFalse(l_oTinkApp.ActiveUser.IsLoggedIn); + // Verifiy initial state. + Assert.IsFalse(tinkApp.ActiveUser.IsLoggedIn); Assert.AreEqual( 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"); Assert.AreEqual( 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."); - Assert.IsNull(l_oTinkApp.GetConnector(true).Command.SessionCookie); + Assert.IsNull(tinkApp.GetConnector(true).Command.SessionCookie); - // Log user out. - var l_oAccount = l_oTinkApp.GetConnector(true).Command.DoLogin("javaminister@gmail.com", "*********", "HwId1000000000000").Result; - await l_oTinkApp.ActiveUser.Login(l_oAccount); + // Log in user. + var account = tinkApp.GetConnector(true).Command.DoLogin("javaminister@gmail.com", "*********", "HwId1000000000000").Result; + await tinkApp.ActiveUser.Login(account); - Assert.IsTrue(l_oTinkApp.ActiveUser.IsLoggedIn); + Assert.IsTrue(tinkApp.ActiveUser.IsLoggedIn); Assert.AreEqual( 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."); Assert.AreEqual( 2, - l_oTinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count, + tinkApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response.Count, "Javaminster occupies 2 bikes."); - Assert.AreEqual("6103_112e96b36ba33de245943c5ffaf369cd_", l_oTinkApp.GetConnector(true).Command.SessionCookie); + Assert.AreEqual("6103_112e96b36ba33de245943c5ffaf369cd_oiF2kahH", tinkApp.GetConnector(true).Command.SessionCookie); } } } diff --git a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikesAtStationPageViewModel.cs b/TestShareeLib/ViewModel/BikesAtStation/TestBikesAtStationPageViewModel.cs similarity index 92% rename from TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikesAtStationPageViewModel.cs rename to TestShareeLib/ViewModel/BikesAtStation/TestBikesAtStationPageViewModel.cs index dd5af82..89aa0ba 100644 --- a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikesAtStationPageViewModel.cs +++ b/TestShareeLib/ViewModel/BikesAtStation/TestBikesAtStationPageViewModel.cs @@ -1,35 +1,34 @@ -using NUnit.Framework; +using NSubstitute; +using NSubstitute.ExceptionExtensions; +using NUnit.Framework; +using Plugin.BLE.Abstractions.Contracts; using System; using System.Collections.Generic; using System.Linq; 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.Connector; -using TINK.Repository.Exception; -using TINK.View; +using TINK.Model.Device; using TINK.Model.Services.CopriApi; +using TINK.Model.Services.Geolocation; using TINK.Repository; - -using static TINK.Repository.CopriCallsMemory; -using TINK.ViewModel.Map; -using TINK.ViewModel.Settings; -using Plugin.BLE.Abstractions.Contracts; +using TINK.Repository.Exception; +using TINK.Services; using TINK.Services.BluetoothLock; -using NSubstitute; -using TINK.ViewModel.BikesAtStation; -using Xamarin.Forms; using TINK.Services.BluetoothLock.Tdo; using TINK.Services.Permissions; -using TINK.Model.Services.Geolocation; -using NSubstitute.ExceptionExtensions; -using TINK.Services; -using TINK.Model.Device; -using TestFramework.Model.Device; -using TestFramework.Repository; -using TestFramework.Model.User.Account; -using TestFramework.Model.Services.Geolocation; -using TestFramework.Services.Permissions; -using TestFramework.Services.CopriApi.Connector; +using TINK.View; +using TINK.ViewModel.BikesAtStation; +using TINK.ViewModel.Map; +using TINK.ViewModel.Settings; +using Xamarin.Forms; +using static TINK.Repository.CopriCallsMemory; namespace TestTINKLib.Fixtures.ObjectTests.ViewModel { @@ -48,15 +47,16 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel var tinkApp = new TinkApp( new TINK.Model.Settings.Settings( - new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), + new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new TINK.Settings.PollingParameters(new TimeSpan(10000), true), Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("", null, null, new List())), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("", null, false, null, new List())), + (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + "MyMerchId", geolocation, locksService, new DeviceMock(), @@ -127,8 +127,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, new DeviceMock(), @@ -204,8 +205,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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 locksService, 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 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 12. October 08:38.", bike1537.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 {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText); Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Close lock", bike1545.LockitButtonText); @@ -296,6 +298,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel } ); + bluetooth.State.Returns(BluetoothState.On); + var tinkApp = new TinkApp( new TINK.Model.Settings.Settings( new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), @@ -305,8 +309,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, 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 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 12. October 08:38.", bike1537.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 {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText); Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Search lock", bike1545.LockitButtonText); @@ -412,8 +417,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, 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 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 12. October 08:38.", bike1537.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 {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText); Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Search lock", bike1545.LockitButtonText); @@ -516,8 +522,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, 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 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 12. October 08:38.", bike1537.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 {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText); Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Search lock", bike1545.LockitButtonText); @@ -618,8 +625,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, 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 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 12. October 08:38.", bike1537.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 {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText); Assert.AreEqual("Available.", bike1315.StateText); Assert.AreEqual("Available.", bike1543.StateText); Assert.AreEqual("Search lock", bike1545.LockitButtonText); @@ -705,7 +713,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel var tinkApp = new TinkApp( new TINK.Model.Settings.Settings( - new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }), + new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), new GroupFilterSettings(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new TINK.Settings.PollingParameters(new TimeSpan(10000), true), @@ -713,7 +721,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), locksService, new DeviceMock(), @@ -786,7 +795,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), locksService, new DeviceMock(), @@ -846,7 +856,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel var tinkApp = new TinkApp( new TINK.Model.Settings.Settings( - new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), + new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), 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( LoginSessionCopriInfo.JavaministerHardwareNr1.Mail, LoginSessionCopriInfo.JavaministerHardwareNr1.Pwd, + false, "6103_112e96b36ba33de245943c5ffaf369cd_", // Was 4da3044c8657a04ba60e2eaa753bc51a before switching from data provider CopriCallsMemory(SampleSets.Set2, 1, ...) new List { 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>(), locksService, 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("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 Assert.IsFalse(bikesAtStation.IsLoginRequiredHintVisible); @@ -923,7 +935,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel var tinkApp = new TinkApp( new TINK.Model.Settings.Settings( - new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), + new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new TINK.Settings.PollingParameters(new TimeSpan(10000), true), @@ -931,7 +943,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), locksService, new DeviceMock(), @@ -994,7 +1007,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel var tinkApp = new TinkApp( new TINK.Model.Settings.Settings( - new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), + new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new TINK.Settings.PollingParameters(new TimeSpan(10000), true), @@ -1014,6 +1027,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel sessionCookie: sessionCookie, cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))), + "MyMerchId", Substitute.For>(), locksService, new DeviceMock(), @@ -1079,7 +1093,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel var tinkApp = new TinkApp( new TINK.Model.Settings.Settings( - new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.Off } }), + new GroupFilterMapPage(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.Off }, { FilterHelper.CITYBIKE, FilterState.On } }), new GroupFilterSettings(new Dictionary { { FilterHelper.CARGOBIKE, FilterState.On }, { FilterHelper.CITYBIKE, FilterState.On } }), new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"), new TINK.Settings.PollingParameters(new TimeSpan(10000), @@ -1100,6 +1114,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel sessionCookie: sessionCookie, cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), httpsServer: new ExceptionServer((msg) => new Exception(msg)))), + "MyMerchId", Substitute.For>(), locksService, new DeviceMock(), diff --git a/TestTINKLib/Fixtures/ObjectTests/Bike/BC/TestBikeInfo.cs b/TestTINKLib/Fixtures/ObjectTests/Bike/BC/TestBikeInfo.cs deleted file mode 100644 index 767faa7..0000000 --- a/TestTINKLib/Fixtures/ObjectTests/Bike/BC/TestBikeInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NUnit.Framework; -using TINK.Model.Bike.BC; - -namespace TestTINKLib.Fixtures.ObjectTests.Bike.BC -{ - /// - /// Moved to TestShareeLib (.Net Core) - /// - [TestFixture] - public class TestBikeInfo - { - [Test] - public void TestCtorCopyNull() - { - Assert.Throws( - () => new BikeInfo(null), - "Verify that no unspecific reference not set to... exception is thrown"); - } - } -} diff --git a/TestTINKLib/Fixtures/ObjectTests/Bike/BC/TestBikeInfoMutable.cs b/TestTINKLib/Fixtures/ObjectTests/Bike/BC/TestBikeInfoMutable.cs index c163684..4eec30a 100644 --- a/TestTINKLib/Fixtures/ObjectTests/Bike/BC/TestBikeInfoMutable.cs +++ b/TestTINKLib/Fixtures/ObjectTests/Bike/BC/TestBikeInfoMutable.cs @@ -22,11 +22,12 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike WheelType? wheelType = null, TypeOfBike? typeOfBike = null, string description = null, - string currentStationId = null, + string stationId = null, + string stationName = null, Uri operatorUri = null, TariffDescription tariffDescription = null, Func 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"); 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(null, l_oBikeInfo.WheelType); Assert.AreEqual(null, l_oBikeInfo.TypeOfBike); @@ -44,7 +45,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike l_oBikeInfo = new BikeInfoMutable("22", false, new List { "TINK" }, WheelType.Trike, TypeOfBike.Cargo, "Test description", "23"); Assert.AreEqual("22", l_oBikeInfo.Id); 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(WheelType.Trike, l_oBikeInfo.WheelType); 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.TypeOfBike).Return(TypeOfBike.Cargo); 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_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.MailAddress).Return("a@b"); 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("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(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike); 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.TypeOfBike).Return(TypeOfBike.Cargo); 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_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.MailAddress).Return("a@b"); 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("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(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike); 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.TypeOfBike).Return(TypeOfBike.Cargo); 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_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("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(TypeOfBike.Cargo, l_oBikeInfo.TypeOfBike); Assert.AreEqual(InUseStateEnum.Disposable, l_oBikeInfo.State.Value); diff --git a/TestTINKLib/Fixtures/ObjectTests/Connector/TestConnectorCache.cs b/TestTINKLib/Fixtures/ObjectTests/Connector/TestConnectorCache.cs index 51ab920..4ff330c 100644 --- a/TestTINKLib/Fixtures/ObjectTests/Connector/TestConnectorCache.cs +++ b/TestTINKLib/Fixtures/ObjectTests/Connector/TestConnectorCache.cs @@ -1,5 +1,6 @@ using NUnit.Framework; using Rhino.Mocks; +using System; using TINK.Model.Connector; using TINK.Repository; @@ -18,6 +19,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector // Construct not logged in version of connector. var l_oCommand = new ConnectorCache( + new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), "", // Not logged in "", l_oCopri).Command; @@ -34,6 +36,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector var l_oCopri = MockRepository.GenerateStub(); var l_oCommand = new ConnectorCache( + new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), "123", // Logged in "a@b", l_oCopri).Command; @@ -50,6 +53,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector var l_oCopri = MockRepository.GenerateStub(); var l_oQuery = new ConnectorCache( + new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), "", "", l_oCopri).Query; @@ -66,6 +70,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector var l_oCopri = MockRepository.GenerateStub(); var l_oQuery = new ConnectorCache( + new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), "123", "a@b", l_oCopri).Query; diff --git a/TestTINKLib/Fixtures/ObjectTests/Connector/TestFilter.cs b/TestTINKLib/Fixtures/ObjectTests/Connector/TestFilter.cs index be93102..8ef0522 100644 --- a/TestTINKLib/Fixtures/ObjectTests/Connector/TestFilter.cs +++ b/TestTINKLib/Fixtures/ObjectTests/Connector/TestFilter.cs @@ -5,6 +5,7 @@ using TINK.Model.Connector; using System.Linq; using TINK.Repository; using TestFramework.Repository; +using System; namespace TestTINKLib.Fixtures.ObjectTests.Connector { @@ -17,6 +18,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector public void TestGetStationsAll() { var connector = new ConnectorCache( + new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), string.Empty, string.Empty, new CopriCallsMemory001()); @@ -51,6 +53,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector public void TestGetBikesAll() { var l_oConnector = new ConnectorCache( + new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), string.Empty, string.Empty, new CopriCallsMemory001()); diff --git a/TestTINKLib/Fixtures/ObjectTests/Connector/TestTextToTypeHelper.cs b/TestTINKLib/Fixtures/ObjectTests/Connector/TestTextToTypeHelper.cs index d44f814..84ac15d 100644 --- a/TestTINKLib/Fixtures/ObjectTests/Connector/TestTextToTypeHelper.cs +++ b/TestTINKLib/Fixtures/ObjectTests/Connector/TestTextToTypeHelper.cs @@ -614,5 +614,56 @@ namespace TestTINKLib.Fixtures.Connector () => version.GetCopriVersion(), Throws.InstanceOf()); } + + [Test] + public void TestGetIsAgbAcknowledged() + { + var response = JsonConvertRethrow.DeserializeObject(@" + { + ""agb_checked"" : ""1"" + }"); + + Assert.That( + () => response.GetIsAgbAcknowledged(), + Is.True); + } + + [Test] + public void TestGetIsAgbAcknowledged_No() + { + var response = JsonConvertRethrow.DeserializeObject(@" + { + ""agb_checked"" : ""0"" + }"); + + Assert.That( + () => response.GetIsAgbAcknowledged(), + Is.False); + } + + [Test] + public void TestGetIsAgbAcknowledged_Invalid() + { + var response = JsonConvertRethrow.DeserializeObject(@" + { + ""agb_checked"" : ""ä"" + }"); + + Assert.That( + () => response.GetIsAgbAcknowledged(), + Is.False); + } + + [Test] + public void TestGetIsAgbAcknowledged_Empty() + { + var response = JsonConvertRethrow.DeserializeObject(@" + { + }"); + + Assert.That( + () => response.GetIsAgbAcknowledged(), + Is.False); + } } } diff --git a/TestTINKLib/Fixtures/ObjectTests/User/Account/TestAccount.cs b/TestTINKLib/Fixtures/ObjectTests/User/Account/TestAccount.cs index 39e6e19..3c3e534 100644 --- a/TestTINKLib/Fixtures/ObjectTests/User/Account/TestAccount.cs +++ b/TestTINKLib/Fixtures/ObjectTests/User/Account/TestAccount.cs @@ -14,6 +14,7 @@ namespace UITest.Fixtures.ObjectTests.User.Account var account = new TINK.Model.User.Account.Account( "hans.musterman@hotmail.com", // Mail "myPasswd", // Pwd + false, "aktuellerKeks", // Cookie new List { "Honkey", "Tonkey" }, // Group TINK.Model.User.Account.Permissions.None); @@ -21,6 +22,7 @@ namespace UITest.Fixtures.ObjectTests.User.Account // Assert Assert.AreEqual("hans.musterman@hotmail.com", account.Mail); Assert.AreEqual("myPasswd", account.Pwd); + Assert.That(account.IsAgbAcknowledged, Is.False); Assert.AreEqual("aktuellerKeks", account.SessionCookie); Assert.AreEqual("Honkey,Tonkey", String.Join(",", account.Group)); Assert.AreEqual(TINK.Model.User.Account.Permissions.None, account.DebugLevel); @@ -29,19 +31,26 @@ namespace UITest.Fixtures.ObjectTests.User.Account [Test] 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 { "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 { "Honkey", "Tonkey" }, + TINK.Model.User.Account.Permissions.None)); - Assert.AreEqual("a@b", l_oAccount.Mail); - Assert.AreEqual("112", l_oAccount.Pwd); - Assert.AreEqual("3330", l_oAccount.SessionCookie); - Assert.AreEqual("Honkey,Tonkey", String.Join(",", l_oAccount.Group)); - Assert.AreEqual(TINK.Model.User.Account.Permissions.None, l_oAccount.DebugLevel); + Assert.AreEqual("a@b", account.Mail); + Assert.AreEqual("112", account.Pwd); + Assert.That(account.IsAgbAcknowledged, Is.False); + Assert.AreEqual("3330", account.SessionCookie); + Assert.AreEqual("Honkey,Tonkey", String.Join(",", account.Group)); + Assert.AreEqual(TINK.Model.User.Account.Permissions.None, account.DebugLevel); } [Test] public void TestConstruct_InvalidGroup() { - Assert.Throws(() => new TINK.Model.User.Account.Account("a@b", "112", "3330", null, TINK.Model.User.Account.Permissions.None)); + Assert.Throws(() => new TINK.Model.User.Account.Account("a@b", "112", false, "3330", null, TINK.Model.User.Account.Permissions.None)); Assert.Throws(() => new TINK.Model.User.Account.Account(null)); } diff --git a/TestTINKLib/Fixtures/ObjectTests/User/TestUser.cs b/TestTINKLib/Fixtures/ObjectTests/User/TestUser.cs index bc4f25e..15668c4 100644 --- a/TestTINKLib/Fixtures/ObjectTests/User/TestUser.cs +++ b/TestTINKLib/Fixtures/ObjectTests/User/TestUser.cs @@ -8,6 +8,8 @@ using TINK.Repository; using static TINK.Repository.CopriCallsMemory; using TestFramework.Model.User.Account; +using System; +using System.Threading.Tasks; namespace TestTINKLib { @@ -18,11 +20,11 @@ namespace TestTINKLib [Test] 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( - l_oStoreMock, - l_oStoreMock.Load().Result, + storeMock, + storeMock.Load().Result, "HwId1000000000000"); Assert.IsFalse(l_oUser.IsLoggedIn); @@ -34,23 +36,23 @@ namespace TestTINKLib [Test] public void TestConstruct_NotLoggedIn_NoCookie() { - var l_oStoreMock = new StoreMock(new Account("John", "123", null, new List())); // Account without session cookie. + var storeMock = new StoreMock(new Account("John", "123", true, null, new List())); // Account without session cookie. - var l_oUser = new User( - l_oStoreMock, - l_oStoreMock.Load().Result, + var user = new User( + storeMock, + storeMock.Load().Result, "123456789"); - Assert.IsFalse(l_oUser.IsLoggedIn); - Assert.AreEqual("John", l_oUser.Mail); - Assert.AreEqual("123", l_oUser.Password); - Assert.IsNull(l_oUser.SessionCookie); + Assert.IsFalse(user.IsLoggedIn); + Assert.AreEqual("John", user.Mail); + Assert.AreEqual("123", user.Password); + Assert.IsNull(user.SessionCookie); } [Test] public void TestConstruct_LoggedIn() { - var l_oStoreMock = new StoreMock(new Account("John", "123", "9512", new List { "TINK" })); + var l_oStoreMock = new StoreMock(new Account("John", "123", false, "9512", new List { "TINK" })); var l_oUser = new User( l_oStoreMock, @@ -66,9 +68,10 @@ namespace TestTINKLib /// Test logging in. [Test] - public void TestSetCredentials() + public async Task TestSetCredentials() { var l_oConnector = new ConnectorCache( + new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), string.Empty, string.Empty, new CopriCallsMemory(SampleSets.Set2, 1)); @@ -88,7 +91,7 @@ namespace TestTINKLib LoginSessionCopriInfo.JavaministerHardwareNr1.Pwd, l_oUser.DeviceId).Result; - l_oUser.Login(l_oAccount); + await l_oUser.Login(l_oAccount); Assert.IsTrue(l_oUser.IsLoggedIn); Assert.AreEqual(LoginSessionCopriInfo.JavaministerHardwareNr1.Mail, l_oUser.Mail); diff --git a/TestTINKLib/Fixtures/ObjectTests/ViewModel/Account/TestAccountPageViewModel.cs b/TestTINKLib/Fixtures/ObjectTests/ViewModel/Account/TestAccountPageViewModel.cs index d938736..8209f94 100644 --- a/TestTINKLib/Fixtures/ObjectTests/ViewModel/Account/TestAccountPageViewModel.cs +++ b/TestTINKLib/Fixtures/ObjectTests/ViewModel/Account/TestAccountPageViewModel.cs @@ -43,7 +43,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), @@ -81,8 +82,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account Serilog.Events.LogEventLevel.Error, activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "UnknownCookie", new List { "TINK" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "UnknownCookie", new List { "TINK" })), + (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>(), new LocksServiceMock(), new DeviceMock(), @@ -121,8 +123,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account Serilog.Events.LogEventLevel.Error, activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "6103_112e96b36ba33de245943c5ffaf369cd_", new List { "TINK" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "6103_112e96b36ba33de245943c5ffaf369cd_", new List { "TINK" })), + (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + "MyMerchId", Substitute.For>(), new LocksServiceMock(), new DeviceMock(), @@ -160,8 +163,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account Serilog.Events.LogEventLevel.Error, activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "6103_112e96b36ba33de245943c5ffaf369cd_", new List { "TINK" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "6103_112e96b36ba33de245943c5ffaf369cd_", new List { "TINK" })), + (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001(sessionCookie)), + "MyMerchId", Substitute.For>(), new LocksServiceMock(), new DeviceMock(), @@ -199,7 +203,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account Serilog.Events.LogEventLevel.Error, activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "6103_112e96b36ba33de245943c5ffaf369cd_", new List { "TINK" })), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "6103_112e96b36ba33de245943c5ffaf369cd_", new List { "TINK" })), (isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector( uri, new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), @@ -212,6 +216,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account sessionCookie: sessionCookie, cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))), + "MyMerchId", Substitute.For>(), new LocksServiceMock(), new DeviceMock(), diff --git a/TestTINKLib/Fixtures/ObjectTests/ViewModel/Bikes/Bike/BluetoothLock/TestRequestHandlerFactory.cs b/TestTINKLib/Fixtures/ObjectTests/ViewModel/Bikes/Bike/BluetoothLock/TestRequestHandlerFactory.cs index 110a2d2..34fbea0 100644 --- a/TestTINKLib/Fixtures/ObjectTests/ViewModel/Bikes/Bike/BluetoothLock/TestRequestHandlerFactory.cs +++ b/TestTINKLib/Fixtures/ObjectTests/ViewModel/Bikes/Bike/BluetoothLock/TestRequestHandlerFactory.cs @@ -24,7 +24,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock public void TestCreate() { // 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(LockingState.Disconnected, bike.LockInfo.State); Assert.AreEqual( @@ -42,7 +44,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock MockRepository.GenerateStub()).GetType()); // 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(), 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(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround), + "My Station Name"); Assert.AreEqual( typeof(ReservedDisconnected), RequestHandlerFactory.Create( @@ -58,7 +62,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock MockRepository.GenerateStub()).GetType()); // 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(), 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(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround), + "My Station Name"); bike.LockInfo.State = LockingState.Closed; Assert.AreEqual( typeof(ReservedClosed), @@ -75,7 +81,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock MockRepository.GenerateStub()).GetType()); // 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(), 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(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround), + "My Station Name"); bike.LockInfo.State = LockingState.Open; Assert.AreEqual( typeof(ReservedOpen), @@ -92,7 +100,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock MockRepository.GenerateStub()).GetType()); // 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(), 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(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround), + "My Station Name"); bike.LockInfo.State = LockingState.Closed; Assert.AreEqual( typeof(BookedClosed), @@ -109,7 +119,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock MockRepository.GenerateStub()).GetType()); // 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(), 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(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround), + "My Station Name"); bike.LockInfo.State = LockingState.Open; Assert.AreEqual( typeof(BookedOpen), @@ -126,7 +138,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.Bike.BluetoothLock MockRepository.GenerateStub()).GetType()); // 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(), 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(), TINK.Model.Bike.WheelType.Mono, TINK.Model.Bike.TypeOfBike.Allround), + "My Station Name"); Assert.AreEqual( typeof(BookedDisconnected), diff --git a/TestTINKLib/Fixtures/ObjectTests/ViewModel/Map/TestMapPageViewModel.cs b/TestTINKLib/Fixtures/ObjectTests/ViewModel/Map/TestMapPageViewModel.cs index e6d29f5..d75c8ae 100644 --- a/TestTINKLib/Fixtures/ObjectTests/ViewModel/Map/TestMapPageViewModel.cs +++ b/TestTINKLib/Fixtures/ObjectTests/ViewModel/Map/TestMapPageViewModel.cs @@ -43,7 +43,8 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), @@ -120,7 +121,8 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), @@ -194,7 +196,8 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), @@ -263,7 +266,8 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), @@ -332,7 +336,8 @@ namespace TestShareeLib.UseCases.Startup activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), @@ -416,6 +421,7 @@ namespace TestShareeLib.UseCases.Startup sessionCookie: sessionCookie, cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))), + "MyMerchId", Substitute.For>(), new LocksServiceMock(), new DeviceMock(), @@ -500,6 +506,7 @@ namespace TestShareeLib.UseCases.Startup sessionCookie: sessionCookie, cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie), httpsServer: new ExceptionServer((msg) => new Exception(msg)))), + "MyMerchId", Substitute.For>(), new LocksServiceMock(), new DeviceMock(), diff --git a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeAtStationViewModel.cs b/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeAtStationViewModel.cs index 37cd437..0f2785a 100644 --- a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeAtStationViewModel.cs +++ b/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeAtStationViewModel.cs @@ -24,16 +24,17 @@ namespace UITest.Fixtures.ViewModel private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable { public BikeInfoMutable( - string p_iId, - bool p_bIsDemo = false, - IEnumerable p_oGroup = null, - WheelType? p_eWheelType = null, - TypeOfBike? p_eTypeOfBike = null, + string id, + bool isDemo = false, + IEnumerable group = null, + WheelType? wheelType = null, + TypeOfBike? typeOfBike = null, string description = null, - string p_strCurrentStationName = null, + string stationId = null, + string stationName = null, Uri operatorUri = null, Func 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", "4asdfA"); - var l_oStoreMock = new StoreMock(new Account("john@long", "123456789" /* password */, "987654321" /* session cookie */, new List { "TINK" })); + var l_oStoreMock = new StoreMock(new Account("john@long", "123456789" /* password */, false, "987654321" /* session cookie */, new List { "TINK" })); var l_oViewModel = new TINK.ViewModel.Bikes.Bike.BC.BikeViewModel( null, @@ -196,7 +197,7 @@ namespace UITest.Fixtures.ViewModel "ragu@gnu-systems.de", "4asdfA"); - var l_oStoreMock = new StoreMock(new Account("john@long", "123456789" /* password */, "987654321" /* session cookie */, new List { "TINK" })); + var l_oStoreMock = new StoreMock(new Account("john@long", "123456789" /* password */, false, "987654321" /* session cookie */, new List { "TINK" })); var l_oViewModel = new TINK.ViewModel.Bikes.Bike.BC.BikeViewModel( null, diff --git a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModel.cs b/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModel.cs index fcbf5b9..1b8cf32 100644 --- a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModel.cs +++ b/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModel.cs @@ -17,16 +17,17 @@ namespace UITest.Fixtures.ViewModel private class BikeInfoMutable : TINK.Model.Bike.BC.BikeInfoMutable { public BikeInfoMutable( - string p_iId, - bool p_bIsDemo = false, - IEnumerable p_oGroup = null, - WheelType? p_eWheelType = null, - TypeOfBike? p_eTypeOfBike = null, + string id, + bool pisDemo = false, + IEnumerable group = null, + WheelType? wheelType = null, + TypeOfBike? typeOfBike = null, string description = null, - string p_strCurrentStationName = null, + string stationId = null, + string stationName = null, Uri operatorUri = null, Func 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, "Test description", "3", + "Radstation", null, () => 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. "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 { "TINK" })); + var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, false, "987654321" /* session cookie */, new List { "TINK" })); var l_oUser = new User( l_oStoreMock, l_oStoreMock.Load().Result, @@ -82,6 +84,7 @@ namespace UITest.Fixtures.ViewModel TypeOfBike.Cargo, "Test description", "3", + "Radstation", null, () => (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. "4asdfA"); // Reservation code from Copri - var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, "987654321" /* session cookie */, new List { "TINK" })); + var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, false, "987654321" /* session cookie */, new List { "TINK" })); var l_oUser = new User( l_oStoreMock, // Mocks account store functionality. l_oStoreMock.Load().Result, @@ -124,7 +127,7 @@ namespace UITest.Fixtures.ViewModel 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 { "TINK" })); + var l_oStoreMock = new StoreMock(new Account("ragu@gnu-systems.de", "123456789" /* password */, false, "987654321" /* session cookie */, new List { "TINK" })); var l_oUser = new User( l_oStoreMock, l_oStoreMock.Load().Result, diff --git a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModelFactory.cs b/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModelFactory.cs index a4d7655..cd9f498 100644 --- a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModelFactory.cs +++ b/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestBikeViewModelFactory.cs @@ -28,7 +28,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel null, // viewUpdateManager NSubstitute.Substitute.For(), 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(), // user MockRepository.GenerateStub(), MockRepository.GenerateStub()).GetType()); // stateInfoProvider @@ -44,7 +44,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel null, // viewUpdateManager NSubstitute.Substitute.For(), 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(), // user MockRepository.GenerateStub(), MockRepository.GenerateStub()).GetType()); // stateInfoProvider diff --git a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestMyBikesPageViewModel.cs b/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestMyBikesPageViewModel.cs index 064c42d..5f03959 100644 --- a/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestMyBikesPageViewModel.cs +++ b/TestTINKLib/Fixtures/ObjectTests/ViewModel/TestMyBikesPageViewModel.cs @@ -70,8 +70,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" } )), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" } )), + (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, locksService, new DeviceMock(), @@ -93,6 +94,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), geolocation.Active, // geolocation locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), @@ -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 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 12. October 08:38.", bike1537.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 {DateTime.Parse("2020-10-12 08:38:12.374231+02"):dd. MMMM HH:mm}.", bike1537.StateText); Assert.AreEqual("Close lock", bike1545.LockitButtonText); Assert.AreEqual("Open lock & continue renting", bike1537.LockitButtonText); @@ -161,8 +163,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, new DeviceMock(), @@ -184,6 +187,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), geolocation.Active, // geolocation locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), @@ -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 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 12. October 08:38.", bike1537.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 {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", bike1537.LockitButtonText); @@ -260,8 +264,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, new DeviceMock(), @@ -283,6 +288,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), geolocation.Active, // geolocation locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), @@ -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 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 12. October 08:38.", bike1537.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 {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", bike1537.LockitButtonText); @@ -354,8 +360,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, new DeviceMock(), @@ -377,6 +384,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), geolocation.Active, // geolocation locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), @@ -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 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 12. October 08:38.", bike1537.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 {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", bike1537.LockitButtonText); @@ -446,8 +454,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "5781_d47fc786e740ef77d85a24bcb6f0ff97_oiF2kahH", new List { "300001", "300029" })), + (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, locksService, new DeviceMock(), @@ -469,6 +478,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), geolocation.Active, // geolocation locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), @@ -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 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 12. October 08:38.", bike1537.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 {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", bike1537.LockitButtonText); @@ -532,8 +542,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "Invalid_SessionCookie", new List { "TINK" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "Invalid_SessionCookie", new List { "TINK" })), + (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>(), locksService, new DeviceMock(), @@ -555,6 +566,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), new GeolocationMock(), locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), @@ -593,8 +605,9 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "4da3044c8657a04ba60e2eaa753bc51a", new List { "TINK" })), - (isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "4da3044c8657a04ba60e2eaa753bc51a", new List { "TINK" })), + (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>(), locksService, new DeviceMock(), @@ -616,6 +629,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), new GeolocationMock(), locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), @@ -657,7 +671,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "4da3044c8657a04ba60e2eaa753bc51a", new List { "TINK" })), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "4da3044c8657a04ba60e2eaa753bc51a", new List { "TINK" })), (isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector( uri, new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), @@ -670,6 +684,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel sessionCookie: sessionCookie, cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie), httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))), + "MyMerchId", Substitute.For>(), locksService, new DeviceMock(), @@ -691,6 +706,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), new GeolocationMock(), locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), @@ -735,7 +751,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel Serilog.Events.LogEventLevel.Error, activeLockService: locksService.GetType().FullName, activeGeolocationService: typeof(GeolocationMock).FullName), - new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "4da3044c8657a04ba60e2eaa753bc51a", new List { "TINK" })), + new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", false, "4da3044c8657a04ba60e2eaa753bc51a", new List { "TINK" })), (isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector( uri, new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), @@ -748,6 +764,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel sessionCookie: sessionCookie, cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie), httpsServer: new ExceptionServer((msg) => new Exception(msg)))), + "MyMerchId", Substitute.For>(), locksService, new DeviceMock(), @@ -769,6 +786,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel (isConnected) => tinkApp.GetConnector(isConnected), new GeolocationMock(), locksService, + tinkApp.Stations, tinkApp.Polling, (d, obj) => d(obj), Substitute.For(), diff --git a/TestTINKLib/Fixtures/UseCases/ConnectedOffline/TestTinkApp.cs b/TestTINKLib/Fixtures/UseCases/ConnectedOffline/TestTinkApp.cs index 958bad3..f64bbb9 100644 --- a/TestTINKLib/Fixtures/UseCases/ConnectedOffline/TestTinkApp.cs +++ b/TestTINKLib/Fixtures/UseCases/ConnectedOffline/TestTinkApp.cs @@ -27,7 +27,8 @@ namespace TestTINKLib.Fixtures.UseCases.ConnectedOffline activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), diff --git a/TestTINKLib/Fixtures/UseCases/SelectStation/TestTinkApp.cs b/TestTINKLib/Fixtures/UseCases/SelectStation/TestTinkApp.cs index 7479d7f..306c60e 100644 --- a/TestTINKLib/Fixtures/UseCases/SelectStation/TestTinkApp.cs +++ b/TestTINKLib/Fixtures/UseCases/SelectStation/TestTinkApp.cs @@ -25,6 +25,7 @@ namespace TestTINKLib.Fixtures.UseCases.SelectStation public void TestBikesAtStation_AccountStoreMock_NoUser_CopriMock_Set2() { var l_oConnector = new ConnectorCache( + new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), string.Empty, string.Empty, new CopriCallsMemory(SampleSets.Set2, 1)); @@ -39,7 +40,8 @@ namespace TestTINKLib.Fixtures.UseCases.SelectStation activeLockService: typeof(LocksServiceMock).FullName, activeGeolocationService: typeof(GeolocationMock).FullName), 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>(), new LocksServiceMock(), new DeviceMock(), @@ -50,25 +52,25 @@ namespace TestTINKLib.Fixtures.UseCases.SelectStation 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 - 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(), null); - Assert.AreEqual(3, TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, 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("11", TestHelper.GetBikesAtStation(l_oTinkApp.ActiveUser, l_oConnector, 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(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.Stations, l_oTinkApp.SelectedStation.Id).Result.GetById("25").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.Stations, l_oTinkApp.SelectedStation.Id).Result.GetById("2").Id); l_oTinkApp.SelectedStation = new TINK.Model.Station.Station("10", new List(), null); Assert.AreEqual( 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(), 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); } } } \ No newline at end of file diff --git a/TestTINKLib/Fixtures/UseCases/TestHelper.cs b/TestTINKLib/Fixtures/UseCases/TestHelper.cs index cbf85c1..5ac923c 100644 --- a/TestTINKLib/Fixtures/UseCases/TestHelper.cs +++ b/TestTINKLib/Fixtures/UseCases/TestHelper.cs @@ -1,7 +1,9 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using TINK.Model; using TINK.Model.Bike; +using TINK.Model.Station; using TINK.Model.User; namespace TestTINKLib.Fixtures.UseCases @@ -14,13 +16,14 @@ namespace TestTINKLib.Fixtures.UseCases public static async Task GetBikesAtStation( User user, TINK.Model.Connector.IConnector connector, - string selectedStation) + IEnumerable stations, + string selectedStationId) { var l_oBikesAtStation = new BikeCollectionMutable(); 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; } diff --git a/TestTINKLib/TestTINKLib.csproj b/TestTINKLib/TestTINKLib.csproj index e41ea41..a140323 100644 --- a/TestTINKLib/TestTINKLib.csproj +++ b/TestTINKLib/TestTINKLib.csproj @@ -47,7 +47,6 @@ - @@ -107,7 +106,6 @@ - @@ -116,7 +114,6 @@ -