using NUnit.Framework; using TINK.Repository.Response; namespace TestShareeLib.Repository.Response { [TestFixture] public class TestTariffDescription { [Test] public void TestDeserialize() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""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")); } /// /// Verifies that missing elements are initialized correctly. /// [Test] public void TestDeserialize_Missing() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""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")); } /// /// Verifies that unknown elements in JSON to not lead to firing of exceptions. /// [Test] public void TestDeserialize_NewElement() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""number"" : ""5494"", ""name"" : ""Tester Basic"", ""FancyNewElement"" : ""Yeah"" }"); Assert.That( tariffDescription.number, Is.EqualTo("5494")); Assert.That( tariffDescription.name, Is.EqualTo("Tester Basic")); } } }