mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-06-22 05:47:28 +02:00
Version 3.0.337
This commit is contained in:
parent
fd0e63cf10
commit
573fe77e12
2336 changed files with 33688 additions and 86082 deletions
|
@ -1,6 +1,6 @@
|
|||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Connector.Filter;
|
||||
|
||||
namespace TestShareeLib.Model.Connector.Filter
|
||||
|
@ -52,7 +52,7 @@ namespace TestShareeLib.Model.Connector.Filter
|
|||
public void TestIntersectByGoupId_Empty()
|
||||
{
|
||||
CollectionAssert.AreEqual(
|
||||
new List<string> (),
|
||||
new List<string>(),
|
||||
new List<string> { "FR_300102" }.IntersectByGoupId(new List<string> { "FR_300101" }));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Connector.Updater;
|
||||
using TINK.Repository.Response;
|
||||
|
||||
namespace TestShareeLib.Model.Connector
|
||||
|
@ -80,7 +80,7 @@ namespace TestShareeLib.Model.Connector
|
|||
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create(bikeInfoResponse).GetType(),
|
||||
Is.EqualTo( typeof(TINK.Model.Bike.CopriLock.BikeInfo)),
|
||||
Is.EqualTo(typeof(TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo)),
|
||||
"Default lock by is BackendLock.");
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ namespace TestShareeLib.Model.Connector
|
|||
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create(bikeInfoResponse).GetType(),
|
||||
Is.EqualTo(typeof(TINK.Model.Bike.BluetoothLock.BikeInfo)));
|
||||
Is.EqualTo(typeof(TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -117,7 +117,67 @@ namespace TestShareeLib.Model.Connector
|
|||
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create(bikeInfoResponse).GetType(),
|
||||
Is.EqualTo(typeof(TINK.Model.Bike.CopriLock.BikeInfo)));
|
||||
Is.EqualTo(typeof(TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreate_Available_CorpiLock_FeedbackPending()
|
||||
{
|
||||
var bikeInfoResponse = JsonConvert.DeserializeObject<BikeInfoAvailable>(
|
||||
@"{
|
||||
""description"" : ""Cargo Long"",
|
||||
""state"" : ""available"",
|
||||
""bike"" : ""1"",
|
||||
""gps"" : { ""latitude"": ""47.669888"", ""longitude"": ""9.167749"" },
|
||||
""station"" : ""9"",
|
||||
""system"" : ""SIGO"",
|
||||
""co2saving"" : ""You saved tonns of co2!"",
|
||||
""user_miniquery"" : {
|
||||
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
||||
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert."",
|
||||
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
||||
""questions"" : {
|
||||
""q1"" : {
|
||||
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
||||
""type"" : ""check_one"",
|
||||
""query"" : {
|
||||
""opt5"" : ""e. Ausprobieren"",
|
||||
""opt3"" : ""c. Lastentransport"",
|
||||
""opt6"" : ""f. Sonstiges"",
|
||||
""opt1"" : ""a. Einkauf"",
|
||||
""opt4"" : ""d. Freizeit"",
|
||||
""opt2"" : ""b. Kinderbeförderung""
|
||||
}
|
||||
},
|
||||
""q2"" : {
|
||||
""type"" : ""check_one"",
|
||||
""quest_text"" : ""2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?"",
|
||||
""query"" : {
|
||||
""opt1"" : ""a. Auto"",
|
||||
""opt7"" : ""g. Sonstige"",
|
||||
""opt2"" : ""b. Motorrad oder Motorroller"",
|
||||
""opt4"" : ""d. Eigenes Fahrrad"",
|
||||
""opt6"" : ""f. Keines (ich hätte die Fahrt sonst nicht gemacht)"",
|
||||
""opt5"" : ""e. Zu Fuß"",
|
||||
""opt3"" : ""c. Bus oder Bahn""
|
||||
},
|
||||
},
|
||||
""q3"" : {
|
||||
""type"" : ""text"",
|
||||
""quest_text"" : ""3. Haben Sie Anmerkungen oder Anregungen?"",
|
||||
""query"" : {
|
||||
""opt1"" : """"
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}");
|
||||
|
||||
var bike = BikeInfoFactory.Create(bikeInfoResponse) as TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo;
|
||||
|
||||
Assert.That(
|
||||
bike,
|
||||
Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -156,7 +216,7 @@ namespace TestShareeLib.Model.Connector
|
|||
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create(bikeInfoResponse, "a@b", () => new System.DateTime()).GetType(),
|
||||
Is.EqualTo(typeof(TINK.Model.Bike.CopriLock.BikeInfo)));
|
||||
Is.EqualTo(typeof(TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -175,7 +235,7 @@ namespace TestShareeLib.Model.Connector
|
|||
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create(bikeInfoResponse, "a@b", () => new System.DateTime()).GetType(),
|
||||
Is.EqualTo(typeof(TINK.Model.Bike.BluetoothLock.BikeInfo)));
|
||||
Is.EqualTo(typeof(TINK.Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -195,7 +255,72 @@ namespace TestShareeLib.Model.Connector
|
|||
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create(bikeInfoResponse, "a@b", () => new System.DateTime()).GetType(),
|
||||
Is.EqualTo(typeof(TINK.Model.Bike.CopriLock.BikeInfo)));
|
||||
Is.EqualTo(typeof(TINK.Model.Bikes.BikeInfoNS.CopriLock.BikeInfo)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreate_Available_CopriLock_FeedBackRequied()
|
||||
{
|
||||
var bikeInfoResponse = JsonConvert.DeserializeObject<BikeInfoAvailable>(
|
||||
@"{
|
||||
""rental_description"": {
|
||||
""reserve_timerange"": ""30 Min"",
|
||||
""name"": ""Lastenrad"",
|
||||
""rental_info"": {
|
||||
""2"": [
|
||||
""AGB"",
|
||||
""Mit der Mietrad Anmietung wird folgender Betreiber <a href='https://shareeapp-wue.copri.eu/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB).""
|
||||
],
|
||||
""1"": [
|
||||
""Tracking"",
|
||||
""Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!""
|
||||
]
|
||||
},
|
||||
""id"": ""5523"",
|
||||
""tarif_elements"": {
|
||||
""1"": [
|
||||
""Mietgebühr"",
|
||||
""3,00 € / 1 Std ""
|
||||
],
|
||||
""6"": [
|
||||
""Gratis Mietzeit"",
|
||||
""30 Min / Tag""
|
||||
],
|
||||
""4"": [
|
||||
""Max. Gebühr"",
|
||||
""15.00 € / Tag""
|
||||
]
|
||||
}
|
||||
},
|
||||
""uri_operator"": ""https://shareeapp-wue.copri.eu"",
|
||||
""state"": ""available"",
|
||||
""bike"": ""WUE5529"",
|
||||
""authed"": ""1"",
|
||||
""bike_group"": [
|
||||
""WUE300101""
|
||||
],
|
||||
""gps"": {
|
||||
""longitude"": null,
|
||||
""latitude"": null
|
||||
},
|
||||
""system"": ""sigo"",
|
||||
""tariff_description"": {
|
||||
""free_hours"": ""0.50"",
|
||||
""number"": ""5523"",
|
||||
""max_eur_per_day"": ""15.00"",
|
||||
""name"": ""Lastenrad"",
|
||||
""eur_per_hour"": ""3.00""
|
||||
},
|
||||
""station"": ""WUE9301"",
|
||||
""description"": ""sigolaster Bay"",
|
||||
""lock_state"": ""locked"",
|
||||
""co2saving"" : """"
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
BikeInfoFactory.Create(bikeInfoResponse)?.State?.Value,
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.FeedbackPending),
|
||||
"Bikes with state booking state available in ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
298
TestShareeLib/Model/Connector/TestCachedQueryLoggedIn.cs
Normal file
298
TestShareeLib/Model/Connector/TestCachedQueryLoggedIn.cs
Normal file
|
@ -0,0 +1,298 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Repository;
|
||||
using TINK.Repository.Response;
|
||||
using TINK.Services.CopriApi;
|
||||
|
||||
namespace TestShareeLib.Model.Connector
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestCachedQueryLoggedIn
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies that available bikes are not considered to by kind of MyBikes.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestGetBikesOccupiedAsyncMyBikesNone()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
|
||||
var bikesAvailable = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
|
||||
{
|
||||
""bikes"": {
|
||||
""FR1005"": {
|
||||
""system"": ""Sigo"",
|
||||
""state"": ""available"",
|
||||
""bike"": ""FR1005"",
|
||||
""station"": ""REN0"",
|
||||
}
|
||||
},
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var bikesOccupied = JsonConvert.DeserializeObject<BikesReservedOccupiedResponse>(@"
|
||||
{
|
||||
""bikes_occupied"": { },
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var resultAvailable = new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsHttps), // Marks that response was taken from cache
|
||||
bikesAvailable,
|
||||
new GeneralData());
|
||||
|
||||
var resultOccupied = new Result<BikesReservedOccupiedResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
bikesOccupied,
|
||||
new GeneralData());
|
||||
|
||||
server.GetBikesAvailable(false).Returns(Task.FromResult(resultAvailable));
|
||||
server.GetBikesOccupied(false).Returns(Task.FromResult(resultOccupied));
|
||||
|
||||
var query = new CachedQueryLoggedIn(
|
||||
server,
|
||||
"SessionCookie",
|
||||
"Mail",
|
||||
() => new DateTime(2022, 7, 16));
|
||||
|
||||
var bikesResponse = await query.GetBikesOccupiedAsync();
|
||||
|
||||
Assert.That(
|
||||
bikesResponse.Response.Count,
|
||||
Is.EqualTo(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that available bikes with Co2Saving entry set are considered to by kind of MyBikes.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestGetBikesOccupiedAsyncMyBikesOneFeedbackPending()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
|
||||
var bikesAvailable = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
|
||||
{
|
||||
""bikes"": {
|
||||
""FR1005"": {
|
||||
""system"": ""Sigo"",
|
||||
""state"": ""available"",
|
||||
""bike"": ""FR1005"",
|
||||
""station"": ""REN0"",
|
||||
""co2saving"" : """"
|
||||
}
|
||||
},
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var bikesOccupied = JsonConvert.DeserializeObject<BikesReservedOccupiedResponse>(@"
|
||||
{
|
||||
""bikes_occupied"": { },
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var resultAvailable = new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
bikesAvailable,
|
||||
new GeneralData());
|
||||
|
||||
var resultOccupied = new Result<BikesReservedOccupiedResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
bikesOccupied,
|
||||
new GeneralData());
|
||||
|
||||
server.GetBikesAvailable(false).Returns(Task.FromResult(resultAvailable));
|
||||
server.GetBikesOccupied(false).Returns(Task.FromResult(resultOccupied));
|
||||
|
||||
var query = new CachedQueryLoggedIn(
|
||||
server,
|
||||
"SessionCookie",
|
||||
"Mail",
|
||||
() => new DateTime(2022, 7, 16));
|
||||
|
||||
var bikesResponse = await query.GetBikesOccupiedAsync();
|
||||
|
||||
Assert.That(
|
||||
bikesResponse.Response.Count,
|
||||
Is.EqualTo(1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// .
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestGetBikesOccupiedAsyncMyBikesOneOccupied()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
|
||||
var bikesAvailable = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
|
||||
{
|
||||
""bikes"": { },
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var bikesOccupied = JsonConvert.DeserializeObject<BikesReservedOccupiedResponse>(@"
|
||||
{
|
||||
""bikes_occupied"": {
|
||||
""FR1005"": {
|
||||
""lock_state"": ""occupied"",
|
||||
""system"": ""Sigo"",
|
||||
""state"": ""occupied"",
|
||||
""bike"": ""FR1005"",
|
||||
""station"": ""REN0"",
|
||||
}
|
||||
},
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var resultAvailable = new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
bikesAvailable,
|
||||
new GeneralData());
|
||||
|
||||
var resultOccupied = new Result<BikesReservedOccupiedResponse>(
|
||||
typeof(CopriCallsHttps),
|
||||
bikesOccupied,
|
||||
new GeneralData());
|
||||
|
||||
server.GetBikesAvailable(false).Returns(Task.FromResult(resultAvailable)); // Get bikes from copri
|
||||
server.GetBikesOccupied(false).Returns(Task.FromResult(resultOccupied)); // Get bikes from cache
|
||||
|
||||
var query = new CachedQueryLoggedIn(
|
||||
server,
|
||||
"SessionCookie",
|
||||
"Mail",
|
||||
() => new DateTime(2022, 7, 16));
|
||||
|
||||
var bikesResponse = await query.GetBikesOccupiedAsync();
|
||||
|
||||
Assert.That(
|
||||
bikesResponse.Response.Count,
|
||||
Is.EqualTo(1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scenario: Call of GetBikesAvailable fails data is taken from cache.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestGetBikesOccupiedAsyncGetAvailableFailsMyBikeOneFeedbackPending()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
|
||||
var bikesAvailable = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
|
||||
{
|
||||
""bikes"": {
|
||||
""FR1005"": {
|
||||
""system"": ""Sigo"",
|
||||
""state"": ""available"",
|
||||
""bike"": ""FR1005"",
|
||||
""station"": ""REN0"",
|
||||
""co2saving"" : """"
|
||||
}
|
||||
},
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var bikesOccupied = JsonConvert.DeserializeObject<BikesReservedOccupiedResponse>(@"
|
||||
{
|
||||
""bikes_occupied"": { },
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var resultAvailable = new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsMonkeyStore),
|
||||
bikesAvailable,
|
||||
new GeneralData());
|
||||
|
||||
var resultOccupied = new Result<BikesReservedOccupiedResponse>(
|
||||
typeof(CopriCallsMonkeyStore),
|
||||
bikesOccupied,
|
||||
new GeneralData());
|
||||
|
||||
server.GetBikesAvailable(false).Returns(Task.FromResult(resultAvailable));
|
||||
server.GetBikesOccupied(true).Returns(Task.FromResult(resultOccupied));
|
||||
|
||||
var query = new CachedQueryLoggedIn(
|
||||
server,
|
||||
"SessionCookie",
|
||||
"Mail",
|
||||
() => new DateTime(2022, 7, 16));
|
||||
|
||||
var bikesResponse = await query.GetBikesOccupiedAsync();
|
||||
|
||||
Assert.That(
|
||||
bikesResponse.Response.Count,
|
||||
Is.EqualTo(1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scenario: Call of GetBikesAvailable succeeds but because call of GetBikesOccupied fails data is taken from cache.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestGetBikesOccupiedAsyncGetGetBikesOccupiedFailsMyBikeFeedbackPending()
|
||||
{
|
||||
var server = Substitute.For<ICachedCopriServer>();
|
||||
|
||||
var bikesAvailableCopri = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
|
||||
{
|
||||
""bikes"": { },
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var bikesAvailableCache = JsonConvert.DeserializeObject<BikesAvailableResponse>(@"
|
||||
{
|
||||
""bikes"": {
|
||||
""FR1005"": {
|
||||
""system"": ""Sigo"",
|
||||
""state"": ""available"",
|
||||
""bike"": ""FR1005"",
|
||||
""station"": ""REN0"",
|
||||
""co2saving"" : """"
|
||||
}
|
||||
},
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var bikesOccupied = JsonConvert.DeserializeObject<BikesReservedOccupiedResponse>(@"
|
||||
{
|
||||
""bikes_occupied"": { },
|
||||
""copri_version"": ""4.1.12.5"",
|
||||
}");
|
||||
|
||||
var resultAvailableCopri = new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsHttps), // Marks that response was taken from copri
|
||||
bikesAvailableCache,
|
||||
new GeneralData());
|
||||
|
||||
var resultAvailableCache = new Result<BikesAvailableResponse>(
|
||||
typeof(CopriCallsMonkeyStore), // Marks that response was taken from cache
|
||||
bikesAvailableCache,
|
||||
new GeneralData());
|
||||
|
||||
var resultOccupied = new Result<BikesReservedOccupiedResponse>(
|
||||
typeof(CopriCallsMonkeyStore),
|
||||
bikesOccupied,
|
||||
new GeneralData());
|
||||
|
||||
server.GetBikesAvailable(false).Returns(Task.FromResult(resultAvailableCopri)); // Get bikes from copri
|
||||
server.GetBikesOccupied(false).Returns(Task.FromResult(resultOccupied)); // Get bikes from copri fails
|
||||
server.GetBikesAvailable(true).Returns(Task.FromResult(resultAvailableCache)); // Get bikes from cache
|
||||
|
||||
var query = new CachedQueryLoggedIn(
|
||||
server,
|
||||
"SessionCookie",
|
||||
"Mail",
|
||||
() => new DateTime(2022, 7, 16));
|
||||
|
||||
var bikesResponse = await query.GetBikesOccupiedAsync();
|
||||
|
||||
Assert.That(
|
||||
bikesResponse.Response.Count,
|
||||
Is.EqualTo(1));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
using MonkeyCache.FileStore;
|
||||
using System;
|
||||
using MonkeyCache.FileStore;
|
||||
using NUnit.Framework;
|
||||
using Serilog;
|
||||
using System;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Model.Services.CopriApi.ServerUris;
|
||||
using TINK.Repository;
|
||||
|
@ -32,7 +32,7 @@ namespace TestTINKLib.Fixtures.Misc
|
|||
{
|
||||
Barrel.ApplicationId = GetType().Name + nameof(TestCachedQuery_GetStationsAll);
|
||||
|
||||
Log .Logger = new LoggerConfiguration()
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.ControlledBy(new Serilog.Core.LoggingLevelSwitch(Serilog.Events.LogEventLevel.Error))
|
||||
.WriteTo.Debug()
|
||||
.CreateLogger();
|
||||
|
@ -41,6 +41,7 @@ namespace TestTINKLib.Fixtures.Misc
|
|||
true, // Is connected
|
||||
new Uri(url),
|
||||
new AppContextInfo("oiF2kahH" + nameof(TestCachedQuery_GetStationsAll), "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cookieAndMail.Split(';')[0],
|
||||
cookieAndMail.Split(';')[1],
|
||||
TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
|
||||
|
@ -92,6 +93,7 @@ namespace TestTINKLib.Fixtures.Misc
|
|||
true, // Is connected
|
||||
new Uri(url),
|
||||
new AppContextInfo("oiF2kahH" + nameof(TestCachedQuery_GetBikes), "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cookieAndMail.Split(';')[0],
|
||||
cookieAndMail.Split(';')[1],
|
||||
TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
|
||||
|
@ -139,6 +141,7 @@ namespace TestTINKLib.Fixtures.Misc
|
|||
true, // Is connected
|
||||
new Uri(url),
|
||||
new AppContextInfo("oiF2kahH" + nameof(TestCachedQuery_GetBikesOccupied), "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cookieAndMail.Split(';')[0],
|
||||
cookieAndMail.Split(';')[1],
|
||||
TimeSpan.FromSeconds(3)); // See task #97 for need of custom expiresAfter value.
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
using MonkeyCache.FileStore;
|
||||
using System;
|
||||
using MonkeyCache.FileStore;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Repository;
|
||||
|
||||
|
@ -21,10 +17,10 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
Barrel.ApplicationId = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
|
||||
}
|
||||
|
||||
var connector = ConnectorFactory.Create(false, new Uri("https://1.2.3.4"), new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), "123456789", "a@b");
|
||||
var connector = ConnectorFactory.Create(false, new Uri("https://1.2.3.4"), new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), null /*UI language */, "123456789", "a@b");
|
||||
Assert.AreEqual(typeof(ConnectorCache), connector.GetType());
|
||||
|
||||
connector = ConnectorFactory.Create(true, new Uri("https://1.2.3.4"), new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), "123456789", "a@b");
|
||||
connector = ConnectorFactory.Create(true, new Uri("https://1.2.3.4"), new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), null /*UI language */, "123456789", "a@b");
|
||||
Assert.AreEqual(typeof(TINK.Model.Connector.Connector), connector.GetType());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using MonkeyCache.FileStore;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MonkeyCache.FileStore;
|
||||
using Newtonsoft.Json;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Services.CopriApi;
|
||||
using TINK.Repository;
|
||||
using TINK.Repository.Exception;
|
||||
|
@ -110,7 +110,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
public async Task TestGetBikesAvailable_NotExpired()
|
||||
{
|
||||
var cache = Substitute.For<ICopriCache>();
|
||||
var https = Substitute.For<ICopriServer >();
|
||||
var https = Substitute.For<ICopriServer>();
|
||||
|
||||
cache.IsBikesAvailableExpired.Returns(false);
|
||||
cache.GetBikesAvailableAsync().Returns(Task.Run(() => JsonConvert.DeserializeObject<BikesAvailableResponse>(BIKESAVAILABLE)));
|
||||
|
@ -119,6 +119,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123", // Merchant id
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
|
||||
null /*UI language */,
|
||||
"456", // cookie
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
@ -130,7 +131,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
Assert.IsNull(bikes.Exception);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task TestGetBikesAvailable_ExpiredForceCache()
|
||||
{
|
||||
|
@ -144,6 +145,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
||||
|
@ -167,6 +169,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
||||
|
@ -191,6 +194,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
||||
|
@ -214,6 +218,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"12345678", // Merchant id
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
|
||||
null /*UI language */,
|
||||
"f782a208d9399291ba8d086b5dcc2509", // Auth cookie
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
@ -238,6 +243,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"12345678", // Merchant id
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
|
||||
null /*UI language */,
|
||||
"f782a208d9399291ba8d086b5dcc2509", // Auth cookie
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
@ -262,6 +268,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"12345678", // Merchant id
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
|
||||
null /*UI language */,
|
||||
"f782a208d9399291ba8d086b5dcc2509", // Auth cookie
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
@ -287,6 +294,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"12345678", // Merchant id
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
|
||||
null /*UI language */,
|
||||
"f782a208d9399291ba8d086b5dcc2509", // Auth cookie
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
@ -311,6 +319,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123", // Merchant id
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
|
||||
null /*UI language */,
|
||||
"456", // cookie
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
@ -335,6 +344,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
||||
|
@ -358,6 +368,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
||||
|
@ -382,6 +393,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */,
|
||||
cacheServer: cache,
|
||||
httpsServer: https);
|
||||
|
||||
|
@ -403,7 +415,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
var provider = new CopriProviderHttps(
|
||||
new Uri("http://1.2.3.4"),
|
||||
"123456789",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)));
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */);
|
||||
|
||||
var stations = await provider.GetStations(true);
|
||||
Assert.AreEqual(0, stations.Response.stations.Count);
|
||||
|
@ -442,7 +455,8 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
var provider = new CopriProviderHttps(
|
||||
new Uri("http://1.2.3.4"),
|
||||
"123456789",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)));
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)),
|
||||
null /*UI language */);
|
||||
|
||||
var bikes = await provider.GetBikesAvailable(true);
|
||||
Assert.AreEqual(0, bikes.Response.bikes.Count);
|
||||
|
@ -483,6 +497,7 @@ namespace TestTINKLib.Fixtures.ObjectTests.Connector
|
|||
new Uri("http://1.2.3.4"),
|
||||
"123456789",
|
||||
new AppContextInfo("oiF2kahH", "sharee.bike.test", new Version(3, 0, 267)), // User agent
|
||||
null /* langugage */,
|
||||
"876");
|
||||
|
||||
var bikes = await provider.GetBikesOccupied(true);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using TINK.Model.Bike;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.BikeNS;
|
||||
using TINK.Model.Connector;
|
||||
using TINK.Repository.Exception;
|
||||
using TINK.Repository.Response;
|
||||
|
@ -34,6 +34,10 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
""bike"" : ""2"",
|
||||
""bike_group"" : [ ""TINK"" ],
|
||||
""description"" : ""Cargo Long"",
|
||||
""bike_type"": {
|
||||
""category"": ""cargo"",
|
||||
""wheels"": ""2""
|
||||
},
|
||||
""gps"" : { ""latitude"": ""47.6612083333"", ""longitude"": ""9.16637533333"" },
|
||||
""station"" : ""9"",
|
||||
""state"" : ""available""
|
||||
|
@ -47,6 +51,10 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
""bike"" : ""11"",
|
||||
""bike_group"" : [ ""TINK"" ],
|
||||
""description"" : ""Cargo Trike"",
|
||||
""bike_type"": {
|
||||
""category"": ""cargo"",
|
||||
""wheels"": ""3""
|
||||
},
|
||||
""gps"" : { ""latitude"": ""47.665051"", ""longitude"": ""9.174096"" },
|
||||
""station"" : ""1"",
|
||||
""state"" : ""available""
|
||||
|
@ -66,7 +74,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
}");
|
||||
|
||||
// Verify behaviour of member.
|
||||
Assert.AreEqual(WheelType.Two, TextToTypeHelper.GetWheelType(l_oInfo));
|
||||
Assert.That(TextToTypeHelper.GetWheelType(l_oInfo), Is.Null); // Was WheelType.Two up to 3.0.322
|
||||
|
||||
l_oInfo = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
{
|
||||
|
@ -79,7 +87,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
}");
|
||||
|
||||
// Verify behaviour of member.
|
||||
Assert.AreEqual(WheelType.Two, TextToTypeHelper.GetWheelType(l_oInfo));
|
||||
Assert.That(TextToTypeHelper.GetWheelType(l_oInfo), Is.Null); // Was WheelType.Two up to 3.0.322
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -97,69 +105,132 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestGetTypeOfBike()
|
||||
{
|
||||
var l_oInfo = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
var info = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
{
|
||||
""bike"" : ""2"",
|
||||
""bike_group"" : [ ""TINK"" ],
|
||||
""description"" : ""Cargo Long"",
|
||||
""bike_type"": {
|
||||
""category"": ""cargo"",
|
||||
""wheels"": ""2""
|
||||
},
|
||||
""gps"" : { ""latitude"": ""47.6612083333"", ""longitude"": ""9.16637533333"" },
|
||||
""station"" : ""9"",
|
||||
""state"" : ""available""
|
||||
}");
|
||||
|
||||
// Verify behaviour of member.
|
||||
Assert.AreEqual(TypeOfBike.Cargo, TextToTypeHelper.GetTypeOfBike(l_oInfo));
|
||||
Assert.AreEqual(TypeOfBike.Cargo, TextToTypeHelper.GetTypeOfBike(info));
|
||||
|
||||
l_oInfo = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
info = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
{
|
||||
""bike"" : ""11"",
|
||||
""bike_group"" : [ ""TINK"" ],
|
||||
""description"" : ""Cargo Trike"",
|
||||
""bike_type"": {
|
||||
""category"": ""cargo"",
|
||||
""wheels"": ""2""
|
||||
},
|
||||
""gps"" : { ""latitude"": ""47.665051"", ""longitude"": ""9.174096"" },
|
||||
""station"" : ""1"",
|
||||
""state"" : ""available""
|
||||
}");
|
||||
|
||||
// Verify behaviour of member.
|
||||
Assert.AreEqual(TypeOfBike.Cargo, TextToTypeHelper.GetTypeOfBike(l_oInfo));
|
||||
Assert.AreEqual(TypeOfBike.Cargo, TextToTypeHelper.GetTypeOfBike(info));
|
||||
|
||||
l_oInfo = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
info = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
{
|
||||
""bike"" : ""51"",
|
||||
""bike_group"" : [ ""Konrad"" ],
|
||||
""description"" : ""Demo Stadtrad"",
|
||||
""bike_type"": {
|
||||
""category"": ""city"",
|
||||
""wheels"": ""2""
|
||||
},
|
||||
""gps"" : { ""latitude"": ""47.657766"", ""longitude"": ""9.176094"" },
|
||||
""station"" : ""8"",
|
||||
""state"" : ""available""
|
||||
}");
|
||||
|
||||
// Verify behaviour of member.
|
||||
Assert.AreEqual(TypeOfBike.Citybike, TextToTypeHelper.GetTypeOfBike(l_oInfo));
|
||||
Assert.AreEqual(TypeOfBike.City, TextToTypeHelper.GetTypeOfBike(info));
|
||||
|
||||
l_oInfo = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
info = JsonConvertRethrow.DeserializeObject<BikeInfoBase>(@"
|
||||
{
|
||||
""bike"" : ""51"",
|
||||
""bike_group"" : [ ""Konrad"" ],
|
||||
""description"" : ""Stadtrad"",
|
||||
""bike_type"": {
|
||||
},
|
||||
""gps"" : { ""latitude"": ""47.657766"", ""longitude"": ""9.176094"" },
|
||||
""station"" : ""8"",
|
||||
""state"" : ""available""
|
||||
}");
|
||||
|
||||
// Verify behaviour of member.
|
||||
Assert.AreEqual(TypeOfBike.Citybike, TextToTypeHelper.GetTypeOfBike(l_oInfo));
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetTypeOfBike(info),
|
||||
Is.Null); // Version up to 3.0.322 considered this bike to be a city bike to to description "Stadtrad"
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetStateAvailable()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"state\" : \"available\" }").GetState(),
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.Disposable));
|
||||
|
||||
[Test]
|
||||
public void TestGetStateAvailableCase()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"state\" : \"availablE \" }").GetState(),
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.Disposable));
|
||||
|
||||
[Test]
|
||||
public void TestGetStateReserved()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"state\" : \"requested\" }").GetState(),
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.Reserved));
|
||||
|
||||
[Test]
|
||||
public void TestGetStateReservedCase()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"state\" : \" reQuested\" }").GetState(),
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.Reserved));
|
||||
|
||||
[Test]
|
||||
public void TestGetStateOccupied()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"state\" : \"occupied\" }").GetState(),
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.Booked));
|
||||
|
||||
[Test]
|
||||
public void TestGetStateOccupiedCase()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"state\" : \"occuPied\" }").GetState(),
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.Booked));
|
||||
|
||||
[Test]
|
||||
public void TestGetStateBikeInfoAvailableDisposable()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoAvailable>("{ \"state\" : \"available\" }").GetState(),
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.Disposable));
|
||||
[Test]
|
||||
public void TestGetStateBikeInfoAvailableFeedbackPending()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoAvailable>("{ \"state\" : \"available\", \"co2saving\" : \"\" }").GetState(),
|
||||
Is.EqualTo(TINK.Model.State.InUseStateEnum.FeedbackPending));
|
||||
|
||||
[Test]
|
||||
public void TestGetState_InvalidDescription()
|
||||
{
|
||||
var l_oInfo = new BikeInfoBase();
|
||||
var info = new BikeInfoBase();
|
||||
|
||||
// Verify prerequisites
|
||||
Assert.IsNull(l_oInfo.state);
|
||||
Assert.IsNull(info.state);
|
||||
|
||||
// Verify behaviour of member.
|
||||
Assert.Throws<InvalidResponseException<BikeInfoBase>>(() => TextToTypeHelper.GetState(l_oInfo));
|
||||
Assert.Throws<InvalidResponseException<BikeInfoBase>>(() => TextToTypeHelper.GetState(info));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -445,7 +516,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
[Test]
|
||||
public void TestGetGroupString_Roundtrip()
|
||||
{
|
||||
Assert.AreEqual("Tunk,Unk", TextToTypeHelper.GetGroup(TextToTypeHelper.GetGroup(new [] { "Tunk", "Unk" })));
|
||||
Assert.AreEqual("Tunk,Unk", TextToTypeHelper.GetGroup(TextToTypeHelper.GetGroup(new[] { "Tunk", "Unk" })));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -592,7 +663,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
{
|
||||
}");
|
||||
|
||||
Assert.AreEqual(0, TextToTypeHelper.GetBluetoothLockId (l_oInfo));
|
||||
Assert.AreEqual(0, TextToTypeHelper.GetBluetoothLockId(l_oInfo));
|
||||
|
||||
l_oInfo = JsonConvertRethrow.DeserializeObject<BikeInfoReservedOrBooked>(@"
|
||||
{
|
||||
|
@ -643,10 +714,10 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
{
|
||||
""copri_version"": ""4.3.2.1""
|
||||
}");
|
||||
|
||||
|
||||
Assert.That(
|
||||
version.GetCopriVersion(),
|
||||
Is.EqualTo(new Version(4,3,2,1)));
|
||||
Is.EqualTo(new Version(4, 3, 2, 1)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -819,7 +890,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetCopriLockingState(response),
|
||||
Is.EqualTo(TINK.Model.Bikes.Bike.CopriLock.LockingState.Closed));
|
||||
Is.EqualTo(TINK.Model.Bikes.BikeInfoNS.CopriLock.LockingState.Closed));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -838,7 +909,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetCopriLockingState(response),
|
||||
Is.EqualTo(TINK.Model.Bikes.Bike.CopriLock.LockingState.Closing));
|
||||
Is.EqualTo(TINK.Model.Bikes.BikeInfoNS.CopriLock.LockingState.Closing));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -857,7 +928,7 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetCopriLockingState(response),
|
||||
Is.EqualTo(TINK.Model.Bikes.Bike.CopriLock.LockingState.Open));
|
||||
Is.EqualTo(TINK.Model.Bikes.BikeInfoNS.CopriLock.LockingState.Open));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -876,7 +947,84 @@ namespace TestTINKLib.Fixtures.Connector
|
|||
|
||||
Assert.That(
|
||||
TextToTypeHelper.GetCopriLockingState(response),
|
||||
Is.EqualTo(TINK.Model.Bikes.Bike.CopriLock.LockingState.Opening));
|
||||
Is.EqualTo(TINK.Model.Bikes.BikeInfoNS.CopriLock.LockingState.Opening));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGetIsFeedbackPendingIsPendingValue()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoAvailable>("{ \"co2saving\" : \"Tonns\" }").GetIsFeedbackPending(),
|
||||
Is.True);
|
||||
|
||||
[Test]
|
||||
public void TestGetIsFeedbackPendingIsPending()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoAvailable>("{ \"co2saving\" : \"\" }").GetIsFeedbackPending(),
|
||||
Is.True);
|
||||
|
||||
[Test]
|
||||
public void TestGetIsFeedbackPendingNot()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoAvailable>("{ }").GetIsFeedbackPending(),
|
||||
Is.False);
|
||||
|
||||
[Test]
|
||||
public void TestGetTypeOfBikeCity()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"bike_type\" : { \"category\" : \"city\" } }").GetTypeOfBike(),
|
||||
Is.EqualTo(TypeOfBike.City));
|
||||
|
||||
[Test]
|
||||
public void TestGetTypeOfBikeCargo()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"bike_type\" : { \"category\" : \"cargo\" } }").GetTypeOfBike(),
|
||||
Is.EqualTo(TypeOfBike.Cargo));
|
||||
|
||||
[Test]
|
||||
public void TestGetTypeOfBikeNull()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"bike_type\" : { } }").GetTypeOfBike(),
|
||||
Is.Null);
|
||||
|
||||
[Test]
|
||||
public void TestGetWheelTypeTrike()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"bike_type\" : { \"wheels\" : \"3\" } }").GetWheelType(),
|
||||
Is.EqualTo(WheelType.Trike));
|
||||
|
||||
[Test]
|
||||
public void TestGetWheelTypeQuad()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"bike_type\" : { \"wheels\" : \"4\" } }").GetWheelType(),
|
||||
Is.EqualTo(WheelType.Quad));
|
||||
|
||||
[Test]
|
||||
public void TestGetWheelTypeTow()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"bike_type\" : { \"wheels\" : \"2\" } }").GetWheelType(),
|
||||
Is.EqualTo(WheelType.Two));
|
||||
|
||||
[Test]
|
||||
public void TestGetWheelTypeNull()
|
||||
=> Assert.That(
|
||||
JsonConvert.DeserializeObject<BikeInfoBase>("{ \"bike_type\" : { } }").GetWheelType(),
|
||||
Is.Null);
|
||||
|
||||
[Test]
|
||||
public void TestGetFrom()
|
||||
=> Assert.That(
|
||||
JsonConvertRethrow.DeserializeObject<BikeInfoReservedOrBooked>(@"
|
||||
{
|
||||
""start_time"" : ""2022-7-16"",
|
||||
}").GetFrom(),
|
||||
Is.EqualTo(new DateTime(2022, 7, 16)));
|
||||
|
||||
[Test]
|
||||
public void TestGetFromInvalid()
|
||||
=> Assert.That(
|
||||
JsonConvertRethrow.DeserializeObject<BikeInfoReservedOrBooked>(@"
|
||||
{
|
||||
}").GetFrom(),
|
||||
Is.EqualTo(DateTime.MinValue));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Connector.Updater;
|
||||
using TINK.Repository.Response;
|
||||
|
||||
|
||||
namespace TestShareeLib.Model.Connector.Updater
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestBookingFinishedModelFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_Co2Saving()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""co2saving"" : ""Einsparung: 1,95 kg CO2 und 3,00 EUR bei einer Strecke von 10 KM""
|
||||
}
|
||||
}");
|
||||
|
||||
var bookingFinshed = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
bookingFinshed.Co2Saving,
|
||||
Is.EqualTo("Einsparung: 1,95 kg CO2 und 3,00 EUR bei einer Strecke von 10 KM"));
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""user_miniquery"" : {
|
||||
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
||||
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
||||
""questions"" : {
|
||||
""q3"" : {
|
||||
""quest_text"" : ""3. Haben Sie Anmerkungen oder Anregungen?"",
|
||||
""type"" : ""text"",
|
||||
""query"" : {
|
||||
""opt1"" : """"
|
||||
}
|
||||
},
|
||||
""q1"" : {
|
||||
""type"" : ""check_one"",
|
||||
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
||||
""query"" : {
|
||||
""opt2"" : ""b. Kinderbeförderung"",
|
||||
""opt5"" : ""e. Ausprobieren"",
|
||||
""opt4"" : ""d. Freizeit"",
|
||||
""opt1"" : ""a. Einkauf"",
|
||||
""opt3"" : ""c. Lastentransport"",
|
||||
""opt6"" : ""f. Sonstiges""
|
||||
}
|
||||
},
|
||||
""q2"" : {
|
||||
""type"" : ""check_one"",
|
||||
""quest_text"" : ""2. Welches Verkehrsmittel hätten Sie ansonsten benutzt?"",
|
||||
""query"" : {
|
||||
""opt6"" : ""f. Keines (ich hätte die Fahrt sonst nicht gemacht)"",
|
||||
""opt3"" : ""c. Bus oder Bahn"",
|
||||
""opt1"" : ""a. Auto"",
|
||||
""opt2"" : ""b. Motorrad oder Motorroller"",
|
||||
""opt7"" : ""g. Sonstige"",
|
||||
""opt4"" : ""d. Eigenes Fahrrad"",
|
||||
""opt5"" : ""e. Zu Fuß""
|
||||
}
|
||||
}
|
||||
},
|
||||
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var bookingFinished = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
bookingFinished,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinished.MiniSurvey.Title,
|
||||
Is.EqualTo("Bitte unterstützen Sie unsere Begleitforschung"));
|
||||
|
||||
Assert.That(
|
||||
bookingFinished.MiniSurvey.Subtitle,
|
||||
Is.EqualTo("Ihre drei Antworten werden anonym gespeichert."));
|
||||
|
||||
Assert.That(
|
||||
bookingFinished.MiniSurvey.Footer,
|
||||
Is.EqualTo("Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"));
|
||||
|
||||
Assert.That(
|
||||
bookingFinished.MiniSurvey.Questions.Count,
|
||||
Is.EqualTo(3));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_Null()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var bookingFinshed = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
bookingFinshed,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinshed.MiniSurvey.Questions.Count,
|
||||
Is.EqualTo(0));
|
||||
|
||||
Assert.That(
|
||||
bookingFinshed.MiniSurvey.Title,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinshed.MiniSurvey.Subtitle,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinshed.MiniSurvey.Footer,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_EmptyQuery()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""user_miniquery"" : {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var bookingFinished = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
bookingFinished,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinished.MiniSurvey.Title,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinished.MiniSurvey.Subtitle,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinished.MiniSurvey.Footer,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_InvalidQuestion_KeyNull()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""user_miniquery"" : {
|
||||
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
||||
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
||||
""questions"" : {
|
||||
"""" : {
|
||||
""type"" : ""check_one"",
|
||||
""quest_text"" : ""1. Was war der Hauptzweck dieser Ausleihe?"",
|
||||
""query"" : {
|
||||
""opt2"" : ""b. Kinderbeförderung"",
|
||||
""opt5"" : ""e. Ausprobieren"",
|
||||
""opt4"" : ""d. Freizeit"",
|
||||
""opt1"" : ""a. Einkauf"",
|
||||
""opt3"" : ""c. Lastentransport"",
|
||||
""opt6"" : ""f. Sonstiges""
|
||||
}
|
||||
},
|
||||
},
|
||||
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var bookingFinised = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
bookingFinised,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinised.MiniSurvey.Questions.Count,
|
||||
Is.EqualTo(0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COPRI response shortened, part not belonging to user_miniquery discarded.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestCreateMiniSurvey_InvalidQuestion_ValueNull()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<ResponseContainer<DoReturnResponse>>(@"
|
||||
{
|
||||
""shareejson"" : {
|
||||
""user_miniquery"" : {
|
||||
""title"" : ""Bitte unterstützen Sie unsere Begleitforschung"",
|
||||
""footer"" : ""Herzlichen Dank und viel Spaß bei der nächsten Fahrt!"",
|
||||
""questions"" : {
|
||||
""q1"" : {
|
||||
},
|
||||
},
|
||||
""subtitle"" : ""Ihre drei Antworten werden anonym gespeichert.""
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
var bookingFinished = response.shareejson.Create();
|
||||
|
||||
Assert.That(
|
||||
bookingFinished,
|
||||
Is.Not.Null);
|
||||
|
||||
Assert.That(
|
||||
bookingFinished.MiniSurvey.Questions.Count,
|
||||
Is.EqualTo(0));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
208
TestShareeLib/Model/Connector/Updater/TestDriveFactory.cs
Normal file
208
TestShareeLib/Model/Connector/Updater/TestDriveFactory.cs
Normal file
|
@ -0,0 +1,208 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Bikes.BikeInfoNS.DriveNS;
|
||||
using TINK.Model.Connector.Updater;
|
||||
using TINK.Repository.Response;
|
||||
|
||||
namespace TestShareeLib.Model.Connector.Updater
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestDriveFactory
|
||||
{
|
||||
[Test]
|
||||
public void TestEmpty()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<BikeType>(@"");
|
||||
|
||||
Assert.That(
|
||||
response.Create().Type,
|
||||
Is.EqualTo(DriveType.SoleHumanPowered));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Engine.Manufacturer,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargePercent,
|
||||
Is.NaN);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.MaxChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.IsBackendAccessible,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.IsHidden,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEmptyEngine()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<BikeType>(@"
|
||||
{
|
||||
""category"" : ""cargo"",
|
||||
""wheels"" : ""2"",
|
||||
""engine"" : {
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().Type,
|
||||
Is.EqualTo(DriveType.SoleHumanPowered));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Engine.Manufacturer,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargePercent,
|
||||
Is.NaN);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.MaxChargeBars,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestEngine()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<BikeType>(@"
|
||||
{
|
||||
""category"" : ""cargo"",
|
||||
""wheels"" : ""2"",
|
||||
""engine"" : {
|
||||
""manufacturer"" : ""dummy""
|
||||
}
|
||||
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().Type,
|
||||
Is.EqualTo(DriveType.Pedelec));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Engine.Manufacturer,
|
||||
Is.EqualTo("dummy"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargePercent,
|
||||
Is.NaN);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargeBars,
|
||||
Is.Null);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.MaxChargeBars,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBatteryValues1()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<BikeType>(@"
|
||||
{
|
||||
""category"" : ""cargo"",
|
||||
""wheels"" : ""2"",
|
||||
""engine"" : {
|
||||
""manufacturer"" : ""dummy""
|
||||
},
|
||||
""battery"" : {
|
||||
""charge_current_bars"" : ""4"",
|
||||
""charge_max_bars"" : ""5"",
|
||||
""charge_current_percent"" : ""70"",
|
||||
""backend_accessible"" : ""0"",
|
||||
""hidden"" : ""0"",
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().Type,
|
||||
Is.EqualTo(DriveType.Pedelec));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Engine.Manufacturer,
|
||||
Is.EqualTo("dummy"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargePercent,
|
||||
Is.EqualTo(70.0));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargeBars,
|
||||
Is.EqualTo(4));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.MaxChargeBars,
|
||||
Is.EqualTo(5));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.IsBackendAccessible,
|
||||
Is.False);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.IsHidden,
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBatteryValues2()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<BikeType>(@"
|
||||
{
|
||||
""category"" : ""cargo"",
|
||||
""wheels"" : ""2"",
|
||||
""engine"" : {
|
||||
""manufacturer"" : ""dummy2""
|
||||
},
|
||||
""battery"" : {
|
||||
""charge_current_bars"" : ""1"",
|
||||
""charge_max_bars"" : ""6"",
|
||||
""charge_current_percent"" : ""70.3"",
|
||||
""backend_accessible"" : ""1"",
|
||||
""hidden"" : ""1"",
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().Type,
|
||||
Is.EqualTo(DriveType.Pedelec));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Engine.Manufacturer,
|
||||
Is.EqualTo("dummy2"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargePercent,
|
||||
Is.EqualTo(70.3));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.CurrentChargeBars,
|
||||
Is.EqualTo(1));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.MaxChargeBars,
|
||||
Is.EqualTo(6));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.IsBackendAccessible,
|
||||
Is.True);
|
||||
|
||||
Assert.That(
|
||||
response.Create().Battery.IsHidden,
|
||||
Is.True);
|
||||
}
|
||||
}
|
||||
}
|
200
TestShareeLib/Model/Connector/Updater/TestRentalDescription.cs
Normal file
200
TestShareeLib/Model/Connector/Updater/TestRentalDescription.cs
Normal file
|
@ -0,0 +1,200 @@
|
|||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using TINK.Model.Connector.Updater;
|
||||
using TINK.Repository.Response;
|
||||
|
||||
|
||||
namespace TestShareeLib.Model.Connector.Updater
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestRentalDescription
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void TestCreateRentalDescriptionEmpyJson()
|
||||
{
|
||||
var response = JsonConvert.DeserializeObject<RentalDescription>(@"");
|
||||
|
||||
Assert.That(
|
||||
response.Create().Name,
|
||||
Is.Empty);
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries.Count,
|
||||
Is.EqualTo(0));
|
||||
|
||||
Assert.That(
|
||||
response.Create().InfoEntries.Count,
|
||||
Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateRentalDescription()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
|
||||
@"{
|
||||
""id"": ""1"",
|
||||
""tarif_elements"" : {
|
||||
""6"": [
|
||||
""Gratis Mietzeit"",
|
||||
""30 Min / Tag""
|
||||
],
|
||||
""1"": [
|
||||
""Mietgebühr"",
|
||||
""2,00 € / 1 Std""
|
||||
],
|
||||
""4"": [
|
||||
""Max. Gebühr"",
|
||||
""40.00 € / Tag""
|
||||
]
|
||||
},
|
||||
""name"": ""REN E-Bike"",
|
||||
""rental_info"" : {
|
||||
""9"" : [
|
||||
""AGB"",
|
||||
""Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt""
|
||||
],
|
||||
""8"" : [
|
||||
""Tracking"",
|
||||
""Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!""
|
||||
]
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().Name,
|
||||
Is.EqualTo("REN E-Bike"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().Id,
|
||||
Is.EqualTo(1));
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries.Count,
|
||||
Is.EqualTo(3));
|
||||
|
||||
Assert.That(
|
||||
response.Create().InfoEntries.Count,
|
||||
Is.EqualTo(2));
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries["1"].Description,
|
||||
Is.EqualTo("Mietgebühr"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries["1"].Value,
|
||||
Is.EqualTo("2,00 € / 1 Std"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries["4"].Description,
|
||||
Is.EqualTo("Max. Gebühr"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries["4"].Value,
|
||||
Is.EqualTo("40.00 € / Tag"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries["6"].Description,
|
||||
Is.EqualTo("Gratis Mietzeit"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries["6"].Value,
|
||||
Is.EqualTo("30 Min / Tag"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().InfoEntries["8"].Key,
|
||||
Is.EqualTo("Tracking"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().InfoEntries["8"].Value,
|
||||
Is.EqualTo("Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().InfoEntries["9"].Key,
|
||||
Is.EqualTo("AGB"));
|
||||
|
||||
Assert.That(
|
||||
response.Create().InfoEntries["9"].Value,
|
||||
Is.EqualTo("Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt"));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestCreateRentalDescriptionDupeTarifElements()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
|
||||
@"{
|
||||
""id"": ""1"",
|
||||
""tarif_elements"" : {
|
||||
""6"": [
|
||||
""Gratis Mietzeit"",
|
||||
""30 Min / Tag""
|
||||
],
|
||||
""6"": [
|
||||
""Mietgebühr"",
|
||||
""2,00 € / 1 Std""
|
||||
],
|
||||
""4"": [
|
||||
""Max. Gebühr"",
|
||||
""40.00 € / Tag""
|
||||
]
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries.Count,
|
||||
Is.EqualTo(2));
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateRentalDescriptionDupeInfoElements()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
|
||||
@"{
|
||||
""rental_info"" : {
|
||||
""9"" : [
|
||||
""AGB"",
|
||||
""Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt""
|
||||
],
|
||||
""9"" : [
|
||||
""Tracking"",
|
||||
""Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!""
|
||||
]
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().InfoEntries.Count,
|
||||
Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateRentalDescriptionsNoTariffElements()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
|
||||
@"{
|
||||
""rental_info"" : {
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().TariffEntries,
|
||||
Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateRentalDescriptionsNoInfoElements()
|
||||
{
|
||||
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
|
||||
@"{
|
||||
""rental_info"" : {
|
||||
}
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
response.Create().InfoEntries,
|
||||
Is.Not.Null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,224 @@
|
|||
using NUnit.Framework;
|
||||
using TINK.Model.Connector.Updater;
|
||||
using TINK.Repository.Response;
|
||||
|
||||
|
||||
namespace TestShareeLib.Model.Connector.Updater
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestTariffDescriptionFactory
|
||||
{
|
||||
[Test]
|
||||
public void TestCreateTariffDescription()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
""free_hours"" : ""1.50"",
|
||||
""number"" : ""5494"",
|
||||
""name"" : ""Tester Basic""
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().Name,
|
||||
Is.EqualTo("Tester Basic"));
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().Id,
|
||||
Is.EqualTo(5494));
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries["1"].Value, // Free time per session
|
||||
Is.EqualTo("1.50 hour(s)/day")); // Did not contain unit before switching signature from TariffDescription to TariffDescription2.
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries["2"].Value, // FeeEuroPerHour
|
||||
Is.EqualTo("10.50 €/hour")); // Did not contain unit before switching signature from TariffDescription to TariffDescription2.
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries["4"].Value, // Abo euro per month
|
||||
Is.EqualTo("920.99 €/month"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_Name()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
""free_hours"" : ""1.50"",
|
||||
""number"" : ""5494"",
|
||||
""name"" : ""Tester Basic""
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().Name,
|
||||
Is.EqualTo("Tester Basic"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_Number()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
""free_hours"" : ""1.50"",
|
||||
""number"" : ""5494"",
|
||||
""name"" : ""Tester Basic""
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().Id,
|
||||
Is.EqualTo(5494));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_FreeTimePerSession()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
""free_hours"" : ""1.50"",
|
||||
""number"" : ""5494"",
|
||||
""name"" : ""Tester Basic""
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries["1"].Value, // Free time per session
|
||||
Is.EqualTo("1.50 hour(s)/day")); // Did not contain unit before switching signature from TariffDescription to TariffDescription2.
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_FeeEuroPerHour()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
""free_hours"" : ""1.50"",
|
||||
""number"" : ""5494"",
|
||||
""name"" : ""Tester Basic""
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries["2"].Value, // FeeEuroPerHour
|
||||
Is.EqualTo("10.50 €/hour")); // Did not contain unit before switching signature from TariffDescription to TariffDescription2.
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_AboEuroPerMonth()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{
|
||||
""eur_per_hour"" : ""10.50"",
|
||||
""abo_eur_per_month"" : ""920.99"",
|
||||
""free_hours"" : ""1.50"",
|
||||
""number"" : ""5494"",
|
||||
""name"" : ""Tester Basic""
|
||||
}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries["4"].Value, // Abo euro per month
|
||||
Is.EqualTo("920.99 €/month"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_Name_Empty()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().Name,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_Number_Empty()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().Id,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_FreeTimePerSession_Empty()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries.ContainsKey("1"), // Free time per session
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_FeeEuroPerHour_Empty()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries.ContainsKey("2"), // FeeEuroPerHour
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_AboEuroPerMonth_Empty()
|
||||
{
|
||||
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
||||
@"{}");
|
||||
|
||||
Assert.That(
|
||||
tariffDescription.Create().TariffEntries.ContainsKey("4"), // Abo euro per month
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_Name_Null()
|
||||
{
|
||||
Assert.That(
|
||||
TariffDescriptionFactory.Create(null).Name,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_Number_Null()
|
||||
{
|
||||
Assert.That(
|
||||
TariffDescriptionFactory.Create(null).Id,
|
||||
Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_FreeTimePerSession_Null()
|
||||
{
|
||||
Assert.That(
|
||||
TariffDescriptionFactory.Create(null).TariffEntries.ContainsKey("1"), // Free time per session
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_FeeEuroPerHour_Null()
|
||||
{
|
||||
Assert.That(
|
||||
TariffDescriptionFactory.Create(null).TariffEntries.ContainsKey("2"), // FeeEuroPerHour
|
||||
Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCreateTariffDescription_AboEuroPerMonth_Null()
|
||||
{
|
||||
Assert.That(
|
||||
TariffDescriptionFactory.Create(null).TariffEntries.ContainsKey("4"), // Abo euro per month
|
||||
Is.False);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue