diff --git a/src/World.Net.UnitTests/Countries/IraqTest.cs b/src/World.Net.UnitTests/Countries/IraqTest.cs new file mode 100644 index 0000000..33431f9 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/IraqTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; +public sealed class IraqTest +{ + private const string IRAQ_COUNTRY_NAME = "Iraq"; + private const string IRAQ_NATIVE_NAME = "العراق"; + private const string IRAQ_CAPITAL = "Baghdad"; + private const string IRAQ_OFFICIAL_NAME = "Republic of Iraq"; + private const string IRAQ_ISO2_CODE = "IQ"; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForIraq() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Iraq; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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)); + } +} + diff --git a/src/World.Net.UnitTests/Countries/IrelandTest.cs b/src/World.Net.UnitTests/Countries/IrelandTest.cs new file mode 100644 index 0000000..f2c387c --- /dev/null +++ b/src/World.Net.UnitTests/Countries/IrelandTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; +public sealed class IrelandTest +{ + private const string IRELAND_COUNTRY_NAME = "Ireland"; + private const string IRELAND_NATIVE_NAME = "Éire"; + private const string IRELAND_CAPITAL = "Dublin"; + private const string IRELAND_OFFICIAL_NAME = "Republic of Ireland"; + private const string IRELAND_ISO2_CODE = "IE"; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForIreland() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Ireland; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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)); + } +} diff --git a/src/World.Net.UnitTests/Countries/IsraelTest.cs b/src/World.Net.UnitTests/Countries/IsraelTest.cs new file mode 100644 index 0000000..357b86a --- /dev/null +++ b/src/World.Net.UnitTests/Countries/IsraelTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; +public sealed class IsraelTest +{ + private const string ISRAEL_COUNTRY_NAME = "Israel"; + private const string ISRAEL_NATIVE_NAME = "יִשְׂרָאֵל"; + private const string ISRAEL_CAPITAL = "Jerusalem"; + private const string ISRAEL_OFFICIAL_NAME = "State of Israel"; + private const string ISRAEL_ISO2_CODE = "IL"; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForIsrael() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Israel; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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)); + } +} diff --git a/src/World.Net.UnitTests/Countries/ItalyTest.cs b/src/World.Net.UnitTests/Countries/ItalyTest.cs new file mode 100644 index 0000000..d2fd3fa --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ItalyTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; +public sealed class ItalyTest +{ + private const string ITALY_COUNTRY_NAME = "Italy"; + private const string ITALY_NATIVE_NAME = "Italia"; + private const string ITALY_CAPITAL = "Rome"; + private const string ITALY_OFFICIAL_NAME = "Italian Republic"; + private const string ITALY_ISO2_CODE = "IT"; + 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", }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForItaly() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Italy; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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)); + } +} diff --git a/src/World.Net/Countries/Iraq.cs b/src/World.Net/Countries/Iraq.cs new file mode 100644 index 0000000..926627f --- /dev/null +++ b/src/World.Net/Countries/Iraq.cs @@ -0,0 +1,52 @@ +namespace World.Net.Countries; +internal sealed class Iraq : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Iraq; + + // + public string Name { get; } = "Iraq"; + + // + public string OfficialName { get; } = "Republic of Iraq"; + + // + public string NativeName => "العراق"; + + // + public string Capital { get; } = "Baghdad"; + + // + public int NumericCode { get; } = 368; + + // + public string ISO2Code { get; } = "IQ"; + + // + public string ISO3Code { get; } = "IRQ"; + + // + public string[] CallingCode { get; } = ["+964"]; + + // + public IEnumerable States => + [ + new("Al Anbar", "IQ-AN", "Governorate"), + new("Al Muthanna", "IQ-MU", "Governorate"), + new("Al-Qādisiyyah", "IQ-QA", "Governorate"), + new("Babylon", "IQ-BB", "Governorate"), + new("Baghdad", "IQ-BG", "Governorate"), + new("Basra", "IQ-BA", "Governorate"), + new("Dhi Qar", "IQ-DQ", "Governorate"), + new("Diyala", "IQ-DI", "Governorate"), + new("Dohuk", "IQ-DA", "Governorate"), + new("Erbil", "IQ-AR", "Governorate"), + new("Karbala", "IQ-KA", "Governorate"), + new("Kirkuk", "IQ-KI", "Governorate"), + new("Maysan", "IQ-MA", "Governorate"), + new("Najaf", "IQ-NA", "Governorate"), + new("Nineveh", "IQ-NI", "Governorate"), + new("Saladin", "IQ-SD", "Governorate"), + new("Sulaymaniyah", "IQ-SU", "Governorate"), + new("Wasit", "IQ-WA", "Governorate") + ]; +} diff --git a/src/World.Net/Countries/Ireland.cs b/src/World.Net/Countries/Ireland.cs new file mode 100644 index 0000000..1c7e733 --- /dev/null +++ b/src/World.Net/Countries/Ireland.cs @@ -0,0 +1,65 @@ +namespace World.Net.Countries; +internal sealed class Ireland : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Ireland; + + // + public string Name { get; } = "Ireland"; + + // + public string OfficialName { get; } = "Republic of Ireland"; + + // + public string NativeName => "Éire"; + + // + public string Capital { get; } = "Dublin"; + + // + public int NumericCode { get; } = 372; + + // + public string ISO2Code { get; } = "IE"; + + // + public string ISO3Code { get; } = "IRL"; + + // + public string[] CallingCode { get; } = ["+353"]; + + // + public IEnumerable States => + [ + new("Carlow", "IE-CW", "County"), + new("Cavan", "IE-CN", "County"), + new("Clare", "IE-CE", "County"), + new("Connacht", "IE-C", "Province"), + new("Cork", "IE-CO", "County"), + new("Donegal", "IE-DL", "County"), + new("Dublin", "IE-D", "County"), + new("Galway", "IE-G", "County"), + new("Kerry", "IE-KY", "County"), + new("Kildare", "IE-KE", "County"), + new("Kilkenny", "IE-KK", "County"), + new("Laois", "IE-LS", "County"), + new("Leinster", "IE-L", "Province"), + new("Leitrim", "IE-LM", "County"), + new("Limerick", "IE-LK", "County"), + new("Longford", "IE-LD", "County"), + new("Louth", "IE-LH", "County"), + new("Mayo", "IE-MO", "County"), + new("Meath", "IE-MH", "County"), + new("Monaghan", "IE-MN", "County"), + new("Munster", "IE-M", "Province"), + new("Offaly", "IE-OY", "County"), + new("Roscommon", "IE-RN", "County"), + new("Sligo", "IE-SO", "County"), + new("Tipperary", "IE-TA", "County"), + new("Ulster", "IE-U", "Province"), + new("Waterford", "IE-WD", "County"), + new("Westmeath", "IE-WH", "County"), + new("Wexford", "IE-WX", "County"), + new("Wicklow", "IE-WW", "County") + ]; + +} diff --git a/src/World.Net/Countries/Israel.cs b/src/World.Net/Countries/Israel.cs new file mode 100644 index 0000000..c0c1516 --- /dev/null +++ b/src/World.Net/Countries/Israel.cs @@ -0,0 +1,40 @@ +namespace World.Net.Countries; +internal sealed class Israel : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Israel; + + // + public string Name { get; } = "Israel"; + + // + public string OfficialName { get; } = "State of Israel"; + + // + public string NativeName => "יִשְׂרָאֵל"; + + // + public string Capital { get; } = "Jerusalem"; + + // + public int NumericCode { get; } = 376; + + // + public string ISO2Code { get; } = "IL"; + + // + public string ISO3Code { get; } = "ISR"; + + // + public string[] CallingCode { get; } = ["+972"]; + + // + public IEnumerable States => + [ + new("Central", "IL-M", "District"), + new("Haifa", "IL-HA", "District"), + new("Jerusalem", "IL-JM", "District"), + new("Northern", "IL-Z", "District"), + new("Southern", "IL-D", "District"), + new("Tel Aviv", "IL-TA", "District") + ]; +} diff --git a/src/World.Net/Countries/Italy.cs b/src/World.Net/Countries/Italy.cs new file mode 100644 index 0000000..4589bf1 --- /dev/null +++ b/src/World.Net/Countries/Italy.cs @@ -0,0 +1,145 @@ +namespace World.Net.Countries; +internal sealed class Italy : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Italy; + + // + public string Name { get; } = "Italy"; + + // + public string OfficialName { get; } = "Italian Republic"; + + // + public string NativeName => "Italia"; + + // + public string Capital { get; } = "Rome"; + + // + public int NumericCode { get; } = 380; + + // + public string ISO2Code { get; } = "IT"; + + // + public string ISO3Code { get; } = "ITA"; + + // + public string[] CallingCode { get; } = ["+39"]; + + // + public IEnumerable States => + [ + new("Abruzzo", "IT-65", "Region"), + new("Agrigento", "IT-AG", "Free Municipal Consortium"), + new("Alessandria", "IT-AL", "Province"), + new("Ancona", "IT-AN", "Province"), + new("Aosta Valley", "IT-23", "Autonomous Region"), + new("Apulia", "IT-75", "Region"), + new("Arezzo", "IT-AR", "Province"), + new("Ascoli Piceno", "IT-AP", "Province"), + new("Asti", "IT-AT", "Province"), + new("Avellino", "IT-AV", "Province"), + new("Barletta-Andria-Trani", "IT-BT", "Province"), + new("Basilicata", "IT-77", "Region"), + new("Belluno", "IT-BL", "Province"), + new("Benevento", "IT-BN", "Province"), + new("Bergamo", "IT-BG", "Province"), + new("Biella", "IT-BI", "Province"), + new("Brescia", "IT-BS", "Province"), + new("Brindisi", "IT-BR", "Province"), + new("Calabria", "IT-78", "Region"), + new("Caltanissetta", "IT-CL", "Free Municipal Consortium"), + new("Campania", "IT-72", "Region"), + new("Campobasso", "IT-CB", "Province"), + new("Caserta", "IT-CE", "Province"), + new("Catanzaro", "IT-CZ", "Province"), + new("Chieti", "IT-CH", "Province"), + new("Como", "IT-CO", "Province"), + new("Cosenza", "IT-CS", "Province"), + new("Cremona", "IT-CR", "Province"), + new("Crotone", "IT-KR", "Province"), + new("Cuneo", "IT-CN", "Province"), + new("Emilia-Romagna", "IT-45", "Region"), + new("Enna", "IT-EN", "Free Municipal Consortium"), + new("Fermo", "IT-FM", "Province"), + new("Ferrara", "IT-FE", "Province"), + new("Foggia", "IT-FG", "Province"), + new("Forlì-Cesena", "IT-FC", "Province"), + new("Friuli–Venezia Giulia", "IT-36", "Autonomous Region"), + new("Frosinone", "IT-FR", "Province"), + new("Gorizia", "IT-GO", "Decentralized Regional Entity"), + new("Grosseto", "IT-GR", "Province"), + new("Imperia", "IT-IM", "Province"), + new("Isernia", "IT-IS", "Province"), + new("L'Aquila", "IT-AQ", "Province"), + new("La Spezia", "IT-SP", "Province"), + new("Latina", "IT-LT", "Province"), + new("Lazio", "IT-62", "Region"), + new("Lecce", "IT-LE", "Province"), + new("Lecco", "IT-LC", "Province"), + new("Liguria", "IT-42", "Region"), + new("Livorno", "IT-LI", "Province"), + new("Lodi", "IT-LO", "Province"), + new("Lombardy", "IT-25", "Region"), + new("Lucca", "IT-LU", "Province"), + new("Macerata", "IT-MC", "Province"), + new("Mantua", "IT-MN", "Province"), + new("Marche", "IT-57", "Region"), + new("Massa and Carrara", "IT-MS", "Province"), + new("Matera", "IT-MT", "Province"), + new("Modena", "IT-MO", "Province"), + new("Molise", "IT-67", "Region"), + new("Monza and Brianza", "IT-MB", "Province"), + new("Novara", "IT-NO", "Province"), + new("Nuoro", "IT-NU", "Province"), + new("Oristano", "IT-OR", "Province"), + new("Padua", "IT-PD", "Province"), + new("Palermo", "IT-PA", "Metropolitan City"), + new("Parma", "IT-PR", "Province"), + new("Pavia", "IT-PV", "Province"), + new("Perugia", "IT-PG", "Province"), + new("Pesaro and Urbino", "IT-PU", "Province"), + new("Pescara", "IT-PE", "Province"), + new("Piacenza", "IT-PC", "Province"), + new("Piedmont", "IT-21", "Region"), + new("Pisa", "IT-PI", "Province"), + new("Pistoia", "IT-PT", "Province"), + new("Pordenone", "IT-PN", "Decentralized Regional Entity"), + new("Potenza", "IT-PZ", "Province"), + new("Prato", "IT-PO", "Province"), + new("Ragusa", "IT-RG", "Free Municipal Consortium"), + new("Ravenna", "IT-RA", "Province"), + new("Reggio Emilia", "IT-RE", "Province"), + new("Rieti", "IT-RI", "Province"), + new("Rimini", "IT-RN", "Province"), + new("Rovigo", "IT-RO", "Province"), + new("Salerno", "IT-SA", "Province"), + new("Sardinia", "IT-88", "Autonomous Region"), + new("Sassari", "IT-SS", "Province"), + new("Savona", "IT-SV", "Province"), + new("Sicily", "IT-82", "Autonomous Region"), + new("Siena", "IT-SI", "Province"), + new("Siracusa", "IT-SR", "Free Municipal Consortium"), + new("Sondrio", "IT-SO", "Province"), + new("South Sardinia", "IT-SU", "Province"), + new("Taranto", "IT-TA", "Province"), + new("Teramo", "IT-TE", "Province"), + new("Terni", "IT-TR", "Province"), + new("Trapani", "IT-TP", "Free Municipal Consortium"), + new("Trentino-South Tyrol", "IT-32", "Autonomous Region"), + new("Treviso", "IT-TV", "Province"), + new("Trieste", "IT-TS", "Decentralized Regional Entity"), + new("Tuscany", "IT-52", "Region"), + new("Udine", "IT-UD", "Decentralized Regional Entity"), + new("Umbria", "IT-55", "Region"), + new("Varese", "IT VA", "Province"), + new("Veneto", "IT-34", "Region"), + new("Verbano-Cusio-Ossola", "IT-VB", "Province"), + new("Vercelli", "IT-VC", "Province"), + new("Verona", "IT-VR", "Province"), + new("Vibo Valentia", "IT-VV", "Province"), + new("Vicenza", "IT-VI", "Province"), + new("Viterbo", "IT-VT", "Province"), + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index ad7dd7c..ba11d9e 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -84,6 +84,10 @@ public static Dictionary Initialize() { CountryIdentifier.France, new France() }, { CountryIdentifier.FrenchGuiana, new FrenchGuiana() }, { CountryIdentifier.FrenchPolynesia, new FrenchPolynesia() }, + { CountryIdentifier.Iraq, new Iraq() }, + { CountryIdentifier.Ireland, new Ireland() }, + { CountryIdentifier.Israel, new Israel() }, + { CountryIdentifier.Italy, new Italy() }, // Future countries can be added here in the same format. };