sharee.bike-App/SharedBusinessLogic.Tests/Model/Connector/Updater/TestRentalDescription.cs

201 lines
5.6 KiB
C#
Raw Normal View History

2023-06-06 12:00:24 +02:00
using Newtonsoft.Json;
2022-08-30 15:42:25 +02:00
using NUnit.Framework;
2024-04-09 12:53:23 +02:00
using ShareeBike.Model.Connector.Updater;
using ShareeBike.Repository.Response;
2022-08-30 15:42:25 +02:00
2024-04-09 12:53:23 +02:00
namespace SharedBusinessLogic.Tests.Model.Connector.Updater
2022-08-30 15:42:25 +02:00
{
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
}