diff --git a/src/World.Net.UnitTests/Countries/CroatiaTest.cs b/src/World.Net.UnitTests/Countries/CroatiaTest.cs new file mode 100644 index 0000000..d950bf0 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CroatiaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CroatiaTest +{ + private const string CROATIA_COUNTRY_NAME = "Croatia"; + private const string CROATIA_NATIVE_NAME = "Hrvatska"; + private const string CROATIA_CAPITAL = "Zagreb"; + private const string CROATIA_OFFICIAL_NAME = "Republic of Croatia"; + private const string CROATIA_ISO2_CODE = "HR"; + private const string CROATIA_ISO3_CODE = "HRV"; + private const int CROATIA_NUMERIC_CODE = 191; + private const string CROATIA_CALLING_CODE = "+385"; + private const int CROATIA_STATE_COUNT = 21; + private static readonly string[] VALID_STATE_TYPES = { "City", "County" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCroatia() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Croatia; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CROATIA_COUNTRY_NAME, country.Name); + Assert.Equal(CROATIA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CROATIA_NATIVE_NAME, country.NativeName); + Assert.Equal(CROATIA_CAPITAL, country.Capital); + Assert.Equal(CROATIA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CROATIA_ISO2_CODE, country.ISO2Code); + Assert.Equal(CROATIA_ISO3_CODE, country.ISO3Code); + Assert.Equal(CROATIA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CROATIA_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/CubaTest.cs b/src/World.Net.UnitTests/Countries/CubaTest.cs new file mode 100644 index 0000000..9a34eea --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CubaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CubaTest +{ + private const string CUBA_COUNTRY_NAME = "Cuba"; + private const string CUBA_NATIVE_NAME = "Cuba"; + private const string CUBA_CAPITAL = "Havana"; + private const string CUBA_OFFICIAL_NAME = "Republic of Cuba"; + private const string CUBA_ISO2_CODE = "CU"; + private const string CUBA_ISO3_CODE = "CUB"; + private const int CUBA_NUMERIC_CODE = 192; + private const string CUBA_CALLING_CODE = "+53"; + private const int CUBA_STATE_COUNT = 16; + private static readonly string[] VALID_STATE_TYPES = { "Province", "Special Municipality" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCuba() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Cuba; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CUBA_COUNTRY_NAME, country.Name); + Assert.Equal(CUBA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CUBA_NATIVE_NAME, country.NativeName); + Assert.Equal(CUBA_CAPITAL, country.Capital); + Assert.Equal(CUBA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CUBA_ISO2_CODE, country.ISO2Code); + Assert.Equal(CUBA_ISO3_CODE, country.ISO3Code); + Assert.Equal(CUBA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CUBA_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/Cura\303\247aoTest.cs" "b/src/World.Net.UnitTests/Countries/Cura\303\247aoTest.cs" new file mode 100644 index 0000000..19a53b9 --- /dev/null +++ "b/src/World.Net.UnitTests/Countries/Cura\303\247aoTest.cs" @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CuraçaoTest +{ + private const string CURACAO_COUNTRY_NAME = "Curaçao"; + private const string CURACAO_NATIVE_NAME = "Kòrsou"; + private const string CURACAO_CAPITAL = "Willemstad"; + private const string CURACAO_OFFICIAL_NAME = "Country of Curaçao"; + private const string CURACAO_ISO2_CODE = "CW"; + private const string CURACAO_ISO3_CODE = "CUW"; + private const int CURACAO_NUMERIC_CODE = 531; + private const string CURACAO_CALLING_CODE = "+599"; + private const int CURACAO_STATE_COUNT = 1; + private static readonly string[] VALID_STATE_TYPES = { "Country" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCuracao() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Curacao; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CURACAO_COUNTRY_NAME, country.Name); + Assert.Equal(CURACAO_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CURACAO_NATIVE_NAME, country.NativeName); + Assert.Equal(CURACAO_CAPITAL, country.Capital); + Assert.Equal(CURACAO_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CURACAO_ISO2_CODE, country.ISO2Code); + Assert.Equal(CURACAO_ISO3_CODE, country.ISO3Code); + Assert.Equal(CURACAO_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.NotEmpty(country.States); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net.UnitTests/Countries/CyprusTest.cs b/src/World.Net.UnitTests/Countries/CyprusTest.cs new file mode 100644 index 0000000..15c2726 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CyprusTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CyprusTest +{ + private const string CYPRUS_COUNTRY_NAME = "Cyprus"; + private const string CYPRUS_NATIVE_NAME = "Κύπρος"; + private const string CYPRUS_CAPITAL = "Nicosia"; + private const string CYPRUS_OFFICIAL_NAME = "Republic of Cyprus"; + private const string CYPRUS_ISO2_CODE = "CY"; + private const string CYPRUS_ISO3_CODE = "CYP"; + private const int CYPRUS_NUMERIC_CODE = 196; + private const string CYPRUS_CALLING_CODE = "+357"; + private const int CYPRUS_STATE_COUNT = 6; + private static readonly string[] VALID_STATE_TYPES = { "District" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCyprus() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Cyprus; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CYPRUS_COUNTRY_NAME, country.Name); + Assert.Equal(CYPRUS_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CYPRUS_NATIVE_NAME, country.NativeName); + Assert.Equal(CYPRUS_CAPITAL, country.Capital); + Assert.Equal(CYPRUS_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CYPRUS_ISO2_CODE, country.ISO2Code); + Assert.Equal(CYPRUS_ISO3_CODE, country.ISO3Code); + Assert.Equal(CYPRUS_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CYPRUS_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/CzechRepublicTest.cs b/src/World.Net.UnitTests/Countries/CzechRepublicTest.cs new file mode 100644 index 0000000..ce41997 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CzechRepublicTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CzechRepublicTest +{ + private const string CZECHREPUBLIC_COUNTRY_NAME = "Czech Republic"; + private const string CZECHREPUBLIC_NATIVE_NAME = "Česká republika"; + private const string CZECHREPUBLIC_CAPITAL = "Prague"; + private const string CZECHREPUBLIC_OFFICIAL_NAME = "Czech Republic"; + private const string CZECHREPUBLIC_ISO2_CODE = "CZ"; + private const string CZECHREPUBLIC_ISO3_CODE = "CZE"; + private const int CZECHREPUBLIC_NUMERIC_CODE = 203; + private const string CZECHREPUBLIC_CALLING_CODE = "+420"; + private const int CZECHREPUBLIC_STATE_COUNT = 14; + private static readonly string[] VALID_STATE_TYPES = { "Region", "Capital City" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCzechRepublic() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.CzechRepublic; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CZECHREPUBLIC_COUNTRY_NAME, country.Name); + Assert.Equal(CZECHREPUBLIC_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CZECHREPUBLIC_NATIVE_NAME, country.NativeName); + Assert.Equal(CZECHREPUBLIC_CAPITAL, country.Capital); + Assert.Equal(CZECHREPUBLIC_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CZECHREPUBLIC_ISO2_CODE, country.ISO2Code); + Assert.Equal(CZECHREPUBLIC_ISO3_CODE, country.ISO3Code); + Assert.Equal(CZECHREPUBLIC_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CZECHREPUBLIC_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net/Countries/Croatia.cs b/src/World.Net/Countries/Croatia.cs new file mode 100644 index 0000000..3f17777 --- /dev/null +++ b/src/World.Net/Countries/Croatia.cs @@ -0,0 +1,57 @@ +namespace World.Net.Countries; + +internal sealed class Croatia : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Croatia; + + // + public string Name { get; } = "Croatia"; + + // + public string OfficialName { get; } = "Republic of Croatia"; + + // + public string NativeName => "Hrvatska"; + + // + public string Capital { get; } = "Zagreb"; + + // + public int NumericCode { get; } = 191; + + // + public string ISO2Code { get; } = "HR"; + + // + public string ISO3Code { get; } = "HRV"; + + // + public string CallingCode { get; } = "+385"; + + // + public IEnumerable States => + [ + new("Bjelovar-Bilogora", "HR-07", "County"), + new("Brod-Posavina", "HR-12", "County"), + new("Dubrovnik-Neretva", "HR-19", "County"), + new("Istria", "HR-18", "County"), + new("Karlovac", "HR-04", "County"), + new("Koprivnica-Križevci", "HR-06", "County"), + new("Krapina-Zagorje", "HR-02", "County"), + new("Lika-Senj", "HR-09", "County"), + new("Međimurje", "HR-20", "County"), + new("Osijek-Baranja", "HR-14", "County"), + new("Požega-Slavonia", "HR-11", "County"), + new("Primorje-Gorski Kotar", "HR-08", "County"), + new("Šibenik-Knin", "HR-15", "County"), + new("Sisak-Moslavina", "HR-03", "County"), + new("Split-Dalmatia", "HR-17", "County"), + new("Varaždin", "HR-05", "County"), + new("Virovitica-Podravina", "HR-10", "County"), + new("Vukovar-Syrmia", "HR-16", "County"), + new("Zadar", "HR-13", "County"), + new("Zagreb", "HR-21", "City"), + new("Zagreb County", "HR-01", "County") + ]; +} diff --git a/src/World.Net/Countries/Cuba.cs b/src/World.Net/Countries/Cuba.cs new file mode 100644 index 0000000..ccc83e9 --- /dev/null +++ b/src/World.Net/Countries/Cuba.cs @@ -0,0 +1,52 @@ +namespace World.Net.Countries; + +internal sealed class Cuba : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Cuba; + + // + public string Name { get; } = "Cuba"; + + // + public string OfficialName { get; } = "Republic of Cuba"; + + // + public string NativeName => "Cuba"; + + // + public string Capital { get; } = "Havana"; + + // + public int NumericCode { get; } = 192; + + // + public string ISO2Code { get; } = "CU"; + + // + public string ISO3Code { get; } = "CUB"; + + // + public string CallingCode { get; } = "+53"; + + // + public IEnumerable States => + [ + new("Artemisa", "CU-15", "Province"), + new("Camagüey", "CU-09", "Province"), + new("Ciego de Ávila", "CU-08", "Province"), + new("Cienfuegos", "CU-06", "Province"), + new("Granma", "CU-12", "Province"), + new("Guantánamo", "CU-14", "Province"), + new("Holguín", "CU-11", "Province"), + new("Isla de la Juventud", "CU-99", "Special Municipality"), + new("La Habana", "CU-03", "Province"), + new("Las Tunas", "CU-10", "Province"), + new("Matanzas", "CU-04", "Province"), + new("Mayabeque", "CU-16", "Province"), + new("Pinar del Río", "CU-01", "Province"), + new("Sancti Spíritus", "CU-07", "Province"), + new("Santiago de Cuba", "CU-13", "Province"), + new("Villa Clara", "CU-05", "Province") + ]; +} diff --git "a/src/World.Net/Countries/Cura\303\247ao.cs" "b/src/World.Net/Countries/Cura\303\247ao.cs" new file mode 100644 index 0000000..4e89f92 --- /dev/null +++ "b/src/World.Net/Countries/Cura\303\247ao.cs" @@ -0,0 +1,37 @@ +namespace World.Net.Countries; + +internal sealed class Curaçao : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Curacao; + + // + public string Name { get; } = "Curaçao"; + + // + public string OfficialName { get; } = "Country of Curaçao"; + + // + public string NativeName => "Kòrsou"; + + // + public string Capital { get; } = "Willemstad"; + + // + public int NumericCode { get; } = 531; + + // + public string ISO2Code { get; } = "CW"; + + // + public string ISO3Code { get; } = "CUW"; + + // + public string CallingCode { get; } = "+599"; + + // + public IEnumerable States => + [ + new("Curaçao", "CW", "Country") + ]; +} diff --git a/src/World.Net/Countries/Cyprus.cs b/src/World.Net/Countries/Cyprus.cs new file mode 100644 index 0000000..c7c93e6 --- /dev/null +++ b/src/World.Net/Countries/Cyprus.cs @@ -0,0 +1,42 @@ +namespace World.Net.Countries; + +internal sealed class Cyprus : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Cyprus; + + // + public string Name { get; } = "Cyprus"; + + // + public string OfficialName { get; } = "Republic of Cyprus"; + + // + public string NativeName => "Κύπρος"; + + // + public string Capital { get; } = "Nicosia"; + + // + public int NumericCode { get; } = 196; + + // + public string ISO2Code { get; } = "CY"; + + // + public string ISO3Code { get; } = "CYP"; + + // + public string CallingCode { get; } = "+357"; + + // + public IEnumerable States => + [ + new("Famagusta", "CY-04", "District"), + new("Kyrenia", "CY-06", "District"), + new("Larnaca", "CY-03", "District"), + new("Limassol", "CY-02", "District"), + new("Nicosia", "CY-01", "District"), + new("Paphos", "CY-05", "District") + ]; +} diff --git a/src/World.Net/Countries/CzechRepublic.cs b/src/World.Net/Countries/CzechRepublic.cs new file mode 100644 index 0000000..027aa67 --- /dev/null +++ b/src/World.Net/Countries/CzechRepublic.cs @@ -0,0 +1,50 @@ +namespace World.Net.Countries; + +internal sealed class CzechRepublic : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.CzechRepublic; + + // + public string Name { get; } = "Czech Republic"; + + // + public string OfficialName { get; } = "Czech Republic"; + + // + public string NativeName => "Česká republika"; + + // + public string Capital { get; } = "Prague"; + + // + public int NumericCode { get; } = 203; + + // + public string ISO2Code { get; } = "CZ"; + + // + public string ISO3Code { get; } = "CZE"; + + // + public string CallingCode { get; } = "+420"; + + // + public IEnumerable States => + [ + new("Central Bohemian", "CZ-20", "Region"), + new("Hradec Králové", "CZ-52", "Region"), + new("Karlovy Vary", "CZ-41", "Region"), + new("Liberec", "CZ-51", "Region"), + new("Moravian-Silesian", "CZ-80", "Region"), + new("Olomouc", "CZ-71", "Region"), + new("Pardubice", "CZ-53", "Region"), + new("Plzeň", "CZ-32", "Region"), + new("Prague", "CZ-10", "Capital City"), + new("South Bohemian", "CZ-31", "Region"), + new("South Moravian", "CZ-64", "Region"), + new("Ústí nad Labem", "CZ-42", "Region"), + new("Vysočina", "CZ-63", "Region"), + new("Zlín", "CZ-72", "Region") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 893be47..bdfbe02 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -50,6 +50,11 @@ public static Dictionary Initialize() { CountryIdentifier.CocosKeelingIslands, new CocosKeelingIslands() }, { CountryIdentifier.Colombia, new Colombia() }, { CountryIdentifier.Comoros, new Comoros() }, + { CountryIdentifier.Croatia, new Croatia() }, + { CountryIdentifier.Cuba, new Cuba() }, + { CountryIdentifier.Curacao, new Curaçao() }, + { CountryIdentifier.Cyprus, new Cyprus() }, + { CountryIdentifier.CzechRepublic, new CzechRepublic() }, // Future countries can be added here in the same format. };