Merge branch 'master' into US-166/location-permission

# Conflicts:
#	TINK/TINK/View/Map/MapPage.xaml.cs
#	TINKLib/ViewModel/Map/MapPageViewModel.cs
#	TestFramework/Services/Permissions/PermissionsMock.cs
#	TestTINKLib/TestTINKLib.csproj
This commit is contained in:
Tobias Reski 2021-11-15 10:06:55 +01:00
commit 30c4e4879b
80 changed files with 2737 additions and 481 deletions

View file

@ -4,9 +4,6 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TestTINKLib.Mocks.Connector;
using TestTINKLib.Mocks.Device;
using TestTINKLib.Mocks.Services;
using TestTINKLib.Model.User.Account;
using TINK.Model;
using TINK.Model.Connector;
using TINK.Repository.Exception;
@ -14,7 +11,6 @@ using TINK.View;
using TINK.Model.Services.CopriApi;
using TINK.Repository;
using static TINK.Repository.CopriCallsMemory;
using TINK.ViewModel.Map;
using TINK.ViewModel.Settings;
@ -22,6 +18,13 @@ using TINK.ViewModel.Account;
using TINK.Services;
using TINK.Model.Services.Geolocation;
using NSubstitute;
using TestFramework.Model.Device;
using TestFramework.Repository;
using TestFramework.Model.User.Account;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.BluetoothLock;
using TestFramework.Services.Permissions;
using TestFramework.Services.CopriApi.Connector;
namespace TestTINKLib.Fixtures.ObjectTests.Account
{
@ -99,7 +102,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
await settingsPageViewModel.OnAppearing();
Assert.AreEqual("Logged in as a@b at TINK.", settingsPageViewModel.LoggedInInfo);
Assert.AreEqual("Logged in as a@b.", settingsPageViewModel.LoggedInInfo);
Assert.IsFalse(settingsPageViewModel.IsBookingStateInfoVisible, "A user is logged but no bikes requested/ booked.");
Assert.AreEqual(string.Empty, settingsPageViewModel.BookingStateInfo);
}
@ -116,8 +119,8 @@ 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", "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "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", "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
new DeviceMock(),
@ -137,7 +140,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
await settingsPageViewModel.OnAppearing();
Assert.AreEqual("Logged in as a@b at TINK.", settingsPageViewModel.LoggedInInfo);
Assert.AreEqual("Logged in as a@b.", settingsPageViewModel.LoggedInInfo);
Assert.IsTrue(settingsPageViewModel.IsBookingStateInfoVisible, "A user is logged but no bikes requested/ booked.");
Assert.AreEqual("Aktuell 2 Fahrräder reserviert/ gebucht.", settingsPageViewModel.BookingStateInfo);
}
@ -154,8 +157,8 @@ 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", "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "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", "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
new DeviceMock(),
@ -175,7 +178,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
await settingsPageViewModel.OnAppearing();
Assert.AreEqual("Logged in as a@b at TINK.", settingsPageViewModel.LoggedInInfo);
Assert.AreEqual("Logged in as a@b.", settingsPageViewModel.LoggedInInfo);
Assert.IsTrue(settingsPageViewModel.IsBookingStateInfoVisible, "A user is logged but no bikes requested/ booked.");
Assert.AreEqual("Aktuell 2 Fahrräder reserviert/ gebucht. Verbindungsstatus: Offline.", settingsPageViewModel.BookingStateInfo);
}
@ -192,7 +195,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", "4da3044c8657a04ba60e2eaa753bc51a", new List<string> { "TINK" })),
new StoreMock(new TINK.Model.User.Account.Account("a@b", "123456789", "6103_112e96b36ba33de245943c5ffaf369cd_", new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new TINK.Model.Connector.Connector(
uri,
"TestTINKApp/3.0.127 AutomatedTestEnvirnoment/Default",
@ -203,7 +206,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
TinkApp.MerchantId,
"TestTINKApp/3.0.127 AutomatedTestEnvirnoment/Default",
sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory(SampleSets.Set2, sessionCookie: sessionCookie),
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
@ -224,7 +227,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Account
await settingsPageViewModel.OnAppearing();
Assert.AreEqual("Logged in as a@b at TINK.", settingsPageViewModel.LoggedInInfo);
Assert.AreEqual("Logged in as a@b.", settingsPageViewModel.LoggedInInfo); // CopriCallsCacheMemory(SampleSets.Set2,
Assert.IsTrue(settingsPageViewModel.IsBookingStateInfoVisible, "A user is logged but no bikes requested/ booked.");
Assert.AreEqual("Aktuell 2 Fahrräder reserviert/ gebucht. Verbindungsstatus: Offline.", settingsPageViewModel.BookingStateInfo);
}

View file

@ -2,7 +2,8 @@
using Rhino.Mocks;
using System;
using System.Collections.Generic;
using TestTINKLib.Mocks.Services;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.BluetoothLock;
using TINK.Model.Bike.BluetoothLock;
using TINK.Model.Device;
using TINK.Model.State;

View file

@ -1,29 +1,29 @@
using NUnit.Framework;
using Rhino.Mocks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TestTINKLib.Mocks.Connector;
using TestTINKLib.Mocks.Device;
using TestTINKLib.Mocks.Services;
using TestTINKLib.Model.User.Account;
using TINK.Model;
using TINK.Model.Connector;
using TINK.Repository.Exception;
using TINK.Model.Services.CopriApi;
using TINK.Repository;
using TINK.View;
using TINK.ViewModel.Map;
using Xamarin.Forms;
using static TINK.Repository.CopriCallsMemory;
using TINK.ViewModel.Settings;
using TINK.Model.Services.Geolocation;
using TINK.Services;
using NSubstitute;
using TINK.Services.Permissions;
using TestFramework.Services.BluetoothLock;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Model.User.Account;
using TestFramework.Model.Device;
using TestFramework.Services.Permissions;
using TestFramework.Repository;
using TestFramework.Services.CopriApi.Connector;
namespace TestTINKLib.Fixtures.UseCases.Startup
namespace TestShareeLib.UseCases.Startup
{
[TestFixture]
@ -34,15 +34,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
{
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
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(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
new DeviceMock(),
@ -54,8 +54,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
lastVersion: new Version(3, 0, 173), // Current app version. Must be larger or equal 3.0.173 to
whatsNewShownInVersion: null); // Whats new page was never shown.
var viewService = MockRepository.GenerateStub<IViewService>();
var navigationService = MockRepository.GenerateStub<INavigation>();
var viewService = Substitute.For<IViewService>();
var navigationService = Substitute.For<INavigation>();
var locationPermission = Substitute.For<ILocationPermission>();
locationPermission.CheckStatusAsync().Returns(Status.Granted);
@ -76,13 +76,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
Assert.IsNull(viewModel.Exception);
// Verify pins on map
Assert.AreEqual(8, viewModel.Pins.Count);
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "4").Icon.Id.Contains("Green"),
"Station 4 must be marked green because there is are bike.");
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "31").Icon.Id.Contains("Red"),
"Station 31 must be marked red because there is no bike.");
Assert.AreEqual(21, viewModel.Pins.Count); // Were 8 pins when loading from CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Green")).Tag,
Is.EqualTo("FR105"),
"Station FR105 must be marked green because there is are bike.");
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Red")).Tag,
Is.EqualTo("KN12"),
"Station KN12 must be marked red because there is no bike."); // Was station id 31
// Verify buttons
Assert.IsTrue(viewModel.IsToggleVisible, "TINK and Konrad are activated in settings.");
@ -108,15 +110,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
{
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.Off }, { "Konrad", FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.Off }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
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(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
new DeviceMock(),
@ -128,8 +130,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
lastVersion: new Version(3, 0, 173), // Current app version. Must be larger or equal 3.0.173 to
whatsNewShownInVersion: null); // Whats new page was never shown.
var viewService = MockRepository.GenerateStub<IViewService>();
var navigationService = MockRepository.GenerateStub<INavigation>();
var viewService = Substitute.For<IViewService>();
var navigationService = Substitute.For<INavigation>();
var locationPermission = Substitute.For<ILocationPermission>();
locationPermission.CheckStatusAsync().Returns(Status.Granted);
@ -150,13 +152,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
Assert.IsNull(viewModel.Exception);
// Verify pins on map
Assert.AreEqual(2, viewModel.Pins.Count);
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "31").Icon.Id.Contains("Green"),
"Station 5 must be marked green because there is are bike.");
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "14").Icon.Id.Contains("Red"),
"Station 14 must be marked red because there is no bike.");
Assert.AreEqual(27, viewModel.Pins.Count); // Were 2 pins when loading from CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Green")).Tag, // Was station 5
Is.EqualTo("FR101"),
"Station FR101 must be marked green because there is are bike.");
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Red")).Tag, // Was station 14
Is.EqualTo("KN12"),
"Station KN12 must be marked red because there is no bike.");
// Verify buttons
Assert.IsTrue(viewModel.IsToggleVisible, "TINK and Konrad are activated in settings.");
@ -174,22 +178,20 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
}
}
[Test]
public async Task TestConstruct_KonradOnly()
{
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "Konrad", FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.Off }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERKONRAD, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.Off }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
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(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
new DeviceMock(),
@ -199,8 +201,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
currentVersion: new Version(3, 2, 0, 115), // Current app version
lastVersion: new Version(3, 0, 173)); // Current app version. Must be larger or equal 3.0.173 to
var viewService = MockRepository.GenerateStub<IViewService>();
var navigationService = MockRepository.GenerateStub<INavigation>();
var viewService = Substitute.For<IViewService>();
var navigationService = Substitute.For<INavigation>();
var locationPermission = Substitute.For<ILocationPermission>();
locationPermission.CheckStatusAsync().Returns(Status.Granted);
@ -208,8 +210,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
var viewModel = new MapPageViewModel(
tinkApp,
locationPermission,
NSubstitute.Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
NSubstitute.Substitute.For<IGeolocation>(),
Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
Substitute.For<IGeolocation>(),
(mapspan) => { },
viewService,
navigationService);
@ -221,13 +223,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
Assert.IsNull(viewModel.Exception);
// Verify pins on map
Assert.AreEqual(2, viewModel.Pins.Count);
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "31").Icon.Id.Contains("Green"),
"Station 5 must be marked green because there is are bike.");
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "14").Icon.Id.Contains("Red"),
"Station 14 must be marked red because there is no bike.");
Assert.AreEqual(27, viewModel.Pins.Count); // Were 2 when loading from CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Green")).Tag, // Was station id 31
Is.EqualTo("FR101"),
"Station FR101 must be marked green because there is are bike.");
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Red")).Tag, // Was 14
Is.EqualTo("KN12"),
"Station KN12 must be marked red because there is no bike.");
// Verify buttons
Assert.IsFalse(viewModel.IsToggleVisible, "TINK and Konrad is deactivated from settings.");
@ -247,15 +251,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
{
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
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(sessionCookie, mail, new CopriCallsMemory001( sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
new DeviceMock(),
@ -265,8 +269,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
currentVersion: new Version(3, 2, 0, 115), // Current app version
lastVersion: new Version(3, 0, 173));
var viewService = MockRepository.GenerateStub<IViewService>();
var navigationService = MockRepository.GenerateStub<INavigation>();
var viewService = Substitute.For<IViewService>();
var navigationService = Substitute.For<INavigation>();
var locationPermission = Substitute.For<ILocationPermission>();
locationPermission.CheckStatusAsync().Returns(Status.Granted);
@ -274,8 +278,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
var viewModel = new MapPageViewModel(
tinkApp,
locationPermission,
NSubstitute.Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
NSubstitute.Substitute.For<IGeolocation>(),
Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
Substitute.For<IGeolocation>(),
(mapspan) => { },
viewService,
navigationService);
@ -287,13 +291,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
Assert.IsNull(viewModel.Exception);
// Verify pins on map
Assert.AreEqual(8, viewModel.Pins.Count);
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "4").Icon.Id.Contains("Green"),
"Station 4 must be marked green because there is are bike.");
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "31").Icon.Id.Contains("Red"),
"Station 31 must be marked red because there is no bike.");
Assert.AreEqual(21, viewModel.Pins.Count); // Were 8 pin when loading from CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Green")).Tag,
Is.EqualTo("FR103"), // Was station id 4
"Station FR101 must be marked green because there is are bike.");
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Red")).Tag, // Was 31
Is.EqualTo("KN12"), // Was station id 31
"Station KN12 must be marked red because there is no bike.");
// Verify buttons
Assert.IsFalse(viewModel.IsToggleVisible, "TINK and Konrad is deactivated from settings.");
@ -313,15 +319,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
{
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
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(sessionCookie, mail, new CopriCallsMemory001( sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
new DeviceMock(),
@ -331,8 +337,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
currentVersion: new Version(3, 2, 0, 115), // Current app version
lastVersion: new Version(3, 0, 173)); // Current app version. Must be larger or equal 3.0.173 to
var viewService = MockRepository.GenerateStub<IViewService>();
var navigationService = MockRepository.GenerateStub<INavigation>();
var viewService = Substitute.For<IViewService>();
var navigationService = Substitute.For<INavigation>();
var locationPermission = Substitute.For<ILocationPermission>();
locationPermission.CheckStatusAsync().Returns(Status.Granted);
@ -340,8 +346,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
var viewModel = new MapPageViewModel(
tinkApp,
locationPermission,
NSubstitute.Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
NSubstitute.Substitute.For<IGeolocation>(),
Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
Substitute.For<IGeolocation>(),
(mapspan) => { },
viewService,
navigationService);
@ -353,13 +359,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
Assert.IsNull(viewModel.Exception);
// Verify pins on map
Assert.AreEqual(8, viewModel.Pins.Count);
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "4").Icon.Id.Contains("Green"),
"Station 4 must be marked green because there is are bike.");
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "31").Icon.Id.Contains("Red"),
"Station 31 must be marked red because there is no bike.");
Assert.AreEqual(21, viewModel.Pins.Count); // Were 8 pins when loading from CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Green")).Tag, // Was station id 4
Is.EqualTo("FR103"),
"Station FR101 must be marked green because there is are bike.");
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Red")).Tag, // Was 31
Is.EqualTo("KN12"),
"Station KN12 must be marked red because there is no bike.");
// Verify buttons
Assert.IsTrue(viewModel.IsToggleVisible, "TINK and Konrad are activated in settings.");
@ -381,8 +389,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
{
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -400,7 +408,7 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
TinkApp.MerchantId,
"TestTINKApp/3.0.127 AutomatedTestEnvirnoment/Default",
sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie),
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
@ -411,8 +419,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
currentVersion: new Version(3, 2, 0, 115), // Current app version
lastVersion: new Version(3, 0, 173)); // Current app version. Must be larger or equal 3.0.173 to
var viewService = MockRepository.GenerateStub<IViewService>();
var navigationService = MockRepository.GenerateStub<INavigation>();
var viewService = Substitute.For<IViewService>();
var navigationService = Substitute.For<INavigation>();
var locationPermission = Substitute.For<ILocationPermission>();
locationPermission.CheckStatusAsync().Returns(Status.Granted);
@ -420,8 +428,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
var viewModel = new MapPageViewModel(
tinkApp,
locationPermission,
NSubstitute.Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
NSubstitute.Substitute.For<IGeolocation>(),
Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
Substitute.For<IGeolocation>(),
(mapspan) => { },
viewService,
navigationService);
@ -435,13 +443,15 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
viewModel.Exception.Message);
// Verify pins on map
Assert.AreEqual(8, viewModel.Pins.Count);
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "4").Icon.Id.Contains("Green"),
"Station 4 must be marked green because there is are bike.");
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "31").Icon.Id.Contains("Red"),
"Station 31 must be marked red because there is no bike.");
Assert.AreEqual(21, viewModel.Pins.Count);
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Green")).Tag, // Was station id 4
Is.EqualTo("FR103"),
"Station FR101 must be marked green because there is are bike.");
Assert.That(
viewModel.Pins.FirstOrDefault(pin => pin.Icon.Id.Contains("Open_Red")).Tag, // Was 31
Is.EqualTo("KN12"),
"Station KN12 must be marked red because there is no bike.");
// Verify buttons
Assert.IsTrue(viewModel.IsToggleVisible, "TINK and Konrad are activated in settings.");
@ -457,14 +467,13 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
}
}
[Test]
public async Task TestConstruct_GeneralPurposeCommunicationError()
{
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -482,7 +491,7 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
TinkApp.MerchantId,
"TestTINKApp/3.0.127 AutomatedTestEnvirnoment/Default",
sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie),
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new Exception(msg)))),
Substitute.For<IServicesContainer<IGeolocation>>(),
new LocksServiceMock(),
@ -494,8 +503,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
lastVersion: new Version(3, 0, 173)); // Current app version. Must be larger or equal 3.0.173 to
var viewService = MockRepository.GenerateStub<IViewService>();
var navigationService = MockRepository.GenerateStub<INavigation>();
var viewService = Substitute.For<IViewService>();
var navigationService = Substitute.For<INavigation>();
var locationPermission = Substitute.For<ILocationPermission>();
locationPermission.CheckStatusAsync().Returns(Status.Granted);
@ -503,8 +512,8 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
var viewModel = new MapPageViewModel(
tinkApp,
locationPermission,
NSubstitute.Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
NSubstitute.Substitute.For<IGeolocation>(),
Substitute.For<Plugin.BLE.Abstractions.Contracts.IBluetoothLE>(),
Substitute.For<IGeolocation>(),
(mapspan) => { },
viewService,
navigationService);
@ -518,12 +527,14 @@ namespace TestTINKLib.Fixtures.UseCases.Startup
viewModel.Exception.Message);
// Verify pins on map
Assert.AreEqual(8, viewModel.Pins.Count);
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "4").Icon.Id.Contains("Green"),
"Station 4 must be marked green because there is are bike.");
Assert.IsTrue(
viewModel.Pins.FirstOrDefault(pin => pin.Tag.ToString() == "31").Icon.Id.Contains("Red"),
Assert.AreEqual(21, viewModel.Pins.Count);
Assert.That(
viewModel.Pins.Where(pin => pin.Icon.Id.Contains("Open_Green")).Select(pin => pin.Tag.ToString()),
Does.Contain("FR103"), // Was station id 4
"Station FR103 must be marked green because there is are bike.");
Assert.That(
viewModel.Pins.Where(pin => pin.Icon.Id.Contains("Open_Red")).Select(pin => pin.Tag.ToString()),
Does.Contain("KN12"), // Was station id 31
"Station 31 must be marked red because there is no bike.");
// Verify buttons

View file

@ -4,7 +4,6 @@ using TINK.Model.Bike;
using TINK.Model.User;
using TINK.Model.User.Account;
using TINK.ViewModel;
using TestTINKLib.Model.User.Account;
using Xamarin.Forms;
using TINK.Model.State;
@ -14,6 +13,7 @@ using System.Collections.Generic;
using BikeInfoMutable = TINK.Model.Bike.BC.BikeInfoMutable;
using TINK.ViewModel.Bikes;
using TINK.Model.Device;
using TestFramework.Model.User.Account;
namespace UITest.Fixtures.ViewModel
{

View file

@ -3,13 +3,12 @@ using System;
using TINK.Model.Bike;
using TINK.Model.User;
using TINK.Model.User.Account;
using TINK.ViewModel;
using TestTINKLib.Model.User.Account;
using static TINK.Repository.CopriCallsMemory;
using TINK.Model.State;
using System.Collections.Generic;
using TINK.Repository;
using TINK.ViewModel.Bikes.Bike;
using TestFramework.Model.User.Account;
namespace UITest.Fixtures.ViewModel
{

View file

@ -1,7 +1,8 @@
using NUnit.Framework;
using Rhino.Mocks;
using System;
using TestTINKLib.Mocks.Services;
using TestFramework.Model.Services.Geolocation;
using TestFramework.Services.BluetoothLock;
using TINK.Model.Device;
using TINK.Model.User;
using TINK.ViewModel;

View file

@ -3,10 +3,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TestTINKLib.Mocks.Connector;
using TestTINKLib.Mocks.Device;
using TestTINKLib.Mocks.Services;
using TestTINKLib.Model.User.Account;
using TINK.Model;
using TINK.Model.Connector;
using TINK.Repository.Exception;
@ -28,6 +24,12 @@ 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;
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
{
@ -46,15 +48,15 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, 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<string> ())),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, sessionCookie)),
new StoreMock(new TINK.Model.User.Account.Account("", null, null, new List<string>())),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
geolocation,
locksService,
new DeviceMock(),
@ -71,7 +73,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
permissions,
bluetooth,
Device.Android,
new TINK.Model.Station.Station("103", new List<string>(), null), // Station 103
new TINK.Model.Station.Station("FR103", new List<string>(), null), // Was station id 103 before switching from data provider CopriCallsMemory(SampleSets.ShareeFr01_Set1, 1, ...)
() => tinkApp.GetIsConnected(),
(isConnected) => tinkApp.GetConnector(isConnected),
geolocation.Active, // geolocation
@ -91,13 +93,13 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Assert.IsTrue(bikesAtStation.IsIdle);
Assert.IsTrue(bikesAtStation.IsBikesListVisible, "If there are any bikes, list must be visible.");
var bike1315 = bikesAtStation.FirstOrDefault(x => x.Id == "1315") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bike1543 = bikesAtStation.FirstOrDefault(x => x.Id == "1543") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel;
var bikeFR9999 = bikesAtStation.FirstOrDefault(x => x.Id == "FR9999") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; // Was id 1315
var bikeFR9998 = bikesAtStation.FirstOrDefault(x => x.Id == "FR9998") as TINK.ViewModel.Bikes.Bike.BluetoothLock.BikeViewModel; // Was id 1543
Assert.AreEqual("Available.", bike1315.StateText);
Assert.AreEqual("Available.", bike1543.StateText);
Assert.AreEqual("NotLoggedIn", bike1315.LockitButtonText);
Assert.AreEqual("NotLoggedIn", bike1543.LockitButtonText);
Assert.AreEqual("Available.", bikeFR9999.StateText);
Assert.AreEqual("Available.", bikeFR9998.StateText);
Assert.AreEqual("NotLoggedIn", bikeFR9999.LockitButtonText);
Assert.AreEqual("NotLoggedIn", bikeFR9998.LockitButtonText);
// Login hint/ no bikes frame
Assert.IsTrue(bikesAtStation.IsLoginRequiredHintVisible);
@ -117,8 +119,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -193,8 +195,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -293,8 +295,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -399,8 +401,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -502,8 +504,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -603,8 +605,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -696,15 +698,15 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.Off }, { "Konrad", FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.Off }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000),true),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
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(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
locksService,
new DeviceMock(),
@ -721,7 +723,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
permissions,
bluetooth,
Device.iOS,
new TINK.Model.Station.Station("31", new List<string>(), null),
new TINK.Model.Station.Station("FR101", new List<string>(), null), // Was 31 before switching CopriCallsMemory(SampleSets.Set2, 1, ...)
() => tinkApp.GetIsConnected(),
(isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(),
@ -737,11 +739,13 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Assert.IsTrue(new List<string> { "Updating...", string.Empty }.Contains(bikesAtStation.StatusInfoText));
// Verify list of bikes
Assert.AreEqual(1, bikesAtStation.Count);
Assert.AreEqual(3, bikesAtStation.Count); // Was 1 before switch.
Assert.IsTrue(bikesAtStation.IsIdle);
Assert.IsTrue(bikesAtStation.IsBikesListVisible, "If there are any bikes, list must be visible.");
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "52").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1003").StateText); // Was 52 before switch.
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1002").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1001").StateText);
// Login hint/ no bikes frame
Assert.IsTrue(bikesAtStation.IsLoginRequiredHintVisible);
@ -766,8 +770,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.Off }, { "Konrad", FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.Off }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -833,19 +837,19 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, 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: locksService.GetType().FullName),
new StoreMock(new TINK.Model.User.Account.Account(
LoginSessionCopriInfo.JavaministerHardwareNr1.Mail,
LoginSessionCopriInfo.JavaministerHardwareNr1.Mail,
LoginSessionCopriInfo.JavaministerHardwareNr1.Pwd,
"4da3044c8657a04ba60e2eaa753bc51a",
new List<string> { "TINK" })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)),
"6103_112e96b36ba33de245943c5ffaf369cd_", // Was 4da3044c8657a04ba60e2eaa753bc51a before switching from data provider CopriCallsMemory(SampleSets.Set2, 1, ...)
new List<string> { FilterHelper.FILTERTINKGENERAL })),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
locksService,
new DeviceMock(),
@ -862,7 +866,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
permissions,
bluetooth,
Device.iOS,
new TINK.Model.Station.Station("4", new List<string>(), null),
new TINK.Model.Station.Station("FR103", new List<string>(), null), // Was station id 4 before switching from data provider CopriCallsMemory(SampleSets.Set2, 1, ...)
() => tinkApp.GetIsConnected(),
(isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(),
@ -878,14 +882,14 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Assert.IsTrue(new List<string> { "Updating...", string.Empty }.Contains(bikesAtStation.StatusInfoText));
// Verify list of bikes
Assert.AreEqual(4, bikesAtStation.Count);
Assert.AreEqual(4, bikesAtStation.Count); // Count of bikes was 4 before switching from data provider CopriCallsMemory(SampleSets.Set2, 1, ...)
Assert.IsTrue(bikesAtStation.IsIdle);
Assert.IsTrue(bikesAtStation.IsBikesListVisible, "If there are any bikes, list must be visible.");
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "5").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "14").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "26").StateText);
Assert.AreEqual("Code 2931, rented since 28. November 13:06.", bikesAtStation.FirstOrDefault(x => x.Id == "7").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText);
Assert.AreEqual("Max. reservation time of 15 minutes expired.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1004").StateText);
Assert.AreEqual("Rented since 06. November 18:57.", bikesAtStation.FirstOrDefault(x => x.Id == "FR1544").StateText); // Was 7
// Login hint/ no bikes frame
Assert.IsFalse(bikesAtStation.IsLoginRequiredHintVisible);
@ -909,15 +913,15 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, 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(),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1, sessionCookie)),
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(sessionCookie, mail, new CopriCallsMemory001(sessionCookie)),
Substitute.For<IServicesContainer<IGeolocation>>(),
locksService,
new DeviceMock(),
@ -934,7 +938,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
permissions,
bluetooth,
Device.iOS,
new TINK.Model.Station.Station("4", new List<string>(), null),
new TINK.Model.Station.Station("FR103", new List<string>(), null), // Was station id 4 before switching from data provider CopriCallsMemory(SampleSets.Set2, 1
() => tinkApp.GetIsConnected(),
(isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(),
@ -950,13 +954,12 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Assert.AreEqual("Offline.", bikesAtStation.StatusInfoText);
// Verify list of bikes
Assert.AreEqual(3, bikesAtStation.Count);
Assert.AreEqual(2, bikesAtStation.Count); // Count of bikes was 3. There is no more bike with id 26.
Assert.IsTrue(bikesAtStation.IsIdle);
Assert.IsTrue(bikesAtStation.IsBikesListVisible, "If there are any bikes, list must be visible.");
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "5").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "14").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "26").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText); // Was id 5
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9998").StateText); // Was is 14
// Login hint/ no bikes frame
Assert.IsTrue(bikesAtStation.IsLoginRequiredHintVisible);
@ -980,8 +983,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000), true),
Serilog.Events.LogEventLevel.Error,
@ -998,7 +1001,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
TinkApp.MerchantId,
"TestTINKApp/3.0.127 AutomatedTestEnvirnoment/Default",
sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie),
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new WebConnectFailureException(msg, new Exception("Source expection."))))),
Substitute.For<IServicesContainer<IGeolocation>>(),
locksService,
@ -1016,7 +1019,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
permissions,
bluetooth,
Device.iOS,
new TINK.Model.Station.Station("4", new List<string>(), null),
new TINK.Model.Station.Station("FR103", new List<string>(), null), // Was station id 4 before switching from data provider CopriCallsCacheMemory()
() => tinkApp.GetIsConnected(),
(isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(),
@ -1035,13 +1038,12 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Assert.AreEqual("Connection interrupted, server unreachable.", bikesAtStation.StatusInfoText);
// Verify list of bikes
Assert.AreEqual(3, bikesAtStation.Count);
Assert.AreEqual(2, bikesAtStation.Count); // Count of bikes was 3. There is no more bike with id 26.
Assert.IsTrue(bikesAtStation.IsIdle);
Assert.IsTrue(bikesAtStation.IsBikesListVisible, "If there are any bikes, list must be visible.");
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "5").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "14").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "26").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText); // Was id 5
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9998").StateText); // Was is 14
// Login hint/ no bikes frame
Assert.IsTrue(bikesAtStation.IsLoginRequiredHintVisible);
@ -1065,8 +1067,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var tinkApp = new TinkApp(
new TINK.Model.Settings.Settings(
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { "TINK", FilterState.On }, { "Konrad", FilterState.On } }),
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.Off } }),
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERTINKGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
new TINK.Settings.PollingParameters(new TimeSpan(10000),
true),
@ -1084,7 +1086,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
TinkApp.MerchantId,
"TestTINKApp/3.0.127 AutomatedTestEnvirnoment/Default",
sessionCookie: sessionCookie,
cacheServer: new CopriCallsCacheMemory(sessionCookie: sessionCookie),
cacheServer: new CopriCallsCacheMemory001(sessionCookie: sessionCookie),
httpsServer: new ExceptionServer((msg) => new Exception(msg)))),
Substitute.For<IServicesContainer<IGeolocation>>(),
locksService,
@ -1102,7 +1104,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
permissions,
bluetooth,
Device.iOS,
new TINK.Model.Station.Station("4", new List<string>(), null),
new TINK.Model.Station.Station("FR103", new List<string>(), null), // Was station id 4 before switching from data provider CopriCallsCacheMemory()
() => tinkApp.GetIsConnected(),
(isConnected) => tinkApp.GetConnector(isConnected),
new GeolocationMock(),
@ -1121,13 +1123,12 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
Assert.AreEqual("Connection interrupted.", bikesAtStation.StatusInfoText);
// Verify list of bikes
Assert.AreEqual(3, bikesAtStation.Count);
Assert.AreEqual(2, bikesAtStation.Count); // Count of bikes was 3. There is no more bike with id 26.
Assert.IsTrue(bikesAtStation.IsIdle);
Assert.IsTrue(bikesAtStation.IsBikesListVisible, "If there are any bikes, list must be visible.");
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "5").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "14").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "26").StateText);
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9999").StateText); // Was id 5
Assert.AreEqual("Available.", bikesAtStation.FirstOrDefault(x => x.Id == "FR9998").StateText); // Was id 14.
// Login hint/ no bikes frame
Assert.IsTrue(bikesAtStation.IsLoginRequiredHintVisible);

View file

@ -4,9 +4,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TestTINKLib.Mocks.Connector;
using TestTINKLib.Mocks.Device;
using TestTINKLib.Mocks.Services;
using TestTINKLib.Model.User.Account;
using TINK.Model;
using TINK.Model.Connector;
using TINK.Repository.Exception;
@ -27,6 +24,11 @@ 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;
namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
{
@ -600,7 +602,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var myBikes = new MyBikesPageViewModel(
tinkApp.ActiveUser,
null, // Permissions,
permissions, // Permissions,
bluetooth,
Device.iOS,
() => tinkApp.GetIsConnected(),
@ -674,7 +676,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var myBikes = new MyBikesPageViewModel(
tinkApp.ActiveUser,
null, // Permissions,
permissions, // Permissions,
bluetooth,
Device.iOS,
() => tinkApp.GetIsConnected(),
@ -751,7 +753,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.ViewModel
var myBikes = new MyBikesPageViewModel(
tinkApp.ActiveUser,
null, // Permissions,
permissions, // Permissions,
bluetooth,
Device.iOS,
() => tinkApp.GetIsConnected(),