diff --git a/src/World.Net.UnitTests/Countries/ElSalvadorTest.cs b/src/World.Net.UnitTests/Countries/ElSalvadorTest.cs index 2093cb5..f0afe87 100644 --- a/src/World.Net.UnitTests/Countries/ElSalvadorTest.cs +++ b/src/World.Net.UnitTests/Countries/ElSalvadorTest.cs @@ -1,9 +1,8 @@ namespace World.Net.UnitTests.Countries { - public sealed class ElSalvadorTest + public sealed class ElSalvadorTest : AssertCountryTestBase { private const string ELSALVADOR_NAME = "ElSalvador"; - private const int ELSALVADOR_STATE_COUNT = 14; private const string ELSALVADOR_OFFICIAL_NAME = "Republic of El Salvador"; private const string ELSALVADOR_NATIVE_NAME = "República de El Salvador"; private const string ELSALVADOR_CAPITAL = "San Salvador"; @@ -11,30 +10,47 @@ public sealed class ElSalvadorTest private const string ELSALVADOR_ISO2_CODE = "SV"; private const string ELSALVADOR_ISO3_CODE = "SLV"; private readonly string[] ELSALVADOR_CALLING_CODE = ["503"]; - private static readonly string[] VALID_STATE_TYPES = { "Department" }; + private static CountryIdentifier ExpectedId => CountryIdentifier.ElSalvador; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + { + new("Ahuachapán", "AH", "Department"), + new("Cabañas", "CA", "Department"), + new("Chalatenango", "CH", "Department"), + new("Cuscatlán", "CU", "Department"), + new("La Libertad", "LI", "Department"), + new("La Paz", "PA", "Department"), + new("La Unión", "UN", "Department"), + new("Morazán", "MO", "Department"), + new("San Miguel", "SM", "Department"), + new("San Salvador", "SS", "Department"), + new("San Vicente", "SV", "Department"), + new("Santa Ana", "SA", "Department"), + new("Sonsonate", "SO", "Department"), + new("Usulután", "US", "Department") + }; [Fact] public void GetCountry_ReturnsCorrectInformation_ForElSalvador() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.ElSalvador; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(ELSALVADOR_NAME, country.Name); - Assert.NotNull(country.States); - Assert.Equal(ELSALVADOR_STATE_COUNT, country.States.Count()); - Assert.Equal(ELSALVADOR_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(ELSALVADOR_NATIVE_NAME, country.NativeName); - Assert.Equal(ELSALVADOR_CAPITAL, country.Capital); - Assert.Equal(ELSALVADOR_NUMERIC_CODE, country.NumericCode); - Assert.Equal(ELSALVADOR_ISO2_CODE, country.ISO2Code); - Assert.Equal(ELSALVADOR_ISO3_CODE, country.ISO3Code); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); - Assert.Equal(ELSALVADOR_CALLING_CODE, country.CallingCode); + + AssertCorrectInformation( + country, + ExpectedId, + ELSALVADOR_NAME, + ELSALVADOR_OFFICIAL_NAME, + ELSALVADOR_NATIVE_NAME, + ELSALVADOR_CAPITAL, + ELSALVADOR_NUMERIC_CODE, + ELSALVADOR_ISO2_CODE, + ELSALVADOR_ISO3_CODE, + ELSALVADOR_CALLING_CODE, + ExpectedStates + ); } } } diff --git a/src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs b/src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs index 5124266..22d1ce7 100644 --- a/src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs +++ b/src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs @@ -1,9 +1,8 @@ namespace World.Net.UnitTests.Countries { - public class EquatorialGuineaTest + public class EquatorialGuineaTest : AssertCountryTestBase { private const string EQUATORIALGUINEA_NAME = "EquatorialGuinea"; - private const int EQUATORIALGUINEA_STATE_COUNT = 8; private const string EQUATORIALGUINEA_OFFICIAL_NAME = "Republic of Equatorial Guinea"; private const string EQUATORIALGUINEA_NATIVE_NAME = "República de Guinea Ecuatorial"; private const string EQUATORIALGUINEA_CAPITAL = "Malabo"; @@ -11,30 +10,40 @@ public class EquatorialGuineaTest private const string EQUATORIALGUINEA_ISO2_CODE = "GQ"; private const string EQUATORIALGUINEA_ISO3_CODE = "GNQ"; private readonly string[] EQUATORIALGUINEA_CALLING_CODE = ["240"]; - private static readonly string[] VALID_STATE_TYPES = { "Province" }; + private static CountryIdentifier ExpectedId => CountryIdentifier.EquatorialGuinea; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + { + new("Annobón", "AN", "Province"), + new("Bioko Norte", "BN", "Province"), + new("Bioko Sur", "BS", "Province"), + new("Centro Sur", "CS", "Province"), + new("Djibloho", "DJ", "Province"), + new("Kié-Ntem", "KN", "Province"), + new("Litoral", "LI", "Province"), + new("Wele-Nzas", "WN", "Province") + }; [Fact] public void GetCountry_ReturnsCorrectInformation_ForEquatorialGuinea() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.EquatorialGuinea; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(EQUATORIALGUINEA_NAME, country.Name); - Assert.NotNull(country.States); - Assert.Equal(EQUATORIALGUINEA_STATE_COUNT, country.States.Count()); - Assert.Equal(EQUATORIALGUINEA_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(EQUATORIALGUINEA_NATIVE_NAME, country.NativeName); - Assert.Equal(EQUATORIALGUINEA_CAPITAL, country.Capital); - Assert.Equal(EQUATORIALGUINEA_NUMERIC_CODE, country.NumericCode); - Assert.Equal(EQUATORIALGUINEA_ISO2_CODE, country.ISO2Code); - Assert.Equal(EQUATORIALGUINEA_ISO3_CODE, country.ISO3Code); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); - Assert.Equal(EQUATORIALGUINEA_CALLING_CODE, country.CallingCode); + AssertCorrectInformation( + country, + ExpectedId, + EQUATORIALGUINEA_NAME, + EQUATORIALGUINEA_OFFICIAL_NAME, + EQUATORIALGUINEA_NATIVE_NAME, + EQUATORIALGUINEA_CAPITAL, + EQUATORIALGUINEA_NUMERIC_CODE, + EQUATORIALGUINEA_ISO2_CODE, + EQUATORIALGUINEA_ISO3_CODE, + EQUATORIALGUINEA_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/EritreaTest.cs b/src/World.Net.UnitTests/Countries/EritreaTest.cs index f551075..881ff2b 100644 --- a/src/World.Net.UnitTests/Countries/EritreaTest.cs +++ b/src/World.Net.UnitTests/Countries/EritreaTest.cs @@ -6,7 +6,7 @@ namespace World.Net.UnitTests.Countries { - public class EritreaTest + public class EritreaTest : AssertCountryTestBase { private const string ERITREA_NAME = "Eritrea"; private const int ERITREA_STATE_COUNT = 6; @@ -18,29 +18,38 @@ public class EritreaTest private const string ERITREA_ISO3_CODE = "ERI"; private readonly string[] ERITREA_CALLING_CODE = ["291"]; private static readonly string[] VALID_STATE_TYPES = { "Region" }; + private static CountryIdentifier ExpectedId => CountryIdentifier.Eritrea; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + { + new("Anseba", "AN", "Region"), + new("Debub", "DU", "Region"), + new("Debubawi Keyih Bahri", "DK", "Region"), + new("Gash-Barka", "GB", "Region"), + new("Maekel", "MA", "Region"), + new("Semenawi Keyih Bahri", "SK", "Region") + }; [Fact] public void GetCountry_ReturnsCorrectInformation_ForEritrea() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Eritrea; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(ERITREA_NAME, country.Name); - Assert.NotNull(country.States); - Assert.Equal(ERITREA_STATE_COUNT, country.States.Count()); - Assert.Equal(ERITREA_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(ERITREA_NATIVE_NAME, country.NativeName); - Assert.Equal(ERITREA_CAPITAL, country.Capital); - Assert.Equal(ERITREA_NUMERIC_CODE, country.NumericCode); - Assert.Equal(ERITREA_ISO2_CODE, country.ISO2Code); - Assert.Equal(ERITREA_ISO3_CODE, country.ISO3Code); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); - Assert.Equal(ERITREA_CALLING_CODE, country.CallingCode); + AssertCorrectInformation( + country, + ExpectedId, + ERITREA_NAME, + ERITREA_OFFICIAL_NAME, + ERITREA_NATIVE_NAME, + ERITREA_CAPITAL, + ERITREA_NUMERIC_CODE, + ERITREA_ISO2_CODE, + ERITREA_ISO3_CODE, + ERITREA_CALLING_CODE, + ExpectedStates + ); } } } diff --git a/src/World.Net.UnitTests/Countries/EstoniaTest.cs b/src/World.Net.UnitTests/Countries/EstoniaTest.cs index e9a235d..fd5f125 100644 --- a/src/World.Net.UnitTests/Countries/EstoniaTest.cs +++ b/src/World.Net.UnitTests/Countries/EstoniaTest.cs @@ -1,6 +1,6 @@ namespace World.Net.UnitTests.Countries { - public sealed class EstoniaTest + public sealed class EstoniaTest : AssertCountryTestBase { private const string ESTONIA_NAME = "Estonia"; private const int ESTONIA_STATE_COUNT = 15; @@ -11,30 +11,47 @@ public sealed class EstoniaTest private const string ESTONIA_ISO2_CODE = "EE"; private const string ESTONIA_ISO3_CODE = "EST"; private readonly string[] ESTONIA_CALLING_CODE = ["372"]; - private static readonly string[] VALID_STATE_TYPES = { "County" }; + private static CountryIdentifier ExpectedId => CountryIdentifier.Estonia; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + { + new("Harju", "37", "County"), + new("Hiiu", "39", "County"), + new("Ida-Viru", "44", "County"), + new("Jõgeva", "49", "County"), + new("Järva", "51", "County"), + new("Lääne", "57", "County"), + new("Lääne-Viru", "59", "County"), + new("Põlva", "65", "County"), + new("Pärnu", "67", "County"), + new("Rapla", "70", "County"), + new("Saare", "74", "County"), + new("Tartu", "78", "County"), + new("Valga", "82", "County"), + new("Viljandi", "84", "County"), + new("Võru", "86", "County") + }; [Fact] public void GetCountry_ReturnsCorrectInformation_ForEstonia() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Estonia; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(ESTONIA_NAME, country.Name); - Assert.NotNull(country.States); - Assert.Equal(ESTONIA_STATE_COUNT, country.States.Count()); - Assert.Equal(ESTONIA_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(ESTONIA_NATIVE_NAME, country.NativeName); - Assert.Equal(ESTONIA_CAPITAL, country.Capital); - Assert.Equal(ESTONIA_NUMERIC_CODE, country.NumericCode); - Assert.Equal(ESTONIA_ISO2_CODE, country.ISO2Code); - Assert.Equal(ESTONIA_ISO3_CODE, country.ISO3Code); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); - Assert.Equal(ESTONIA_CALLING_CODE, country.CallingCode); + AssertCorrectInformation( + country, + ExpectedId, + ESTONIA_NAME, + ESTONIA_OFFICIAL_NAME, + ESTONIA_NATIVE_NAME, + ESTONIA_CAPITAL, + ESTONIA_NUMERIC_CODE, + ESTONIA_ISO2_CODE, + ESTONIA_ISO3_CODE, + ESTONIA_CALLING_CODE, + ExpectedStates + ); } } } diff --git a/src/World.Net.UnitTests/Countries/EswatiniTest.cs b/src/World.Net.UnitTests/Countries/EswatiniTest.cs index 4ea9a4e..8c8478f 100644 --- a/src/World.Net.UnitTests/Countries/EswatiniTest.cs +++ b/src/World.Net.UnitTests/Countries/EswatiniTest.cs @@ -1,7 +1,8 @@ namespace World.Net.UnitTests.Countries { - public class EswatiniTest + public class EswatiniTest : AssertCountryTestBase { + private static CountryIdentifier ExpectedId => CountryIdentifier.Eswatini; private const string ESWATINI_NAME = "Eswatini"; private const int ESWATINI_STATE_COUNT = 4; private const string ESWATINI_OFFICIAL_NAME = "Kingdom of Eswatini"; @@ -11,30 +12,35 @@ public class EswatiniTest private const string ESWATINI_ISO2_CODE = "SZ"; private const string ESWATINI_ISO3_CODE = "SWZ"; private readonly string[] ESWATINI_CALLING_CODE = ["268"]; - private static readonly string[] VALID_STATE_TYPES = { "Region" }; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + { + new("Hhohho", "HH", "Region"), + new("Lubombo", "LU", "Region"), + new("Manzini", "MA", "Region"), + new("Shiselweni", "SH", "Region") + }; [Fact] public void GetCountry_ReturnsCorrectInformation_ForEswatini() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Eswatini; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(ESWATINI_NAME, country.Name); - Assert.NotNull(country.States); - Assert.Equal(ESWATINI_STATE_COUNT, country.States.Count()); - Assert.Equal(ESWATINI_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(ESWATINI_NATIVE_NAME, country.NativeName); - Assert.Equal(ESWATINI_CAPITAL, country.Capital); - Assert.Equal(ESWATINI_NUMERIC_CODE, country.NumericCode); - Assert.Equal(ESWATINI_ISO2_CODE, country.ISO2Code); - Assert.Equal(ESWATINI_ISO3_CODE, country.ISO3Code); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); - Assert.Equal(ESWATINI_CALLING_CODE, country.CallingCode); + AssertCorrectInformation( + country, + ExpectedId, + ESWATINI_NAME, + ESWATINI_OFFICIAL_NAME, + ESWATINI_NATIVE_NAME, + ESWATINI_CAPITAL, + ESWATINI_NUMERIC_CODE, + ESWATINI_ISO2_CODE, + ESWATINI_ISO3_CODE, + ESWATINI_CALLING_CODE, + ExpectedStates + ); } } } diff --git a/src/World.Net.UnitTests/Countries/EthiopiaTest.cs b/src/World.Net.UnitTests/Countries/EthiopiaTest.cs index 606a0e9..45b6fc1 100644 --- a/src/World.Net.UnitTests/Countries/EthiopiaTest.cs +++ b/src/World.Net.UnitTests/Countries/EthiopiaTest.cs @@ -1,9 +1,8 @@ namespace World.Net.UnitTests.Countries { - public sealed class EthiopiaTest + public sealed class EthiopiaTest : AssertCountryTestBase { private const string ETHIOPIA_NAME = "Ethiopia"; - private const int ETHIOPIA_STATE_COUNT = 12; private const string ETHIOPIA_OFFICIAL_NAME = "Federal Democratic Republic of Ethiopia"; private const string ETHIOPIA_NATIVE_NAME = "ኢትዮጵያ"; private const string ETHIOPIA_CAPITAL = "Addis Ababa"; @@ -11,30 +10,44 @@ public sealed class EthiopiaTest private const string ETHIOPIA_ISO2_CODE = "ET"; private const string ETHIOPIA_ISO3_CODE = "ETH"; private readonly string[] ETHIOPIA_CALLING_CODE = ["251"]; - private static readonly string[] VALID_STATE_TYPES = { "Region", "Administration" }; + private static CountryIdentifier ExpectedId => CountryIdentifier.Ethiopia; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + { + new("Addis Ababa", "AA", "Administration"), + new("Afar", "AF", "Region"), + new("Amhara", "AM", "Region"), + new("Benishangul-Gumuz", "BE", "Region"), + new("Dire Dawa", "DD", "Administration"), + new("Gambela", "GA", "Region"), + new("Harari", "HA", "Region"), + new("Oromia", "OR", "Region"), + new("Sidama", "SI", "Region"), + new("Somali", "SO", "Region"), + new("Southern Nations, Nationalities, and Peoples' Region", "SN", "Region"), + new("Tigray", "TI", "Region") + }; [Fact] public void GetCountry_ReturnsCorrectInformation_ForEthiopia() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Ethiopia; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(ETHIOPIA_NAME, country.Name); - Assert.NotNull(country.States); - Assert.Equal(ETHIOPIA_STATE_COUNT, country.States.Count()); - Assert.Equal(ETHIOPIA_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(ETHIOPIA_NATIVE_NAME, country.NativeName); - Assert.Equal(ETHIOPIA_CAPITAL, country.Capital); - Assert.Equal(ETHIOPIA_NUMERIC_CODE, country.NumericCode); - Assert.Equal(ETHIOPIA_ISO2_CODE, country.ISO2Code); - Assert.Equal(ETHIOPIA_ISO3_CODE, country.ISO3Code); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); - Assert.Equal(ETHIOPIA_CALLING_CODE, country.CallingCode); + AssertCorrectInformation( + country, + ExpectedId, + ETHIOPIA_NAME, + ETHIOPIA_OFFICIAL_NAME, + ETHIOPIA_NATIVE_NAME, + ETHIOPIA_CAPITAL, + ETHIOPIA_NUMERIC_CODE, + ETHIOPIA_ISO2_CODE, + ETHIOPIA_ISO3_CODE, + ETHIOPIA_CALLING_CODE, + ExpectedStates + ); } } } diff --git a/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs b/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs index c8c8d7d..541d84a 100644 --- a/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs +++ b/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs @@ -1,13 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace World.Net.UnitTests.Countries { - public sealed class FalklandIslandsTest + public sealed class FalklandIslandsTest : AssertCountryTestBase { + private static CountryIdentifier Id => CountryIdentifier.FalklandIslands; private const string FALKLANDS_NAME = "FalklandIslands"; private const string FALKLANDS_OFFICIAL_NAME = "Falkland Islands"; private const string FALKLANDS_NATIVE_NAME = "Falkland Islands"; @@ -16,30 +19,32 @@ public sealed class FalklandIslandsTest private const string FALKLANDS_ISO2_CODE = "FK"; private const string FALKLANDS_ISO3_CODE = "FLK"; private readonly string[] FALKLANDS_CALLING_CODE = ["500"]; - private static readonly string[] VALID_STATE_TYPES = { "Overseas Territory" }; + private static readonly (string Name, string IsoCode, string Type)[] States = + [ + new("Falkland Islands", "FK", "Overseas Territory") + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForFalklandIslands() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.FalklandIslands; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(Id); // Assert - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(FALKLANDS_NAME, country.Name); - Assert.NotNull(country.States); - Assert.Single(country.States); - Assert.Equal(FALKLANDS_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(FALKLANDS_NATIVE_NAME, country.NativeName); - Assert.Equal(FALKLANDS_CAPITAL, country.Capital); - Assert.Equal(FALKLANDS_NUMERIC_CODE, country.NumericCode); - Assert.Equal(FALKLANDS_ISO2_CODE, country.ISO2Code); - Assert.Equal(FALKLANDS_ISO3_CODE, country.ISO3Code); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); - Assert.Equal(FALKLANDS_CALLING_CODE, country.CallingCode); + AssertCorrectInformation( + country, + Id, + FALKLANDS_NAME, + FALKLANDS_OFFICIAL_NAME, + FALKLANDS_NATIVE_NAME, + FALKLANDS_CAPITAL, + FALKLANDS_NUMERIC_CODE, + FALKLANDS_ISO2_CODE, + FALKLANDS_ISO3_CODE, + FALKLANDS_CALLING_CODE, + States + ); } } } diff --git a/src/World.Net.UnitTests/Countries/IraqTest.cs b/src/World.Net.UnitTests/Countries/IraqTest.cs index 33431f9..5401f37 100644 --- a/src/World.Net.UnitTests/Countries/IraqTest.cs +++ b/src/World.Net.UnitTests/Countries/IraqTest.cs @@ -1,5 +1,5 @@ namespace World.Net.UnitTests.Countries; -public sealed class IraqTest +public sealed class IraqTest : AssertCountryTestBase { private const string IRAQ_COUNTRY_NAME = "Iraq"; private const string IRAQ_NATIVE_NAME = "العراق"; @@ -9,32 +9,51 @@ public sealed class IraqTest private const string IRAQ_ISO3_CODE = "IRQ"; private const int IRAQ_NUMERIC_CODE = 368; private readonly string[] IRAQ_CALLING_CODE = ["+964"]; - private const int IRAQ_STATE_COUNT = 18; - private static readonly string[] VALID_STATE_TYPES = { "Governorate" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Iraq; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Al Anbar", "IQ-AN", "Governorate"), + ("Al Muthanna", "IQ-MU", "Governorate"), + ("Al-Qādisiyyah", "IQ-QA", "Governorate"), + ("Babylon", "IQ-BB", "Governorate"), + ("Baghdad", "IQ-BG", "Governorate"), + ("Basra", "IQ-BA", "Governorate"), + ("Dhi Qar", "IQ-DQ", "Governorate"), + ("Diyala", "IQ-DI", "Governorate"), + ("Dohuk", "IQ-DA", "Governorate"), + ("Erbil", "IQ-AR", "Governorate"), + ("Karbala", "IQ-KA", "Governorate"), + ("Kirkuk", "IQ-KI", "Governorate"), + ("Maysan", "IQ-MA", "Governorate"), + ("Najaf", "IQ-NA", "Governorate"), + ("Nineveh", "IQ-NI", "Governorate"), + ("Saladin", "IQ-SD", "Governorate"), + ("Sulaymaniyah", "IQ-SU", "Governorate"), + ("Wasit", "IQ-WA", "Governorate") + + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForIraq() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Iraq; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(IRAQ_COUNTRY_NAME, country.Name); - Assert.Equal(IRAQ_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(IRAQ_NATIVE_NAME, country.NativeName); - Assert.Equal(IRAQ_CAPITAL, country.Capital); - Assert.Equal(IRAQ_NUMERIC_CODE, country.NumericCode); - Assert.Equal(IRAQ_ISO2_CODE, country.ISO2Code); - Assert.Equal(IRAQ_ISO3_CODE, country.ISO3Code); - Assert.Equal(IRAQ_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(IRAQ_STATE_COUNT, country.States.Count()); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + AssertCorrectInformation( + country, + ExpectedId, + IRAQ_COUNTRY_NAME, + IRAQ_OFFICIAL_NAME, + IRAQ_NATIVE_NAME, + IRAQ_CAPITAL, + IRAQ_NUMERIC_CODE, + IRAQ_ISO2_CODE, + IRAQ_ISO3_CODE, + IRAQ_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/IrelandTest.cs b/src/World.Net.UnitTests/Countries/IrelandTest.cs index f2c387c..66f5dc4 100644 --- a/src/World.Net.UnitTests/Countries/IrelandTest.cs +++ b/src/World.Net.UnitTests/Countries/IrelandTest.cs @@ -1,5 +1,5 @@ namespace World.Net.UnitTests.Countries; -public sealed class IrelandTest +public sealed class IrelandTest : AssertCountryTestBase { private const string IRELAND_COUNTRY_NAME = "Ireland"; private const string IRELAND_NATIVE_NAME = "Éire"; @@ -9,31 +9,61 @@ public sealed class IrelandTest private const string IRELAND_ISO3_CODE = "IRL"; private const int IRELAND_NUMERIC_CODE = 372; private readonly string[] IRELAND_CALLING_CODE = ["+353"]; - private const int IRELAND_STATE_COUNT = 30; - private static readonly string[] VALID_STATE_TYPES = { "County", "Province" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Ireland; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Carlow", "IE-CW", "County"), + ("Cavan", "IE-CN", "County"), + ("Clare", "IE-CE", "County"), + ("Connacht", "IE-C", "Province"), + ("Cork", "IE-CO", "County"), + ("Donegal", "IE-DL", "County"), + ("Dublin", "IE-D", "County"), + ("Galway", "IE-G", "County"), + ("Kerry", "IE-KY", "County"), + ("Kildare", "IE-KE", "County"), + ("Kilkenny", "IE-KK", "County"), + ("Laois", "IE-LS", "County"), + ("Leinster", "IE-L", "Province"), + ("Leitrim", "IE-LM", "County"), + ("Limerick", "IE-LK", "County"), + ("Longford", "IE-LD", "County"), + ("Louth", "IE-LH", "County"), + ("Mayo", "IE-MO", "County"), + ("Meath", "IE-MH", "County"), + ("Monaghan", "IE-MN", "County"), + ("Munster", "IE-M", "Province"), + ("Offaly", "IE-OY", "County"), + ("Roscommon", "IE-RN", "County"), + ("Sligo", "IE-SO", "County"), + ("Tipperary", "IE-TA", "County"), + ("Ulster", "IE-U", "Province"), + ("Waterford", "IE-WD", "County"), + ("Westmeath", "IE-WH", "County"), + ("Wexford", "IE-WX", "County"), + ("Wicklow", "IE-WW", "County") + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForIreland() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Ireland; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(IRELAND_COUNTRY_NAME, country.Name); - Assert.Equal(IRELAND_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(IRELAND_NATIVE_NAME, country.NativeName); - Assert.Equal(IRELAND_CAPITAL, country.Capital); - Assert.Equal(IRELAND_NUMERIC_CODE, country.NumericCode); - Assert.Equal(IRELAND_ISO2_CODE, country.ISO2Code); - Assert.Equal(IRELAND_ISO3_CODE, country.ISO3Code); - Assert.Equal(IRELAND_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(IRELAND_STATE_COUNT, country.States.Count()); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + AssertCorrectInformation( + country, + ExpectedId, + IRELAND_COUNTRY_NAME, + IRELAND_OFFICIAL_NAME, + IRELAND_NATIVE_NAME, + IRELAND_CAPITAL, + IRELAND_NUMERIC_CODE, + IRELAND_ISO2_CODE, + IRELAND_ISO3_CODE, + IRELAND_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/IsraelTest.cs b/src/World.Net.UnitTests/Countries/IsraelTest.cs index 357b86a..e5da90e 100644 --- a/src/World.Net.UnitTests/Countries/IsraelTest.cs +++ b/src/World.Net.UnitTests/Countries/IsraelTest.cs @@ -1,5 +1,5 @@ namespace World.Net.UnitTests.Countries; -public sealed class IsraelTest +public sealed class IsraelTest : AssertCountryTestBase { private const string ISRAEL_COUNTRY_NAME = "Israel"; private const string ISRAEL_NATIVE_NAME = "יִשְׂרָאֵל"; @@ -9,31 +9,37 @@ public sealed class IsraelTest private const string ISRAEL_ISO3_CODE = "ISR"; private const int ISRAEL_NUMERIC_CODE = 376; private readonly string[] ISRAEL_CALLING_CODE = ["+972"]; - private const int ISRAEL_STATE_COUNT = 6; - private static readonly string[] VALID_STATE_TYPES = { "District" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Israel; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Central", "IL-M", "District"), + ("Haifa", "IL-HA", "District"), + ("Jerusalem", "IL-JM", "District"), + ("Northern", "IL-Z", "District"), + ("Southern", "IL-D", "District"), + ("Tel Aviv", "IL-TA", "District") + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForIsrael() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Israel; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(ISRAEL_COUNTRY_NAME, country.Name); - Assert.Equal(ISRAEL_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(ISRAEL_NATIVE_NAME, country.NativeName); - Assert.Equal(ISRAEL_CAPITAL, country.Capital); - Assert.Equal(ISRAEL_NUMERIC_CODE, country.NumericCode); - Assert.Equal(ISRAEL_ISO2_CODE, country.ISO2Code); - Assert.Equal(ISRAEL_ISO3_CODE, country.ISO3Code); - Assert.Equal(ISRAEL_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(ISRAEL_STATE_COUNT, country.States.Count()); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + AssertCorrectInformation( + country, + ExpectedId, + ISRAEL_COUNTRY_NAME, + ISRAEL_OFFICIAL_NAME, + ISRAEL_NATIVE_NAME, + ISRAEL_CAPITAL, + ISRAEL_NUMERIC_CODE, + ISRAEL_ISO2_CODE, + ISRAEL_ISO3_CODE, + ISRAEL_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/ItalyTest.cs b/src/World.Net.UnitTests/Countries/ItalyTest.cs index d2fd3fa..9c9253d 100644 --- a/src/World.Net.UnitTests/Countries/ItalyTest.cs +++ b/src/World.Net.UnitTests/Countries/ItalyTest.cs @@ -1,5 +1,5 @@ namespace World.Net.UnitTests.Countries; -public sealed class ItalyTest +public sealed class ItalyTest : AssertCountryTestBase { private const string ITALY_COUNTRY_NAME = "Italy"; private const string ITALY_NATIVE_NAME = "Italia"; @@ -9,31 +9,142 @@ public sealed class ItalyTest private const string ITALY_ISO3_CODE = "ITA"; private const int ITALY_NUMERIC_CODE = 380; private readonly string[] ITALY_CALLING_CODE = ["+39"]; - private const int ITALY_STATE_COUNT = 111; - private static readonly string[] VALID_STATE_TYPES = { "Decentralized Regional Entity", "Metropolitan City", "Autonomous Region", "Free Municipal Consortium", "Province", "Region", }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Italy; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Abruzzo", "IT-65", "Region"), + ("Agrigento", "IT-AG", "Free Municipal Consortium"), + ("Alessandria", "IT-AL", "Province"), + ("Ancona", "IT-AN", "Province"), + ("Aosta Valley", "IT-23", "Autonomous Region"), + ("Apulia", "IT-75", "Region"), + ("Arezzo", "IT-AR", "Province"), + ("Ascoli Piceno", "IT-AP", "Province"), + ("Asti", "IT-AT", "Province"), + ("Avellino", "IT-AV", "Province"), + ("Barletta-Andria-Trani", "IT-BT", "Province"), + ("Basilicata", "IT-77", "Region"), + ("Belluno", "IT-BL", "Province"), + ("Benevento", "IT-BN", "Province"), + ("Bergamo", "IT-BG", "Province"), + ("Biella", "IT-BI", "Province"), + ("Brescia", "IT-BS", "Province"), + ("Brindisi", "IT-BR", "Province"), + ("Calabria", "IT-78", "Region"), + ("Caltanissetta", "IT-CL", "Free Municipal Consortium"), + ("Campania", "IT-72", "Region"), + ("Campobasso", "IT-CB", "Province"), + ("Caserta", "IT-CE", "Province"), + ("Catanzaro", "IT-CZ", "Province"), + ("Chieti", "IT-CH", "Province"), + ("Como", "IT-CO", "Province"), + ("Cosenza", "IT-CS", "Province"), + ("Cremona", "IT-CR", "Province"), + ("Crotone", "IT-KR", "Province"), + ("Cuneo", "IT-CN", "Province"), + ("Emilia-Romagna", "IT-45", "Region"), + ("Enna", "IT-EN", "Free Municipal Consortium"), + ("Fermo", "IT-FM", "Province"), + ("Ferrara", "IT-FE", "Province"), + ("Foggia", "IT-FG", "Province"), + ("Forlì-Cesena", "IT-FC", "Province"), + ("Friuli–Venezia Giulia", "IT-36", "Autonomous Region"), + ("Frosinone", "IT-FR", "Province"), + ("Gorizia", "IT-GO", "Decentralized Regional Entity"), + ("Grosseto", "IT-GR", "Province"), + ("Imperia", "IT-IM", "Province"), + ("Isernia", "IT-IS", "Province"), + ("L'Aquila", "IT-AQ", "Province"), + ("La Spezia", "IT-SP", "Province"), + ("Latina", "IT-LT", "Province"), + ("Lazio", "IT-62", "Region"), + ("Lecce", "IT-LE", "Province"), + ("Lecco", "IT-LC", "Province"), + ("Liguria", "IT-42", "Region"), + ("Livorno", "IT-LI", "Province"), + ("Lodi", "IT-LO", "Province"), + ("Lombardy", "IT-25", "Region"), + ("Lucca", "IT-LU", "Province"), + ("Macerata", "IT-MC", "Province"), + ("Mantua", "IT-MN", "Province"), + ("Marche", "IT-57", "Region"), + ("Massa and Carrara", "IT-MS", "Province"), + ("Matera", "IT-MT", "Province"), + ("Modena", "IT-MO", "Province"), + ("Molise", "IT-67", "Region"), + ("Monza and Brianza", "IT-MB", "Province"), + ("Novara", "IT-NO", "Province"), + ("Nuoro", "IT-NU", "Province"), + ("Oristano", "IT-OR", "Province"), + ("Padua", "IT-PD", "Province"), + ("Palermo", "IT-PA", "Metropolitan City"), + ("Parma", "IT-PR", "Province"), + ("Pavia", "IT-PV", "Province"), + ("Perugia", "IT-PG", "Province"), + ("Pesaro and Urbino", "IT-PU", "Province"), + ("Pescara", "IT-PE", "Province"), + ("Piacenza", "IT-PC", "Province"), + ("Piedmont", "IT-21", "Region"), + ("Pisa", "IT-PI", "Province"), + ("Pistoia", "IT-PT", "Province"), + ("Pordenone", "IT-PN", "Decentralized Regional Entity"), + ("Potenza", "IT-PZ", "Province"), + ("Prato", "IT-PO", "Province"), + ("Ragusa", "IT-RG", "Free Municipal Consortium"), + ("Ravenna", "IT-RA", "Province"), + ("Reggio Emilia", "IT-RE", "Province"), + ("Rieti", "IT-RI", "Province"), + ("Rimini", "IT-RN", "Province"), + ("Rovigo", "IT-RO", "Province"), + ("Salerno", "IT-SA", "Province"), + ("Sardinia", "IT-88", "Autonomous Region"), + ("Sassari", "IT-SS", "Province"), + ("Savona", "IT-SV", "Province"), + ("Sicily", "IT-82", "Autonomous Region"), + ("Siena", "IT-SI", "Province"), + ("Siracusa", "IT-SR", "Free Municipal Consortium"), + ("Sondrio", "IT-SO", "Province"), + ("South Sardinia", "IT-SU", "Province"), + ("Taranto", "IT-TA", "Province"), + ("Teramo", "IT-TE", "Province"), + ("Terni", "IT-TR", "Province"), + ("Trapani", "IT-TP", "Free Municipal Consortium"), + ("Trentino-South Tyrol", "IT-32", "Autonomous Region"), + ("Treviso", "IT-TV", "Province"), + ("Trieste", "IT-TS", "Decentralized Regional Entity"), + ("Tuscany", "IT-52", "Region"), + ("Udine", "IT-UD", "Decentralized Regional Entity"), + ("Umbria", "IT-55", "Region"), + ("Varese", "IT VA", "Province"), + ("Veneto", "IT-34", "Region"), + ("Verbano-Cusio-Ossola", "IT-VB", "Province"), + ("Vercelli", "IT-VC", "Province"), + ("Verona", "IT-VR", "Province"), + ("Vibo Valentia", "IT-VV", "Province"), + ("Vicenza", "IT-VI", "Province"), + ("Viterbo", "IT-VT", "Province") + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForItaly() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Italy; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(ITALY_COUNTRY_NAME, country.Name); - Assert.Equal(ITALY_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(ITALY_NATIVE_NAME, country.NativeName); - Assert.Equal(ITALY_CAPITAL, country.Capital); - Assert.Equal(ITALY_NUMERIC_CODE, country.NumericCode); - Assert.Equal(ITALY_ISO2_CODE, country.ISO2Code); - Assert.Equal(ITALY_ISO3_CODE, country.ISO3Code); - Assert.Equal(ITALY_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(ITALY_STATE_COUNT, country.States.Count()); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + AssertCorrectInformation( + country, + ExpectedId, + ITALY_COUNTRY_NAME, + ITALY_OFFICIAL_NAME, + ITALY_NATIVE_NAME, + ITALY_CAPITAL, + ITALY_NUMERIC_CODE, + ITALY_ISO2_CODE, + ITALY_ISO3_CODE, + ITALY_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/JamaicaTest.cs b/src/World.Net.UnitTests/Countries/JamaicaTest.cs index 67439db..60a1225 100644 --- a/src/World.Net.UnitTests/Countries/JamaicaTest.cs +++ b/src/World.Net.UnitTests/Countries/JamaicaTest.cs @@ -1,5 +1,5 @@ namespace World.Net.UnitTests.Countries; -public sealed class JamaicaTest +public sealed class JamaicaTest : AssertCountryTestBase { private const string JAMAICA_COUNTRY_NAME = "Jamaica"; private const string JAMAICA_NATIVE_NAME = "Jamaica"; @@ -9,31 +9,45 @@ public sealed class JamaicaTest private const string JAMAICA_ISO3_CODE = "JAM"; private const int JAMAICA_NUMERIC_CODE = 388; private readonly string[] JAMAICA_CALLING_CODE = ["+1-876"]; - private const int JAMAICA_STATE_COUNT = 14; - private static readonly string[] VALID_STATE_TYPES = { "Parish" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Jamaica; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Clarendon", "JM-13", "Parish"), + ("Hanover", "JM-09", "Parish"), + ("Kingston", "JM-01", "Parish"), + ("Manchester", "JM-12", "Parish"), + ("Portland", "JM-04", "Parish"), + ("Saint Andrew", "JM-02", "Parish"), + ("Saint Ann", "JM-06", "Parish"), + ("Saint Catherine", "JM-14", "Parish"), + ("Saint Elizabeth", "JM-11", "Parish"), + ("Saint James", "JM-08", "Parish"), + ("Saint Mary", "JM-05", "Parish"), + ("Saint Thomas", "JM-03", "Parish"), + ("Trelawny", "JM-07", "Parish"), + ("Westmoreland", "JM-10", "Parish"), + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForJamaica() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Jamaica; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(JAMAICA_COUNTRY_NAME, country.Name); - Assert.Equal(JAMAICA_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(JAMAICA_NATIVE_NAME, country.NativeName); - Assert.Equal(JAMAICA_CAPITAL, country.Capital); - Assert.Equal(JAMAICA_NUMERIC_CODE, country.NumericCode); - Assert.Equal(JAMAICA_ISO2_CODE, country.ISO2Code); - Assert.Equal(JAMAICA_ISO3_CODE, country.ISO3Code); - Assert.Equal(JAMAICA_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(JAMAICA_STATE_COUNT, country.States.Count()); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + AssertCorrectInformation( + country, + ExpectedId, + JAMAICA_COUNTRY_NAME, + JAMAICA_OFFICIAL_NAME, + JAMAICA_NATIVE_NAME, + JAMAICA_CAPITAL, + JAMAICA_NUMERIC_CODE, + JAMAICA_ISO2_CODE, + JAMAICA_ISO3_CODE, + JAMAICA_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/JapanTest.cs b/src/World.Net.UnitTests/Countries/JapanTest.cs index ef974b9..e4c0186 100644 --- a/src/World.Net.UnitTests/Countries/JapanTest.cs +++ b/src/World.Net.UnitTests/Countries/JapanTest.cs @@ -1,5 +1,5 @@ namespace World.Net.UnitTests.Countries; -public sealed class JapanTest +public sealed class JapanTest : AssertCountryTestBase { private const string JAPAN_COUNTRY_NAME = "Japan"; private const string JAPAN_NATIVE_NAME = "日本"; @@ -9,31 +9,82 @@ public sealed class JapanTest private const string JAPAN_ISO3_CODE = "JPN"; private const int JAPAN_NUMERIC_CODE = 392; private readonly string[] JAPAN_CALLING_CODE = ["+81"]; - private const int JAPAN_STATE_COUNT = 47; private static readonly string[] VALID_STATE_TYPES = { "Prefecture" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Japan; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Aichi", "JP-23", "Prefecture"), + ("Akita", "JP-05", "Prefecture"), + ("Aomori", "JP-02", "Prefecture"), + ("Chiba", "JP-12", "Prefecture"), + ("Ehime", "JP-38", "Prefecture"), + ("Fukui", "JP-18", "Prefecture"), + ("Fukuoka", "JP-40", "Prefecture"), + ("Fukushima", "JP-07", "Prefecture"), + ("Gifu", "JP-21", "Prefecture"), + ("Gunma", "JP-10", "Prefecture"), + ("Hiroshima", "JP-34", "Prefecture"), + ("Hokkaidō", "JP-01", "Prefecture"), + ("Hyōgo", "JP-28", "Prefecture"), + ("Ibaraki", "JP-08", "Prefecture"), + ("Ishikawa", "JP-17", "Prefecture"), + ("Iwate", "JP-03", "Prefecture"), + ("Kagawa", "JP-37", "Prefecture"), + ("Kagoshima", "JP-46", "Prefecture"), + ("Kanagawa", "JP-14", "Prefecture"), + ("Kōchi", "JP-39", "Prefecture"), + ("Kumamoto", "JP-43", "Prefecture"), + ("Kyōto", "JP-26", "Prefecture"), + ("Mie", "JP-24", "Prefecture"), + ("Miyagi", "JP-04", "Prefecture"), + ("Miyazaki", "JP-45", "Prefecture"), + ("Nagano", "JP-20", "Prefecture"), + ("Nagasaki", "JP-42", "Prefecture"), + ("Nara", "JP-29", "Prefecture"), + ("Niigata", "JP-15", "Prefecture"), + ("Ōita", "JP-44", "Prefecture"), + ("Okayama", "JP-33", "Prefecture"), + ("Okinawa", "JP-47", "Prefecture"), + ("Ōsaka", "JP-27", "Prefecture"), + ("Saga", "JP-41", "Prefecture"), + ("Saitama", "JP-11", "Prefecture"), + ("Shiga", "JP-25", "Prefecture"), + ("Shimane", "JP-32", "Prefecture"), + ("Shizuoka", "JP-22", "Prefecture"), + ("Tochigi", "JP-09", "Prefecture"), + ("Tokushima", "JP-36", "Prefecture"), + ("Tokyo", "JP-13", "Prefecture"), + ("Tottori", "JP-31", "Prefecture"), + ("Toyama", "JP-16", "Prefecture"), + ("Wakayama", "JP-30", "Prefecture"), + ("Yamagata", "JP-06", "Prefecture"), + ("Yamaguchi", "JP-35", "Prefecture"), + ("Yamanashi", "JP-19", "Prefecture") + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForJapan() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Japan; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(JAPAN_COUNTRY_NAME, country.Name); - Assert.Equal(JAPAN_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(JAPAN_NATIVE_NAME, country.NativeName); - Assert.Equal(JAPAN_CAPITAL, country.Capital); - Assert.Equal(JAPAN_NUMERIC_CODE, country.NumericCode); - Assert.Equal(JAPAN_ISO2_CODE, country.ISO2Code); - Assert.Equal(JAPAN_ISO3_CODE, country.ISO3Code); - Assert.Equal(JAPAN_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(JAPAN_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + + AssertCorrectInformation( + country, + ExpectedId, + JAPAN_COUNTRY_NAME, + JAPAN_OFFICIAL_NAME, + JAPAN_NATIVE_NAME, + JAPAN_CAPITAL, + JAPAN_NUMERIC_CODE, + JAPAN_ISO2_CODE, + JAPAN_ISO3_CODE, + JAPAN_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/JerseyTest.cs b/src/World.Net.UnitTests/Countries/JerseyTest.cs index fad36bd..9b28266 100644 --- a/src/World.Net.UnitTests/Countries/JerseyTest.cs +++ b/src/World.Net.UnitTests/Countries/JerseyTest.cs @@ -1,5 +1,5 @@ namespace World.Net.UnitTests.Countries; -public sealed class JerseyTest +public sealed class JerseyTest : AssertCountryTestBase { private const string JERSEY_COUNTRY_NAME = "Jersey"; private const string JERSEY_NATIVE_NAME = "Jersey"; @@ -9,31 +9,46 @@ public sealed class JerseyTest private const string JERSEY_ISO3_CODE = "JEY"; private const int JERSEY_NUMERIC_CODE = 832; private readonly string[] JERSEY_CALLING_CODE = ["+44"]; - private const int JERSEY_STATE_COUNT = 12; private static readonly string[] VALID_STATE_TYPES = { "parish" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Jersey; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Grouville", "JE-01", "parish"), + ("St Brelade", "JE-02", "parish"), + ("St Clement", "JE-03", "parish"), + ("St Helier", "JE-04", "parish"), + ("St John", "JE-05", "parish"), + ("St Lawrence", "JE-06", "parish"), + ("St Martin", "JE-07", "parish"), + ("St Mary", "JE-08", "parish"), + ("St Ouen", "JE-09", "parish"), + ("St Peter", "JE-10", "parish"), + ("St Saviour", "JE-11", "parish"), + ("Trinity", "JE-12", "parish"), + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForJersey() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Jersey; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(JERSEY_COUNTRY_NAME, country.Name); - Assert.Equal(JERSEY_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(JERSEY_NATIVE_NAME, country.NativeName); - Assert.Equal(JERSEY_CAPITAL, country.Capital); - Assert.Equal(JERSEY_NUMERIC_CODE, country.NumericCode); - Assert.Equal(JERSEY_ISO2_CODE, country.ISO2Code); - Assert.Equal(JERSEY_ISO3_CODE, country.ISO3Code); - Assert.Equal(JERSEY_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(JERSEY_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + + AssertCorrectInformation( + country, + ExpectedId, + JERSEY_COUNTRY_NAME, + JERSEY_OFFICIAL_NAME, + JERSEY_NATIVE_NAME, + JERSEY_CAPITAL, + JERSEY_NUMERIC_CODE, + JERSEY_ISO2_CODE, + JERSEY_ISO3_CODE, + JERSEY_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/JordanTest.cs b/src/World.Net.UnitTests/Countries/JordanTest.cs index 4c383d7..5ce8a10 100644 --- a/src/World.Net.UnitTests/Countries/JordanTest.cs +++ b/src/World.Net.UnitTests/Countries/JordanTest.cs @@ -1,5 +1,5 @@ namespace World.Net.UnitTests.Countries; -public sealed class JordanTest +public sealed class JordanTest : AssertCountryTestBase { private const string JORDAN_COUNTRY_NAME = "Jordan"; private const string JORDAN_NATIVE_NAME = "الأردن"; @@ -9,31 +9,48 @@ public sealed class JordanTest private const string JORDAN_ISO3_CODE = "JOR"; private const int JORDAN_NUMERIC_CODE = 400; private readonly string[] JORDAN_CALLING_CODE = ["+962"]; - private const int JORDAN_STATE_COUNT = 12; private static readonly string[] VALID_STATE_TYPES = { "governorate" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Jordan; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Ajloun", "JO-AJ", "governorate"), + ("Amman", "JO-AM", "governorate"), + ("Aqaba", "JO-AQ", "governorate"), + ("Balqa", "JO-BA", "governorate"), + ("Irbid", "JO-IR", "governorate"), + ("Jerash", "JO-JA", "governorate"), + ("Karak", "JO-KA", "governorate"), + ("Ma'an", "JO-MN", "governorate"), + ("Madaba", "JO-MD", "governorate"), + ("Mafraq", "JO-MA", "governorate"), + ("Tafilah", "JO-AT", "governorate"), + ("Zarqa", "JO-AZ", "governorate"), + ]; + [Fact] public void GetCountry_ReturnsCorrectInformation_ForJordan() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Jordan; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(JORDAN_COUNTRY_NAME, country.Name); - Assert.Equal(JORDAN_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(JORDAN_NATIVE_NAME, country.NativeName); - Assert.Equal(JORDAN_CAPITAL, country.Capital); - Assert.Equal(JORDAN_NUMERIC_CODE, country.NumericCode); - Assert.Equal(JORDAN_ISO2_CODE, country.ISO2Code); - Assert.Equal(JORDAN_ISO3_CODE, country.ISO3Code); - Assert.Equal(JORDAN_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(JORDAN_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + + AssertCorrectInformation( + country, + ExpectedId, + JORDAN_COUNTRY_NAME, + JORDAN_OFFICIAL_NAME, + JORDAN_NATIVE_NAME, + JORDAN_CAPITAL, + JORDAN_NUMERIC_CODE, + JORDAN_ISO2_CODE, + JORDAN_ISO3_CODE, + JORDAN_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/KazakhstanTest.cs b/src/World.Net.UnitTests/Countries/KazakhstanTest.cs index d498c7d..fd220af 100644 --- a/src/World.Net.UnitTests/Countries/KazakhstanTest.cs +++ b/src/World.Net.UnitTests/Countries/KazakhstanTest.cs @@ -1,47 +1,57 @@ namespace World.Net.UnitTests.Countries; -internal static class KazakhstanTestData +public sealed class KazakhstanTest : AssertCountryTestBase { - internal const string COUNTRY_NAME = "Kazakhstan"; - internal const string NATIVE_NAME = "?????????"; - internal const string CAPITAL = "Astana"; - internal const string OFFICIAL_NAME = "Republic of Kazakhstan"; - internal const string ISO2_CODE = "KZ"; - internal const string ISO3_CODE = "KAZ"; - internal const int NUMERIC_CODE = 398; - internal static readonly string[] CALLING_CODE = ["+7"]; - internal const string REGION_TYPE = "Region"; - internal const string CITY_TYPE = "City"; - internal const int EXPECTED_REGION_COUNT = 14; - internal const int EXPECTED_CITY_COUNT = 3; -} + private const CountryIdentifier ExpectedId = CountryIdentifier.Kazakhstan; + private const string ExpectedName = "Kazakhstan"; + private const string ExpectedOfficialName = "Republic of Kazakhstan"; + private const string ExpectedNativeName = "?????????"; + private const string ExpectedCapital = "Astana"; + private const int ExpectedNumericCode = 398; + private const string ExpectedISO2Code = "KZ"; + private const string ExpectedISO3Code = "KAZ"; + private static readonly string[] ExpectedCallingCode = ["+7"]; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Akmola", "KZ-AKM", "Region"), + ("Aktobe", "KZ-AKT", "Region"), + ("Almaty", "KZ-ALM", "Region"), + ("Atyrau", "KZ-ATY", "Region"), + ("East Kazakhstan", "KZ-VOS", "Region"), + ("Jambyl", "KZ-ZHA", "Region"), + ("Karaganda", "KZ-KAR", "Region"), + ("Kostanay", "KZ-KUS", "Region"), + ("Kyzylorda", "KZ-KZY", "Region"), + ("Mangystau", "KZ-MAN", "Region"), + ("Pavlodar", "KZ-PAV", "Region"), + ("North Kazakhstan", "KZ-SEV", "Region"), + ("Turkistan", "KZ-TUR", "Region"), + ("West Kazakhstan", "KZ-ZAP", "Region"), + ("Nur-Sultan", "KZ-NUR", "City"), + ("Almaty City", "KZ-ALA", "City"), + ("Shymkent", "KZ-SHY", "City") + ]; -public sealed class KazakhstanTest -{ [Fact] public void GetCountry_ReturnsCorrectInformation_ForKazakhstan() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Kazakhstan; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(KazakhstanTestData.COUNTRY_NAME, country.Name); - Assert.Equal(KazakhstanTestData.OFFICIAL_NAME, country.OfficialName); - Assert.Equal(KazakhstanTestData.NATIVE_NAME, country.NativeName); - Assert.Equal(KazakhstanTestData.CAPITAL, country.Capital); - Assert.Equal(KazakhstanTestData.NUMERIC_CODE, country.NumericCode); - Assert.Equal(KazakhstanTestData.ISO2_CODE, country.ISO2Code); - Assert.Equal(KazakhstanTestData.ISO3_CODE, country.ISO3Code); - Assert.Equal(KazakhstanTestData.CALLING_CODE, country.CallingCode); - - Assert.NotNull(country.States); - Assert.Equal(KazakhstanTestData.EXPECTED_REGION_COUNT + KazakhstanTestData.EXPECTED_CITY_COUNT, country.States.Count()); - Assert.Equal(KazakhstanTestData.EXPECTED_REGION_COUNT, country.States.Count(s => s.Type == KazakhstanTestData.REGION_TYPE)); - Assert.Equal(KazakhstanTestData.EXPECTED_CITY_COUNT, country.States.Count(s => s.Type == KazakhstanTestData.CITY_TYPE)); + AssertCorrectInformation( + country, + ExpectedId, + ExpectedName, + ExpectedOfficialName, + ExpectedNativeName, + ExpectedCapital, + ExpectedNumericCode, + ExpectedISO2Code, + ExpectedISO3Code, + ExpectedCallingCode, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/KenyaTest.cs b/src/World.Net.UnitTests/Countries/KenyaTest.cs index 1c537fd..aec83ff 100644 --- a/src/World.Net.UnitTests/Countries/KenyaTest.cs +++ b/src/World.Net.UnitTests/Countries/KenyaTest.cs @@ -3,7 +3,7 @@ namespace World.Net.UnitTests.Countries; -public sealed class KenyaTest +public sealed class KenyaTest : AssertCountryTestBase { private const string KENYA_COUNTRY_NAME = "Kenya"; private const string KENYA_NATIVE_NAME = "Kenya"; @@ -13,31 +13,82 @@ public sealed class KenyaTest private const string KENYA_ISO3_CODE = "KEN"; private const int KENYA_NUMERIC_CODE = 404; private readonly string[] KENYA_CALLING_CODE = ["+254"]; - private const int KENYA_STATE_COUNT = 47; private static readonly string[] VALID_STATE_TYPES = { "County" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Kenya; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Baringo", "KE-01", "County"), + ("Bomet", "KE-02", "County"), + ("Bungoma", "KE-03", "County"), + ("Busia", "KE-04", "County"), + ("Elgeyo-Marakwet", "KE-05", "County"), + ("Embu", "KE-06", "County"), + ("Garissa", "KE-07", "County"), + ("Homa Bay", "KE-08", "County"), + ("Isiolo", "KE-09", "County"), + ("Kajiado", "KE-10", "County"), + ("Kakamega", "KE-11", "County"), + ("Kericho", "KE-12", "County"), + ("Kiambu", "KE-13", "County"), + ("Kilifi", "KE-14", "County"), + ("Kirinyaga", "KE-15", "County"), + ("Kisii", "KE-16", "County"), + ("Kisumu", "KE-17", "County"), + ("Kitui", "KE-18", "County"), + ("Kwale", "KE-19", "County"), + ("Laikipia", "KE-20", "County"), + ("Lamu", "KE-21", "County"), + ("Machakos", "KE-22", "County"), + ("Makueni", "KE-23", "County"), + ("Mandera", "KE-24", "County"), + ("Marsabit", "KE-25", "County"), + ("Meru", "KE-26", "County"), + ("Migori", "KE-27", "County"), + ("Mombasa", "KE-28", "County"), + ("Murang'a", "KE-29", "County"), + ("Nairobi City", "KE-30", "County"), + ("Nakuru", "KE-31", "County"), + ("Nandi", "KE-32", "County"), + ("Narok", "KE-33", "County"), + ("Nyamira", "KE-34", "County"), + ("Nyandarua", "KE-35", "County"), + ("Nyeri", "KE-36", "County"), + ("Samburu", "KE-37", "County"), + ("Siaya", "KE-38", "County"), + ("Taita-Taveta", "KE-39", "County"), + ("Tana River", "KE-40", "County"), + ("Tharaka-Nithi", "KE-41", "County"), + ("Trans Nzoia", "KE-42", "County"), + ("Turkana", "KE-43", "County"), + ("Uasin Gishu", "KE-44", "County"), + ("Vihiga", "KE-45", "County"), + ("Wajir", "KE-46", "County"), + ("West Pokot", "KE-47", "County") + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForKenya() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Kenya; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(KENYA_COUNTRY_NAME, country.Name); - Assert.Equal(KENYA_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(KENYA_NATIVE_NAME, country.NativeName); - Assert.Equal(KENYA_CAPITAL, country.Capital); - Assert.Equal(KENYA_NUMERIC_CODE, country.NumericCode); - Assert.Equal(KENYA_ISO2_CODE, country.ISO2Code); - Assert.Equal(KENYA_ISO3_CODE, country.ISO3Code); - Assert.Equal(KENYA_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(KENYA_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + + AssertCorrectInformation( + country, + ExpectedId, + KENYA_COUNTRY_NAME, + KENYA_OFFICIAL_NAME, + KENYA_NATIVE_NAME, + KENYA_CAPITAL, + KENYA_NUMERIC_CODE, + KENYA_ISO2_CODE, + KENYA_ISO3_CODE, + KENYA_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/KiribatiTest.cs b/src/World.Net.UnitTests/Countries/KiribatiTest.cs index 4997171..cc14c4f 100644 --- a/src/World.Net.UnitTests/Countries/KiribatiTest.cs +++ b/src/World.Net.UnitTests/Countries/KiribatiTest.cs @@ -3,7 +3,7 @@ namespace World.Net.UnitTests.Countries; -public sealed class KiribatiTest +public sealed class KiribatiTest : AssertCountryTestBase { private const string KIRIBATI_COUNTRY_NAME = "Kiribati"; private const string KIRIBATI_NATIVE_NAME = "Kiribati"; @@ -13,31 +13,39 @@ public sealed class KiribatiTest private const string KIRIBATI_ISO3_CODE = "KIR"; private const int KIRIBATI_NUMERIC_CODE = 296; private readonly string[] KIRIBATI_CALLING_CODE = ["+686"]; - private const int KIRIBATI_STATE_COUNT = 3; private static readonly string[] VALID_STATE_TYPES = { "Group" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Kiribati; + + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Gilbert Islands", "KI-G", "Group"), + ("Line Islands", "KI-L", "Group"), + ("Phoenix Islands", "KI-P", "Group") + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForKiribati() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Kiribati; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(KIRIBATI_COUNTRY_NAME, country.Name); - Assert.Equal(KIRIBATI_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(KIRIBATI_NATIVE_NAME, country.NativeName); - Assert.Equal(KIRIBATI_CAPITAL, country.Capital); - Assert.Equal(KIRIBATI_NUMERIC_CODE, country.NumericCode); - Assert.Equal(KIRIBATI_ISO2_CODE, country.ISO2Code); - Assert.Equal(KIRIBATI_ISO3_CODE, country.ISO3Code); - Assert.Equal(KIRIBATI_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(KIRIBATI_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + + AssertCorrectInformation( + country, + ExpectedId, + KIRIBATI_COUNTRY_NAME, + KIRIBATI_OFFICIAL_NAME, + KIRIBATI_NATIVE_NAME, + KIRIBATI_CAPITAL, + KIRIBATI_NUMERIC_CODE, + KIRIBATI_ISO2_CODE, + KIRIBATI_ISO3_CODE, + KIRIBATI_CALLING_CODE, + ExpectedStates + ); } } diff --git a/src/World.Net.UnitTests/Countries/KosovoTest.cs b/src/World.Net.UnitTests/Countries/KosovoTest.cs index 2e2cd1a..c76c246 100644 --- a/src/World.Net.UnitTests/Countries/KosovoTest.cs +++ b/src/World.Net.UnitTests/Countries/KosovoTest.cs @@ -1,11 +1,6 @@ -using World.Net; -using World.Net.Countries; -using World.Net.Helpers; -using Xunit; - namespace World.Net.UnitTests.Countries { - public class KosovoTest + public class KosovoTest : AssertCountryTestBase { private const CountryIdentifier ExpectedId = CountryIdentifier.Kosovo; private const string ExpectedName = "Kosovo"; @@ -31,24 +26,20 @@ private static readonly (string Name, string IsoCode, string Type)[] ExpectedSta public void GetCountry_ReturnsCorrectInformation_ForKosovo() { var country = CountryProvider.GetCountry(ExpectedId); - Assert.Equal(ExpectedId, country.Id); - Assert.Equal(ExpectedName, country.Name); - Assert.Equal(ExpectedOfficialName, country.OfficialName); - Assert.Equal(ExpectedNativeName, country.NativeName); - Assert.Equal(ExpectedCapital, country.Capital); - Assert.Equal(ExpectedNumericCode, country.NumericCode); - Assert.Equal(ExpectedISO2Code, country.ISO2Code); - Assert.Equal(ExpectedISO3Code, country.ISO3Code); - Assert.Equal(ExpectedCallingCode, country.CallingCode); - var states = country.States.ToArray(); - Assert.Equal(ExpectedStates.Length, states.Length); - for (int i = 0; i < states.Length; i++) - { - Assert.Equal(ExpectedStates[i].Name, states[i].Name); - Assert.Equal(ExpectedStates[i].IsoCode, states[i].IsoCode); - Assert.Equal(ExpectedStates[i].Type, states[i].Type); - } + AssertCorrectInformation( + country, + ExpectedId, + ExpectedName, + ExpectedOfficialName, + ExpectedNativeName, + ExpectedCapital, + ExpectedNumericCode, + ExpectedISO2Code, + ExpectedISO3Code, + ExpectedCallingCode, + ExpectedStates + ); } } } diff --git a/src/World.Net.UnitTests/Countries/KuwaitTest.cs b/src/World.Net.UnitTests/Countries/KuwaitTest.cs index 58a97c1..94cf8b1 100644 --- a/src/World.Net.UnitTests/Countries/KuwaitTest.cs +++ b/src/World.Net.UnitTests/Countries/KuwaitTest.cs @@ -1,6 +1,6 @@ namespace World.Net.UnitTests.Countries { - public class KuwaitTest + public class KuwaitTest : AssertCountryTestBase { private const CountryIdentifier ExpectedId = CountryIdentifier.Kuwait; private const string ExpectedName = "Kuwait"; @@ -25,24 +25,20 @@ private static readonly (string Name, string IsoCode, string Type)[] ExpectedSta public void GetCountry_ReturnsCorrectInformation_ForKuwait() { var country = CountryProvider.GetCountry(ExpectedId); - Assert.Equal(ExpectedId, country.Id); - Assert.Equal(ExpectedName, country.Name); - Assert.Equal(ExpectedOfficialName, country.OfficialName); - Assert.Equal(ExpectedNativeName, country.NativeName); - Assert.Equal(ExpectedCapital, country.Capital); - Assert.Equal(ExpectedNumericCode, country.NumericCode); - Assert.Equal(ExpectedISO2Code, country.ISO2Code); - Assert.Equal(ExpectedISO3Code, country.ISO3Code); - Assert.Equal(ExpectedCallingCode, country.CallingCode); - - var states = country.States.ToArray(); - Assert.Equal(ExpectedStates.Length, states.Length); - for (int i = 0; i < states.Length; i++) - { - Assert.Equal(ExpectedStates[i].Name, states[i].Name); - Assert.Equal(ExpectedStates[i].IsoCode, states[i].IsoCode); - Assert.Equal(ExpectedStates[i].Type, states[i].Type); - } + + AssertCorrectInformation( + country, + ExpectedId, + ExpectedName, + ExpectedOfficialName, + ExpectedNativeName, + ExpectedCapital, + ExpectedNumericCode, + ExpectedISO2Code, + ExpectedISO3Code, + ExpectedCallingCode, + ExpectedStates + ); } } }