sharee.bike-App/TestShareeLib/Model/Connector/Updater/TestRentalDescription.cs

201 lines
5.5 KiB
C#
Raw Normal View History

2022-08-30 15:42:25 +02:00
using Newtonsoft.Json;
using NUnit.Framework;
using TINK.Model.Connector.Updater;
using TINK.Repository.Response;
namespace TestShareeLib.Model.Connector.Updater
{
2022-09-06 16:08:19 +02:00
[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>(
@"{
2022-08-30 15:42:25 +02:00
""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!""
]
}
}");
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().Name,
Is.EqualTo("REN E-Bike"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().Id,
Is.EqualTo(1));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries.Count,
Is.EqualTo(3));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().InfoEntries.Count,
Is.EqualTo(2));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries["1"].Description,
Is.EqualTo("Mietgebühr"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries["1"].Value,
Is.EqualTo("2,00 € / 1 Std"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries["4"].Description,
Is.EqualTo("Max. Gebühr"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries["4"].Value,
Is.EqualTo("40.00 € / Tag"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries["6"].Description,
Is.EqualTo("Gratis Mietzeit"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries["6"].Value,
Is.EqualTo("30 Min / Tag"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().InfoEntries["8"].Key,
Is.EqualTo("Tracking"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
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!"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().InfoEntries["9"].Key,
Is.EqualTo("AGB"));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
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"));
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCreateRentalDescriptionDupeTarifElements()
{
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
@"{
2022-08-30 15:42:25 +02:00
""id"": ""1"",
""tarif_elements"" : {
""6"": [
""Gratis Mietzeit"",
""30 Min / Tag""
],
""6"": [
""Mietgebühr"",
""2,00 / 1 Std""
],
""4"": [
""Max. Gebühr"",
""40.00 / Tag""
]
}
}");
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries.Count,
Is.EqualTo(2));
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCreateRentalDescriptionDupeInfoElements()
{
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
@"{
2022-08-30 15:42:25 +02:00
""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!""
]
}
}");
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().InfoEntries.Count,
Is.EqualTo(1));
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCreateRentalDescriptionsNoTariffElements()
{
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
@"{
2022-08-30 15:42:25 +02:00
""rental_info"" : {
}
}");
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().TariffEntries,
Is.Not.Null);
}
2022-08-30 15:42:25 +02:00
2022-09-06 16:08:19 +02:00
[Test]
public void TestCreateRentalDescriptionsNoInfoElements()
{
var response = JsonConvertRethrow.DeserializeObject<RentalDescription>(
@"{
2022-08-30 15:42:25 +02:00
""rental_info"" : {
}
}");
2022-09-06 16:08:19 +02:00
Assert.That(
response.Create().InfoEntries,
Is.Not.Null);
}
}
2022-08-30 15:42:25 +02:00
}