using NUnit.Framework; using TINK.Model.Connector.Updater; using TINK.Repository.Response; namespace TestShareeLib.Model.Connector.Updater { [TestFixture] public class TestTariffDescriptionFactory { [Test] public void TestCreateTariffDescription() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""eur_per_hour"" : ""10.50"", ""abo_eur_per_month"" : ""920.99"", ""free_hours"" : ""1.50"", ""number"" : ""5494"", ""name"" : ""Tester Basic"" }"); Assert.That( tariffDescription.Create().Name, Is.EqualTo("Tester Basic")); Assert.That( tariffDescription.Create().Id, Is.EqualTo(5494)); Assert.That( tariffDescription.Create().TariffEntries["1"].Value, // Free time per session Is.EqualTo("1.50 hour(s)/day")); // Did not contain unit before switching signature from TariffDescription to TariffDescription2. Assert.That( tariffDescription.Create().TariffEntries["2"].Value, // FeeEuroPerHour Is.EqualTo("10.50 €/hour")); // Did not contain unit before switching signature from TariffDescription to TariffDescription2. Assert.That( tariffDescription.Create().TariffEntries["4"].Value, // Abo euro per month Is.EqualTo("920.99 €/month")); } [Test] public void TestCreateTariffDescription_Name() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""eur_per_hour"" : ""10.50"", ""abo_eur_per_month"" : ""920.99"", ""free_hours"" : ""1.50"", ""number"" : ""5494"", ""name"" : ""Tester Basic"" }"); Assert.That( tariffDescription.Create().Name, Is.EqualTo("Tester Basic")); } [Test] public void TestCreateTariffDescription_Number() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""eur_per_hour"" : ""10.50"", ""abo_eur_per_month"" : ""920.99"", ""free_hours"" : ""1.50"", ""number"" : ""5494"", ""name"" : ""Tester Basic"" }"); Assert.That( tariffDescription.Create().Id, Is.EqualTo(5494)); } [Test] public void TestCreateTariffDescription_FreeTimePerSession() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""eur_per_hour"" : ""10.50"", ""abo_eur_per_month"" : ""920.99"", ""free_hours"" : ""1.50"", ""number"" : ""5494"", ""name"" : ""Tester Basic"" }"); Assert.That( tariffDescription.Create().TariffEntries["1"].Value, // Free time per session Is.EqualTo("1.50 hour(s)/day")); // Did not contain unit before switching signature from TariffDescription to TariffDescription2. } [Test] public void TestCreateTariffDescription_FeeEuroPerHour() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""eur_per_hour"" : ""10.50"", ""abo_eur_per_month"" : ""920.99"", ""free_hours"" : ""1.50"", ""number"" : ""5494"", ""name"" : ""Tester Basic"" }"); Assert.That( tariffDescription.Create().TariffEntries["2"].Value, // FeeEuroPerHour Is.EqualTo("10.50 €/hour")); // Did not contain unit before switching signature from TariffDescription to TariffDescription2. } [Test] public void TestCreateTariffDescription_AboEuroPerMonth() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{ ""eur_per_hour"" : ""10.50"", ""abo_eur_per_month"" : ""920.99"", ""free_hours"" : ""1.50"", ""number"" : ""5494"", ""name"" : ""Tester Basic"" }"); Assert.That( tariffDescription.Create().TariffEntries["4"].Value, // Abo euro per month Is.EqualTo("920.99 €/month")); } [Test] public void TestCreateTariffDescription_Name_Empty() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{}"); Assert.That( tariffDescription.Create().Name, Is.Null); } [Test] public void TestCreateTariffDescription_Number_Empty() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{}"); Assert.That( tariffDescription.Create().Id, Is.Null); } [Test] public void TestCreateTariffDescription_FreeTimePerSession_Empty() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{}"); Assert.That( tariffDescription.Create().TariffEntries.ContainsKey("1"), // Free time per session Is.False); } [Test] public void TestCreateTariffDescription_FeeEuroPerHour_Empty() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{}"); Assert.That( tariffDescription.Create().TariffEntries.ContainsKey("2"), // FeeEuroPerHour Is.False); } [Test] public void TestCreateTariffDescription_AboEuroPerMonth_Empty() { var tariffDescription = JsonConvertRethrow.DeserializeObject( @"{}"); Assert.That( tariffDescription.Create().TariffEntries.ContainsKey("4"), // Abo euro per month Is.False); } [Test] public void TestCreateTariffDescription_Name_Null() { Assert.That( TariffDescriptionFactory.Create(null).Name, Is.Null); } [Test] public void TestCreateTariffDescription_Number_Null() { Assert.That( TariffDescriptionFactory.Create(null).Id, Is.Null); } [Test] public void TestCreateTariffDescription_FreeTimePerSession_Null() { Assert.That( TariffDescriptionFactory.Create(null).TariffEntries.ContainsKey("1"), // Free time per session Is.False); } [Test] public void TestCreateTariffDescription_FeeEuroPerHour_Null() { Assert.That( TariffDescriptionFactory.Create(null).TariffEntries.ContainsKey("2"), // FeeEuroPerHour Is.False); } [Test] public void TestCreateTariffDescription_AboEuroPerMonth_Null() { Assert.That( TariffDescriptionFactory.Create(null).TariffEntries.ContainsKey("4"), // Abo euro per month Is.False); } } }