mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-07-13 06:06:34 +02:00
Version 3.0.381
This commit is contained in:
parent
f963c0a219
commit
3a363acf3a
1525 changed files with 60589 additions and 125098 deletions
|
@ -0,0 +1,33 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="UseCase\Startup\TestShareeBikeApp.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="UseCase\Startup\TestShareeBikeApp.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NSubstitute" Version="5.1.0" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SharedBusinessLogic.Tests.Framework\SharedBusinessLogic.Tests.Framework.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31829.152
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharedBusinessLogic.Tests.UseCases", "SharedBusinessLogic.Tests.UseCases.csproj", "{A86E5489-2A44-44C5-8CCF-A2C6777F9E78}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharedBusinessLogic", "..\SharedBusinessLogic\SharedBusinessLogic.csproj", "{3D53D769-56F1-439E-B237-ADE4A9370F51}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharedBusinessLogic.Tests.Framework", "..\SharedBusinessLogic.Tests.Framework\SharedBusinessLogic.Tests.Framework.csproj", "{CA8997CD-32A6-4273-9A2B-451C787208EC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A86E5489-2A44-44C5-8CCF-A2C6777F9E78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A86E5489-2A44-44C5-8CCF-A2C6777F9E78}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A86E5489-2A44-44C5-8CCF-A2C6777F9E78}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A86E5489-2A44-44C5-8CCF-A2C6777F9E78}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3D53D769-56F1-439E-B237-ADE4A9370F51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3D53D769-56F1-439E-B237-ADE4A9370F51}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3D53D769-56F1-439E-B237-ADE4A9370F51}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3D53D769-56F1-439E-B237-ADE4A9370F51}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CA8997CD-32A6-4273-9A2B-451C787208EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CA8997CD-32A6-4273-9A2B-451C787208EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CA8997CD-32A6-4273-9A2B-451C787208EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CA8997CD-32A6-4273-9A2B-451C787208EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9BA7D1A2-6C7D-4569-A23B-C86853F51DCF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,380 @@
|
|||
using NUnit.Framework;
|
||||
using ShareeBike.Model;
|
||||
|
||||
using ShareeBike.Model.User.Account;
|
||||
using ShareeBike.Model.Connector;
|
||||
using System;
|
||||
using ShareeBike.Model.Stations;
|
||||
using static ShareeBike.Repository.CopriCallsMemory;
|
||||
using ShareeBike.Model.State;
|
||||
using System.Collections.Generic;
|
||||
using ShareeBike.Repository;
|
||||
using ShareeBike.ViewModel.Map;
|
||||
using ShareeBike.ViewModel.Settings;
|
||||
using ShareeBike.Services;
|
||||
using ShareeBike.Services.Geolocation;
|
||||
using SharedBusinessLogic.Tests.Framework.Model.User.Account;
|
||||
using SharedBusinessLogic.Tests.Framework.Model.Device;
|
||||
using SharedBusinessLogic.Tests.Framework.Services.BluetoothLock;
|
||||
using SharedBusinessLogic.Tests.Framework.Repository;
|
||||
using SharedBusinessLogic.Tests.Framework.Model.Services.Geolocation;
|
||||
using SharedBusinessLogic.Tests.Framework.Services.Permissions;
|
||||
using NSubstitute;
|
||||
using SharedBusinessLogic.Tests.Framework;
|
||||
|
||||
namespace SharedBusinessLogic.Tests.UseCases.Startup
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestShareeBikeApp
|
||||
{
|
||||
[Test]
|
||||
public void NotLoggedIn()
|
||||
{
|
||||
var l_oConnector = new ConnectorCache(
|
||||
string.Empty,
|
||||
string.Empty,
|
||||
new CopriCallsMemory(SampleSets.Set2, 1));
|
||||
|
||||
var l_oShareeBikeApp = new ShareeBikeApp(
|
||||
new ShareeBike.Model.Settings.Settings(
|
||||
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERShareeBikeGENERAL, FilterState.On } }),
|
||||
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERShareeBikeGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
|
||||
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"),
|
||||
new ShareeBike.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(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001()),
|
||||
Substitute.For<IServicesContainer<IGeolocation>>(),
|
||||
new LocksServiceMock(),
|
||||
new DeviceMock(),
|
||||
new SpecialFolderMock(),
|
||||
null, // Cipher
|
||||
Substitute.For<ILocationPermission>(),
|
||||
isConnectedFunc: () => true,
|
||||
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 l_oStations = l_oShareeBikeApp.GetConnector(true).Query.GetBikesAndStationsAsync().Result.Response;
|
||||
|
||||
// Check stations.
|
||||
Assert.AreEqual(21, l_oStations.StationsAll.Count);
|
||||
Assert.NotNull(l_oStations.StationsAll.GetById("KN4")); // Id of station was "4" in former version of COPRI.
|
||||
Assert.AreEqual("KN4", l_oStations.StationsAll.GetById("KN4").Id);
|
||||
Assert.AreEqual(new Position(47.658592, 9.168569), l_oStations.StationsAll.GetById("KN4").Position); // Former position was 47.6586936667, 9.16863116667
|
||||
|
||||
// Verify selected station.
|
||||
Assert.AreEqual(
|
||||
null,
|
||||
l_oShareeBikeApp.SelectedStation.Id,
|
||||
"When starting app selected station must always be invalid");
|
||||
|
||||
// Verify bikes at station.
|
||||
Assert.AreEqual(
|
||||
0,
|
||||
TestHelper.GetBikesAtStation(l_oShareeBikeApp.ActiveUser, l_oConnector, l_oShareeBikeApp.SelectedStation.Id).Result.Count,
|
||||
"If no station is selected BikesAtStation- list count must be zero");
|
||||
|
||||
// Check my bikes.
|
||||
Assert.IsFalse(l_oShareeBikeApp.ActiveUser.IsLoggedIn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoggedIn_BikesReservedBooked()
|
||||
{
|
||||
var l_oConnector = new ConnectorCache(
|
||||
"4da3044c8657a04ba60e2eaa753bc51a",
|
||||
"javaminister@gmail.com",
|
||||
new CopriCallsMemory(SampleSets.Set2, 1, "4da3044c8657a04ba60e2eaa753bc51a"));
|
||||
|
||||
// User logged in is initial state to verify.
|
||||
var l_oShareeBikeApp = new ShareeBikeApp(
|
||||
new ShareeBike.Model.Settings.Settings(
|
||||
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERShareeBikeGENERAL, FilterState.On } }),
|
||||
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERShareeBikeGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
|
||||
new Uri("https://tinkwwp.copri-bike.de/APIjsonserver"), new ShareeBike.Settings.PollingParameters(new TimeSpan(10000), true),
|
||||
Serilog.Events.LogEventLevel.Error,
|
||||
activeLockService: typeof(LocksServiceMock).FullName,
|
||||
activeGeolocationService: typeof(GeolocationMock).FullName),
|
||||
new StoreMock(new Account("javaminister@gmail.com", "javaminister" /* password */, "4da3044c8657a04ba60e2eaa753bc51a" /* session cookie */, new List<string> { FilterHelper.FILTERShareeBikeGENERAL, FilterHelper.FILTERKONRAD })),
|
||||
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001("6103_112e96b36ba33de245943c5ffaf369cd_")),
|
||||
Substitute.For<IServicesContainer<IGeolocation>>(),
|
||||
new LocksServiceMock(),
|
||||
new DeviceMock(),
|
||||
new SpecialFolderMock(),
|
||||
null, // Cipher
|
||||
Substitute.For<ILocationPermission>(),
|
||||
isConnectedFunc: () => true,
|
||||
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
|
||||
|
||||
var l_oStations = l_oShareeBikeApp.GetConnector(true).Query.GetBikesAndStationsAsync().Result.Response;
|
||||
|
||||
// Check stations.
|
||||
Assert.AreEqual(21, l_oStations.StationsAll.Count);
|
||||
Assert.NotNull(l_oStations.StationsAll.GetById("KN4"));
|
||||
Assert.AreEqual("KN4", l_oStations.StationsAll.GetById("KN4").Id);
|
||||
Assert.AreEqual(new Position(47.658592, 9.168569), l_oStations.StationsAll.GetById("KN4").Position); // Former position was 47.6586936667, 9.16863116667
|
||||
|
||||
// Verify selected station.
|
||||
Assert.AreEqual(
|
||||
null,
|
||||
l_oShareeBikeApp.SelectedStation.Id,
|
||||
"When starting app selected station must always be invalid");
|
||||
|
||||
// Verify bikes at station.
|
||||
Assert.AreEqual(
|
||||
0,
|
||||
TestHelper.GetBikesAtStation(l_oShareeBikeApp.ActiveUser, l_oConnector, l_oShareeBikeApp.SelectedStation.Id).Result.Count,
|
||||
"If no station is selected BikesAtStation- list count must be zero");
|
||||
|
||||
// Check my bikes
|
||||
var l_oBikes = l_oShareeBikeApp.GetConnector(true).Query.GetBikesOccupiedAsync().Result.Response;
|
||||
Assert.AreEqual(2, l_oBikes.Count);
|
||||
Assert.AreEqual("FR1544", l_oBikes.GetById("FR1544").Id); // Bike used here was from set CopriCallsMemory(SampleSets.Set2, 1) and had ID 8
|
||||
Assert.AreEqual(InUseStateEnum.Booked, l_oBikes.GetById("FR1544").State.Value);
|
||||
Assert.AreEqual("FR103", l_oBikes.GetById("FR1544").CurrentStation); // // Bike used here was at station 5
|
||||
Assert.That(l_oBikes.GetById("FR1544").TypeOfBike, Is.Null); // Bike used here was TypeOfBike.Cargo
|
||||
Assert.That(l_oBikes.GetById("FR1544").WheelType, Is.Null); // Bike was of Type WheelType.Two
|
||||
Assert.AreEqual("FR1004", l_oBikes.GetById("FR1004").Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoggedIn_AllBikesDisposable_FilterCargo()
|
||||
{
|
||||
var l_oConnector = new ConnectorCache(
|
||||
"1234",
|
||||
"mgrimm@gmail.com",
|
||||
new CopriCallsMemory(SampleSets.Set2, 1));
|
||||
|
||||
// No user logged in is initial state to verify.
|
||||
var l_oShareeBikeApp = new ShareeBikeApp(
|
||||
new ShareeBike.Model.Settings.Settings(
|
||||
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERShareeBikeGENERAL, FilterState.On } }),
|
||||
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERShareeBikeGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
|
||||
new Uri("https://app.tink-konstanz.de/APIjsonserver"),
|
||||
new ShareeBike.Settings.PollingParameters(new TimeSpan(10000), true),
|
||||
Serilog.Events.LogEventLevel.Error,
|
||||
activeLockService: typeof(LocksServiceMock).FullName,
|
||||
activeGeolocationService: typeof(GeolocationMock).FullName),
|
||||
new StoreMock(new Account("mgrimm@gmail.com", "123456789" /* password */, "1234" /* session cookie */, new List<string> { FilterHelper.FILTERShareeBikeGENERAL, FilterHelper.FILTERKONRAD })),
|
||||
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001()),
|
||||
Substitute.For<IServicesContainer<IGeolocation>>(),
|
||||
new LocksServiceMock(),
|
||||
new DeviceMock(),
|
||||
new SpecialFolderMock(),
|
||||
null, // Cipher
|
||||
Substitute.For<ILocationPermission>(),
|
||||
isConnectedFunc: () => true,
|
||||
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
|
||||
|
||||
var l_oStations = l_oShareeBikeApp.GetConnector(true).Query.GetBikesAndStationsAsync().Result.Response;
|
||||
|
||||
// Check stations.
|
||||
Assert.AreEqual(21, l_oStations.StationsAll.Count);
|
||||
Assert.NotNull(l_oStations.StationsAll.GetById("KN4"));
|
||||
Assert.AreEqual("KN4", l_oStations.StationsAll.GetById("KN4").Id);
|
||||
Assert.AreEqual(new Position(47.658592, 9.168569), l_oStations.StationsAll.GetById("KN4").Position); // Former position was 47.6586936667, 9.16863116667
|
||||
|
||||
// Verify selected station.
|
||||
Assert.AreEqual(
|
||||
null,
|
||||
l_oShareeBikeApp.SelectedStation.Id,
|
||||
"When starting app selected station must always be invalid");
|
||||
|
||||
// Verify bikes at station.
|
||||
Assert.AreEqual(
|
||||
0,
|
||||
TestHelper.GetBikesAtStation(l_oShareeBikeApp.ActiveUser, l_oConnector, l_oShareeBikeApp.SelectedStation.Id).Result.Count,
|
||||
"If no station is selected BikesAtStation- list count must be zero");
|
||||
|
||||
// Check my bikes
|
||||
Assert.IsTrue(l_oShareeBikeApp.ActiveUser.IsLoggedIn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoggedIn_AllBikesDisposable_FilterCitybike()
|
||||
{
|
||||
var l_oCopriServer = new CopriCallsMemory(SampleSets.Set2, 1);
|
||||
var l_oConnector = new ConnectorCache(
|
||||
"1234",
|
||||
"mgrimm@gmail.com",
|
||||
new CopriCallsMemory(SampleSets.Set2, 1));
|
||||
|
||||
// No user logged in is initial state to verify.
|
||||
var l_oShareeBikeApp = new ShareeBikeApp(
|
||||
new ShareeBike.Model.Settings.Settings(
|
||||
new GroupFilterMapPage(new Dictionary<string, FilterState> { { FilterHelper.FILTERKONRAD, FilterState.On } }),
|
||||
new GroupFilterSettings(new Dictionary<string, FilterState> { { FilterHelper.FILTERShareeBikeGENERAL, FilterState.On }, { FilterHelper.FILTERKONRAD, FilterState.On } }),
|
||||
new Uri("https://app.tink-konstanz.de/APIjsonserver"),
|
||||
new ShareeBike.Settings.PollingParameters(new TimeSpan(10000), true),
|
||||
Serilog.Events.LogEventLevel.Error,
|
||||
activeLockService: typeof(LocksServiceMock).FullName,
|
||||
activeGeolocationService: typeof(GeolocationMock).FullName),
|
||||
new StoreMock(new Account("mgrimm@gmail.com", "123456789" /* password */, "1234" /* session cookie */, new List<string> { FilterHelper.FILTERShareeBikeGENERAL, FilterHelper.FILTERKONRAD })),
|
||||
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory001()),
|
||||
Substitute.For<IServicesContainer<IGeolocation>>(),
|
||||
new LocksServiceMock(),
|
||||
new DeviceMock(),
|
||||
new SpecialFolderMock(),
|
||||
null, // Cipher
|
||||
Substitute.For<ILocationPermission>(),
|
||||
isConnectedFunc: () => true,
|
||||
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
|
||||
|
||||
var l_oStations = l_oShareeBikeApp.GetConnector(true).Query.GetBikesAndStationsAsync().Result.Response;
|
||||
|
||||
// Check stations.
|
||||
Assert.AreEqual(27, l_oStations.StationsAll.Count);
|
||||
Assert.NotNull(l_oStations.StationsAll.GetById("KN1")); // Former station id was 14 when bike was read from CopriCallsMemory(SampleSets.Set2, 1)
|
||||
Assert.AreEqual("KN1", l_oStations.StationsAll.GetById("KN1").Id);
|
||||
Assert.AreEqual(new Position(47.66267, 9.17262), l_oStations.StationsAll.GetById("KN1").Position); // Former station was 47.66698054007847, 9.169303178787231
|
||||
|
||||
// Verify selected station.
|
||||
Assert.AreEqual(
|
||||
null,
|
||||
l_oShareeBikeApp.SelectedStation.Id,
|
||||
"When starting app selected station must always be invalid");
|
||||
|
||||
// Verify bikes at station.
|
||||
Assert.AreEqual(
|
||||
0,
|
||||
TestHelper.GetBikesAtStation(l_oShareeBikeApp.ActiveUser, l_oConnector, l_oShareeBikeApp.SelectedStation.Id).Result.Count,
|
||||
"If no station is selected BikesAtStation- list count must be zero");
|
||||
|
||||
// Check my bikes
|
||||
Assert.IsTrue(l_oShareeBikeApp.ActiveUser.IsLoggedIn);
|
||||
}
|
||||
|
||||
[Test, Ignore("Todo: Check if reserved bikes are released even if system is offline.")]
|
||||
public void LoggedIn_BikesReserved_OfflineAfterStart()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if Whats New logic works as expected. Form version 3.0.0.115 or smaller no Whats New dialog existed.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void FirstInstall_WhatsNew()
|
||||
{
|
||||
var l_oAppVersion = new Version(3, 2, 0, 120);
|
||||
|
||||
var l_oShareeBikeApp = new ShareeBikeApp(
|
||||
new ShareeBike.Model.Settings.Settings(
|
||||
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "ShareeBike", FilterState.On } }),
|
||||
new GroupFilterSettings(new Dictionary<string, FilterState> { { "ShareeBike", FilterState.On }, { "Citybike", FilterState.On } }),
|
||||
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
|
||||
new ShareeBike.Settings.PollingParameters(new TimeSpan(10000), true),
|
||||
Serilog.Events.LogEventLevel.Error),
|
||||
new StoreMock(),
|
||||
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)),
|
||||
Substitute.For<IServicesContainer<IGeolocation>>(),
|
||||
null, // use default locks service
|
||||
new DeviceMock(),
|
||||
new SpecialFolderMock(),
|
||||
null, // Cipher
|
||||
Substitute.For<ILocationPermission>(),
|
||||
isConnectedFunc: () => true,
|
||||
currentVersion: l_oAppVersion, // Current app version
|
||||
lastVersion: null, // Last version.
|
||||
whatsNewShownInVersion: null); // First install.
|
||||
|
||||
// Whats new page
|
||||
Assert.IsFalse(
|
||||
l_oShareeBikeApp.WhatsNew.IsShowRequired,
|
||||
$"Whats new should not be displayed because first install has been detected.");
|
||||
|
||||
// Call member which view model calls when using app.
|
||||
l_oShareeBikeApp.SetWhatsNewWasShown();
|
||||
|
||||
// Whats new page
|
||||
Assert.IsFalse(
|
||||
l_oShareeBikeApp.WhatsNew.IsShowRequired,
|
||||
$"Whats new should mot be displayed first install detected.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Upgrade120_WhatsNew()
|
||||
{
|
||||
var l_oAppVersion = new Version(3, 0, 0, 120);
|
||||
Version lastVersion = new Version(3, 0, 0, 116);
|
||||
|
||||
var l_oShareeBikeApp = new ShareeBikeApp(
|
||||
new ShareeBike.Model.Settings.Settings(
|
||||
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "ShareeBike", FilterState.On } }),
|
||||
new GroupFilterSettings(new Dictionary<string, FilterState> { { "ShareeBike", FilterState.On }, { "Citybike", FilterState.On } }),
|
||||
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
|
||||
new ShareeBike.Settings.PollingParameters(new TimeSpan(10000), true),
|
||||
Serilog.Events.LogEventLevel.Error),
|
||||
new StoreMock(),
|
||||
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)),
|
||||
Substitute.For<IServicesContainer<IGeolocation>>(),
|
||||
null, // use default locks service
|
||||
new DeviceMock(),
|
||||
new SpecialFolderMock(),
|
||||
null, // Cipher
|
||||
Substitute.For<ILocationPermission>(),
|
||||
isConnectedFunc: () => true,
|
||||
currentVersion: l_oAppVersion, // Current app version
|
||||
lastVersion: lastVersion,
|
||||
whatsNewShownInVersion: null); // Whats new page was never shown.
|
||||
|
||||
// Whats new page
|
||||
Assert.IsTrue(
|
||||
l_oShareeBikeApp.WhatsNew.IsShowRequired,
|
||||
$"Whats new should be displayed because app version is {l_oAppVersion} and version when \"Whats New\" was shown last is {lastVersion} (null means never).");
|
||||
|
||||
// Call member which view model calls when using app.
|
||||
l_oShareeBikeApp.SetWhatsNewWasShown();
|
||||
|
||||
// Whats new page
|
||||
Assert.IsFalse(
|
||||
l_oShareeBikeApp.WhatsNew.IsShowRequired,
|
||||
$"Whats new should mot be displayed because app version is {l_oAppVersion} and version when \"Whats New\" was shown last is {lastVersion} equals.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SubsequentStart_WhatsNew()
|
||||
{
|
||||
var l_oAppVersion = new Version(3, 2, 0, 115);
|
||||
var l_oWhatsNewVersion = new Version(3, 2, 0, 115);
|
||||
|
||||
var l_oShareeBikeApp = new ShareeBikeApp(
|
||||
new ShareeBike.Model.Settings.Settings(
|
||||
new GroupFilterMapPage(new Dictionary<string, FilterState> { { "ShareeBike", FilterState.On } }),
|
||||
new GroupFilterSettings(new Dictionary<string, FilterState> { { "ShareeBike", FilterState.On }, { "Citybike", FilterState.On } }),
|
||||
new Uri("https://shareeapp-primary.copri-bike.de/APIjsonserver"),
|
||||
new ShareeBike.Settings.PollingParameters(new TimeSpan(10000), true),
|
||||
Serilog.Events.LogEventLevel.Error,
|
||||
activeLockService: typeof(ShareeBike.Services.BluetoothLock.BLE.LockItByGuidService).FullName,
|
||||
activeGeolocationService: typeof(ShareeBike.Services.Geolocation.LastKnownGeolocationService).FullName),
|
||||
new StoreMock(),
|
||||
(isConnected, uri, sessionCookie, mail, expiresAfter) => new ConnectorCache(new AppContextInfo("MyMerchId", "MyApp", new Version(1, 2)), sessionCookie, mail, new CopriCallsMemory(SampleSets.Set2, 1)),
|
||||
Substitute.For<IServicesContainer<IGeolocation>>(),
|
||||
null, // use default locks service
|
||||
new DeviceMock(),
|
||||
new SpecialFolderMock(),
|
||||
null, // Cipher
|
||||
Substitute.For<ILocationPermission>(),
|
||||
isConnectedFunc: () => true,
|
||||
currentVersion: l_oAppVersion, // Current app version<
|
||||
lastVersion: l_oWhatsNewVersion); // Whats new page was never shown.
|
||||
|
||||
// Whats new page
|
||||
Assert.IsFalse(
|
||||
l_oShareeBikeApp.WhatsNew.IsShowRequired,
|
||||
$"Whats new should not be displayed because app version is {l_oAppVersion} and version when \"Whats New\" was shown last is {l_oWhatsNewVersion} equals.");
|
||||
|
||||
// Call member which view model would call if Whats New would have been shown.
|
||||
l_oShareeBikeApp.SetWhatsNewWasShown();
|
||||
|
||||
// Whats new page
|
||||
Assert.IsFalse(
|
||||
l_oShareeBikeApp.WhatsNew.IsShowRequired,
|
||||
$"Whats new should mot be displayed because app version is {l_oAppVersion} and version when \"Whats New\" was shown last is {l_oWhatsNewVersion} equals.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue