mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 18:46:30 +01:00
200 lines
5.5 KiB
C#
200 lines
5.5 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|