diff --git a/src/World.Net.UnitTests/Countries/DominicanRepublicTest.cs b/src/World.Net.UnitTests/Countries/DominicanRepublicTest.cs new file mode 100644 index 0000000..e6ed39d --- /dev/null +++ b/src/World.Net.UnitTests/Countries/DominicanRepublicTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class DominicanRepublicTest +{ + private const string DOMINICANREPUBLIC_COUNTRY_NAME = "Dominican Republic"; + private const string DOMINICANREPUBLIC_NATIVE_NAME = "República Dominicana"; + private const string DOMINICANREPUBLIC_CAPITAL = "Santo Domingo"; + private const string DOMINICANREPUBLIC_OFFICIAL_NAME = "Dominican Republic"; + private const string DOMINICANREPUBLIC_ISO2_CODE = "DO"; + private const string DOMINICANREPUBLIC_ISO3_CODE = "DOM"; + private const int DOMINICANREPUBLIC_NUMERIC_CODE = 214; + private readonly string[] DOMINICANREPUBLIC_CALLING_CODE = ["+1-809", "+1-829", "+1-849"]; + private const int DOMINICANREPUBLIC_STATE_COUNT = 32; // 31 provinces + 1 National District + private static readonly string[] VALID_STATE_TYPES = { "Province", "National District" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForDominicanRepublic() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.DominicanRepublic; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(DOMINICANREPUBLIC_COUNTRY_NAME, country.Name); + Assert.Equal(DOMINICANREPUBLIC_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(DOMINICANREPUBLIC_NATIVE_NAME, country.NativeName); + Assert.Equal(DOMINICANREPUBLIC_CAPITAL, country.Capital); + Assert.Equal(DOMINICANREPUBLIC_NUMERIC_CODE, country.NumericCode); + Assert.Equal(DOMINICANREPUBLIC_ISO2_CODE, country.ISO2Code); + Assert.Equal(DOMINICANREPUBLIC_ISO3_CODE, country.ISO3Code); + Assert.Equal(DOMINICANREPUBLIC_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(DOMINICANREPUBLIC_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/EcuadorTest.cs b/src/World.Net.UnitTests/Countries/EcuadorTest.cs new file mode 100644 index 0000000..24c56c5 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EcuadorTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class EcuadorTest +{ + private const string ECUADOR_COUNTRY_NAME = "Ecuador"; + private const string ECUADOR_NATIVE_NAME = "República del Ecuador"; + private const string ECUADOR_CAPITAL = "Quito"; + private const string ECUADOR_OFFICIAL_NAME = "Republic of Ecuador"; + private const string ECUADOR_ISO2_CODE = "EC"; + private const string ECUADOR_ISO3_CODE = "ECU"; + private const int ECUADOR_NUMERIC_CODE = 218; + private readonly string[] ECUADOR_CALLING_CODE = ["+593"]; + private const int ECUADOR_STATE_COUNT = 24; // 24 provinces + private static readonly string[] VALID_STATE_TYPES = { "Province" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEcuador() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Ecuador; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(ECUADOR_COUNTRY_NAME, country.Name); + Assert.Equal(ECUADOR_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(ECUADOR_NATIVE_NAME, country.NativeName); + Assert.Equal(ECUADOR_CAPITAL, country.Capital); + Assert.Equal(ECUADOR_NUMERIC_CODE, country.NumericCode); + Assert.Equal(ECUADOR_ISO2_CODE, country.ISO2Code); + Assert.Equal(ECUADOR_ISO3_CODE, country.ISO3Code); + Assert.Equal(ECUADOR_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(ECUADOR_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/EgyptTest.cs b/src/World.Net.UnitTests/Countries/EgyptTest.cs new file mode 100644 index 0000000..1e966ce --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EgyptTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class EgyptTest +{ + private const string EGYPT_COUNTRY_NAME = "Egypt"; + private const string EGYPT_NATIVE_NAME = "جمهورية مصر العربية"; + private const string EGYPT_CAPITAL = "Cairo"; + private const string EGYPT_OFFICIAL_NAME = "Arab Republic of Egypt"; + private const string EGYPT_ISO2_CODE = "EG"; + private const string EGYPT_ISO3_CODE = "EGY"; + private const int EGYPT_NUMERIC_CODE = 818; + private readonly string[] EGYPT_CALLING_CODE = ["+20"]; + private const int EGYPT_STATE_COUNT = 27; // 27 Governorates + private static readonly string[] VALID_STATE_TYPES = { "Governorate" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEgypt() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Egypt; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(EGYPT_COUNTRY_NAME, country.Name); + Assert.Equal(EGYPT_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(EGYPT_NATIVE_NAME, country.NativeName); + Assert.Equal(EGYPT_CAPITAL, country.Capital); + Assert.Equal(EGYPT_NUMERIC_CODE, country.NumericCode); + Assert.Equal(EGYPT_ISO2_CODE, country.ISO2Code); + Assert.Equal(EGYPT_ISO3_CODE, country.ISO3Code); + Assert.Equal(EGYPT_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(EGYPT_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/TimorLesteTest.cs b/src/World.Net.UnitTests/Countries/TimorLesteTest.cs new file mode 100644 index 0000000..d65fb2e --- /dev/null +++ b/src/World.Net.UnitTests/Countries/TimorLesteTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class TimorLesteTest +{ + private const string TIMORLESTE_COUNTRY_NAME = "Timor-Leste"; + private const string TIMORLESTE_NATIVE_NAME = "Repúblika Demokrátika Timór-Leste"; + private const string TIMORLESTE_CAPITAL = "Dili"; + private const string TIMORLESTE_OFFICIAL_NAME = "Democratic Republic of Timor-Leste"; + private const string TIMORLESTE_ISO2_CODE = "TL"; + private const string TIMORLESTE_ISO3_CODE = "TLS"; + private const int TIMORLESTE_NUMERIC_CODE = 626; + private readonly string[] TIMORLESTE_CALLING_CODE = ["+670"]; + private const int TIMORLESTE_STATE_COUNT = 13; // 12 municipalities + 1 special administrative region + private static readonly string[] VALID_STATE_TYPES = { "Municipality", "Special Administrative Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForTimorLeste() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.TimorLeste; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(TIMORLESTE_COUNTRY_NAME, country.Name); + Assert.Equal(TIMORLESTE_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(TIMORLESTE_NATIVE_NAME, country.NativeName); + Assert.Equal(TIMORLESTE_CAPITAL, country.Capital); + Assert.Equal(TIMORLESTE_NUMERIC_CODE, country.NumericCode); + Assert.Equal(TIMORLESTE_ISO2_CODE, country.ISO2Code); + Assert.Equal(TIMORLESTE_ISO3_CODE, country.ISO3Code); + Assert.Equal(TIMORLESTE_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(TIMORLESTE_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net/Countries/DominicanRepublic.cs b/src/World.Net/Countries/DominicanRepublic.cs new file mode 100644 index 0000000..e26896e --- /dev/null +++ b/src/World.Net/Countries/DominicanRepublic.cs @@ -0,0 +1,69 @@ +namespace World.Net.Countries; + +internal sealed class DominicanRepublic : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.DominicanRepublic; + + // + public string Name { get; } = "Dominican Republic"; + + // + public string OfficialName { get; } = "Dominican Republic"; + + // + public string NativeName => "República Dominicana"; + + // + public string Capital { get; } = "Santo Domingo"; + + // + public int NumericCode { get; } = 214; + + // + public string ISO2Code { get; } = "DO"; + + // + public string ISO3Code { get; } = "DOM"; + + // + public string[] CallingCode { get; } = ["+1-809", "+1-829", "+1-849"]; + + // + // + public IEnumerable States => + [ + new("Azua", "DO-02"), + new("Bahoruco", "DO-03"), + new("Barahona", "DO-04"), + new("Dajabón", "DO-05"), + new("Distrito Nacional", "DO-01", "National District"), + new("Duarte", "DO-06"), + new("El Seibo", "DO-08"), + new("Elias Piña", "DO-07"), + new("Espaillat", "DO-09"), + new("Hato Mayor", "DO-30"), + new("Hermanas Mirabal", "DO-19"), + new("Independencia", "DO-10"), + new("La Altagracia", "DO-11"), + new("La Romana", "DO-12"), + new("La Vega", "DO-13"), + new("Maria Trinidad Sanchez", "DO-14"), + new("Monseñor Nouel", "DO-28"), + new("Monte Cristi", "DO-15"), + new("Monte Plata", "DO-29"), + new("Pedernales", "DO-16"), + new("Peravia", "DO-17"), + new("Puerto Plata", "DO-18"), + new("Samana", "DO-20"), + new("San Cristobal", "DO-21"), + new("San Jose de Ocoa", "DO-31"), + new("San Juan", "DO-22"), + new("San Pedro de Macoris", "DO-23"), + new("Sanchez Ramirez", "DO-24"), + new("Santiago", "DO-25"), + new("Santiago Rodriguez", "DO-26"), + new("Santo Domingo", "DO-32"), + new("Valverde", "DO-27") + ]; +} diff --git a/src/World.Net/Countries/Ecuador.cs b/src/World.Net/Countries/Ecuador.cs new file mode 100644 index 0000000..fc68631 --- /dev/null +++ b/src/World.Net/Countries/Ecuador.cs @@ -0,0 +1,60 @@ +namespace World.Net.Countries; + +internal sealed class Ecuador : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Ecuador; + + // + public string Name { get; } = "Ecuador"; + + // + public string OfficialName { get; } = "Republic of Ecuador"; + + // + public string NativeName => "República del Ecuador"; + + // + public string Capital { get; } = "Quito"; + + // + public int NumericCode { get; } = 218; + + // + public string ISO2Code { get; } = "EC"; + + // + public string ISO3Code { get; } = "ECU"; + + // + public string[] CallingCode { get; } = ["+593"]; + + // + public IEnumerable States => + [ + new("Azuay", "EC-A"), + new("Bolívar", "EC-B"), + new("Cañar", "EC-F"), + new("Carchi", "EC-C"), + new("Chimborazo", "EC-H"), + new("Cotopaxi", "EC-X"), + new("El Oro", "EC-O"), + new("Esmeraldas", "EC-E"), + new("Galápagos", "EC-W"), + new("Guayas", "EC-G"), + new("Imbabura", "EC-I"), + new("Loja", "EC-L"), + new("Los Ríos", "EC-R"), + new("Manabí", "EC-M"), + new("Morona Santiago", "EC-S"), + new("Napo", "EC-N"), + new("Orellana", "EC-D"), + new("Pastaza", "EC-Y"), + new("Pichincha", "EC-P"), + new("Santa Elena", "EC-SE"), + new("Santo Domingo de los Tsáchilas", "EC-SD"), + new("Sucumbíos", "EC-U"), + new("Tungurahua", "EC-T"), + new("Zamora Chinchipe", "EC-Z") + ]; +} diff --git a/src/World.Net/Countries/Egypt.cs b/src/World.Net/Countries/Egypt.cs new file mode 100644 index 0000000..62319f2 --- /dev/null +++ b/src/World.Net/Countries/Egypt.cs @@ -0,0 +1,63 @@ +namespace World.Net.Countries; + +internal sealed class Egypt : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Egypt; + + // + public string Name { get; } = "Egypt"; + + // + public string OfficialName { get; } = "Arab Republic of Egypt"; + + // + public string NativeName => "جمهورية مصر العربية"; + + // + public string Capital { get; } = "Cairo"; + + // + public int NumericCode { get; } = 818; + + // + public string ISO2Code { get; } = "EG"; + + // + public string ISO3Code { get; } = "EGY"; + + // + public string[] CallingCode { get; } = ["+20"]; + + // + public IEnumerable States => + [ + new("Alexandria", "EG-ALX", "Governorate"), + new("Aswan", "EG-ASN", "Governorate"), + new("Asyut", "EG-AST", "Governorate"), + new("Beheira", "EG-BH", "Governorate"), + new("Beni Suef", "EG-BNS", "Governorate"), + new("Cairo", "EG-C", "Governorate"), + new("Dakahlia", "EG-DK", "Governorate"), + new("Damietta", "EG-DT", "Governorate"), + new("Faiyum", "EG-FYM", "Governorate"), + new("Gharbia", "EG-GH", "Governorate"), + new("Giza", "EG-GZ", "Governorate"), + new("Ismailia", "EG-IS", "Governorate"), + new("Kafr El Sheikh", "EG-KFS", "Governorate"), + new("Luxor", "EG-LX", "Governorate"), + new("Matrouh", "EG-MT", "Governorate"), + new("Minya", "EG-MN", "Governorate"), + new("Monufia", "EG-MNF", "Governorate"), + new("New Valley", "EG-WAD", "Governorate"), + new("North Sinai", "EG-SIN", "Governorate"), + new("Port Said", "EG-PTS", "Governorate"), + new("Qalyubia", "EG-KB", "Governorate"), + new("Qena", "EG-QN", "Governorate"), + new("Red Sea", "EG-BA", "Governorate"), + new("Sharqia", "EG-SHR", "Governorate"), + new("Sohag", "EG-SHG", "Governorate"), + new("South Sinai", "EG-JS", "Governorate"), + new("Suez", "EG-SUZ", "Governorate") + ]; +} diff --git a/src/World.Net/Countries/TimorLeste.cs b/src/World.Net/Countries/TimorLeste.cs new file mode 100644 index 0000000..84938a3 --- /dev/null +++ b/src/World.Net/Countries/TimorLeste.cs @@ -0,0 +1,49 @@ +namespace World.Net.Countries; + +internal sealed class TimorLeste : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.TimorLeste; + + // + public string Name { get; } = "Timor-Leste"; + + // + public string OfficialName { get; } = "Democratic Republic of Timor-Leste"; + + // + public string NativeName => "Repúblika Demokrátika Timór-Leste"; + + // + public string Capital { get; } = "Dili"; + + // + public int NumericCode { get; } = 626; + + // + public string ISO2Code { get; } = "TL"; + + // + public string ISO3Code { get; } = "TLS"; + + // + public string[] CallingCode { get; } = ["+670"]; + + // + public IEnumerable States => + [ + new("Aileu", "TL-AL", "Municipality"), + new("Ainaro", "TL-AN", "Municipality"), + new("Baucau", "TL-BA", "Municipality"), + new("Bobonaro", "TL-BO", "Municipality"), + new("Cova Lima", "TL-CO", "Municipality"), + new("Dili", "TL-DI", "Municipality"), + new("Ermera", "TL-ER", "Municipality"), + new("Lautém", "TL-LA", "Municipality"), + new("Liquiça", "TL-LI", "Municipality"), + new("Manatuto", "TL-MT", "Municipality"), + new("Manufahi", "TL-MF", "Municipality"), + new("Viqueque", "TL-VI", "Municipality"), + new("Oecusse", "TL-OE", "Special Administrative Region") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 528dec8..b3747cf 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -64,6 +64,10 @@ public static Dictionary Initialize() { CountryIdentifier.Curacao, new Curaçao() }, { CountryIdentifier.Cyprus, new Cyprus() }, { CountryIdentifier.CzechRepublic, new CzechRepublic() }, + { CountryIdentifier.DominicanRepublic, new DominicanRepublic() }, + { CountryIdentifier.TimorLeste, new TimorLeste() }, + { CountryIdentifier.Ecuador, new Ecuador() }, + { CountryIdentifier.Egypt, new Egypt() }, // Future countries can be added here in the same format. };