sharee.bike-App/TestShareeLib/Repository/Response/TestTariffDescription.cs

98 lines
2.7 KiB
C#
Raw Permalink Normal View History

2021-05-13 20:09:46 +02:00
using NUnit.Framework;
using TINK.Repository.Response;
namespace TestShareeLib.Repository.Response
{
[TestFixture]
public class TestTariffDescription
{
[Test]
public void TestDeserialize()
{
2021-06-26 20:57:55 +02:00
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
2021-05-13 20:09:46 +02:00
@"{
""eur_per_hour"" : ""10.00"",
""abo_eur_per_month"" : ""920.00"",
""free_hours"" : ""3.00"",
""number"" : ""5494"",
""name"" : ""Tester Basic""
}");
Assert.That(
tariffDescription.eur_per_hour,
Is.EqualTo("10.00"));
Assert.That(
tariffDescription.abo_eur_per_month,
Is.EqualTo("920.00"));
Assert.That(
tariffDescription.free_hours,
Is.EqualTo("3.00"));
Assert.That(
tariffDescription.number,
Is.EqualTo("5494"));
Assert.That(
tariffDescription.name,
Is.EqualTo("Tester Basic"));
}
/// <summary>
/// Verifies that missing elements are initialized correctly.
/// </summary>
[Test]
public void TestDeserialize_Missing()
{
2021-06-26 20:57:55 +02:00
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
2021-05-13 20:09:46 +02:00
@"{
""number"" : ""5494"",
""name"" : ""Tester Basic""
}");
Assert.That(
tariffDescription.eur_per_hour,
Is.Null);
Assert.That(
tariffDescription.abo_eur_per_month,
Is.Null);
Assert.That(
tariffDescription.free_hours,
Is.Null);
Assert.That(
tariffDescription.number,
Is.EqualTo("5494"));
Assert.That(
tariffDescription.name,
Is.EqualTo("Tester Basic"));
}
/// <summary>
/// Verifies that unknown elemts in JSON to not lead to firing of exceptions.
/// </summary>
[Test]
public void TestDeserialize_NewElement()
{
2021-06-26 20:57:55 +02:00
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
2021-05-13 20:09:46 +02:00
@"{
""number"" : ""5494"",
""name"" : ""Tester Basic"",
""FancyNewElement"" : ""Yeah""
}");
Assert.That(
tariffDescription.number,
Is.EqualTo("5494"));
Assert.That(
tariffDescription.name,
Is.EqualTo("Tester Basic"));
}
}
}