mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2024-11-05 10:36:30 +01:00
97 lines
2.7 KiB
C#
97 lines
2.7 KiB
C#
using NUnit.Framework;
|
|
using TINK.Repository.Response;
|
|
|
|
namespace TestShareeLib.Repository.Response
|
|
{
|
|
[TestFixture]
|
|
public class TestTariffDescription
|
|
{
|
|
[Test]
|
|
public void TestDeserialize()
|
|
{
|
|
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
|
@"{
|
|
""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()
|
|
{
|
|
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
|
@"{
|
|
""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()
|
|
{
|
|
var tariffDescription = JsonConvertRethrow.DeserializeObject<TariffDescription>(
|
|
@"{
|
|
""number"" : ""5494"",
|
|
""name"" : ""Tester Basic"",
|
|
""FancyNewElement"" : ""Yeah""
|
|
}");
|
|
|
|
Assert.That(
|
|
tariffDescription.number,
|
|
Is.EqualTo("5494"));
|
|
|
|
Assert.That(
|
|
tariffDescription.name,
|
|
Is.EqualTo("Tester Basic"));
|
|
}
|
|
}
|
|
}
|