From e57de560b53d40d894637b901c9d57d329f2668a Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 11:37:23 +0100 Subject: [PATCH 01/14] add estonia --- .../Countries/EstoniaTests.cs | 40 +++++++++++++++++ src/World.Net/Countries/Estonia.cs | 43 +++++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 23 ++++++++++ 3 files changed, 106 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/EstoniaTests.cs create mode 100644 src/World.Net/Countries/Estonia.cs diff --git a/src/World.Net.UnitTests/Countries/EstoniaTests.cs b/src/World.Net.UnitTests/Countries/EstoniaTests.cs new file mode 100644 index 0000000..37c8b77 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EstoniaTests.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class EstoniaTests + { + private const string ESTONIA_NAME = "Estonia"; + private const int ESTONIA_STATE_COUNT = 15; + private const string ESTONIA_OFFICIAL_NAME = "Republic of Estonia"; + private const string ESTONIA_NATIVE_NAME = "Eesti"; + private const string ESTONIA_CAPITAL = "Tallinn"; + private const int ESTONIA_NUMERIC_CODE = 233; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEstonia() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Estonia; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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); + } + } +} diff --git a/src/World.Net/Countries/Estonia.cs b/src/World.Net/Countries/Estonia.cs new file mode 100644 index 0000000..1361a74 --- /dev/null +++ b/src/World.Net/Countries/Estonia.cs @@ -0,0 +1,43 @@ + +namespace World.Net.Countries +{ + internal class Estonia : ICountry + { + public CountryIdentifier Id => CountryIdentifier.Estonia; + + public string Name => nameof(Estonia); + + public string OfficialName => "Republic of Estonia"; + + public string NativeName => "Eesti"; + + public string Capital => "Tallinn"; + + public int NumericCode => 233; + + public string ISO2Code => "EE"; + + public string ISO3Code => "EST"; + + public string[] CallingCode => ["372"]; + + public IEnumerable States => + [ + 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") + ]; + } +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 9c15451..df31cc2 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -55,6 +55,29 @@ public static Dictionary Initialize() { CountryIdentifier.CocosKeelingIslands, new CocosKeelingIslands() }, { CountryIdentifier.Colombia, new Colombia() }, { CountryIdentifier.Comoros, new Comoros() }, + { CountryIdentifier.Congo, new Congo() }, + { CountryIdentifier.CostaRica, new CostaRica() }, + { CountryIdentifier.CookIslands, new CookIslands() }, + { CountryIdentifier.CoteDIvoire, new CoteDIvoire() }, + { CountryIdentifier.Croatia, new Croatia() }, + { CountryIdentifier.Cuba, new Cuba() }, + { CountryIdentifier.Curacao, new Curaçao() }, + { CountryIdentifier.Cyprus, new Cyprus() }, + { CountryIdentifier.CzechRepublic, new CzechRepublic() }, + { CountryIdentifier.Denmark, new Denmark() }, + { CountryIdentifier.Djibouti, new Djibouti() }, + { CountryIdentifier.Dominica, new Dominica() }, + { CountryIdentifier.DominicanRepublic, new DominicanRepublic() }, + { CountryIdentifier.TimorLeste, new TimorLeste() }, + { CountryIdentifier.Ecuador, new Ecuador() }, + { CountryIdentifier.Egypt, new Egypt() }, + { CountryIdentifier.Estonia, new Estonia() }, + { CountryIdentifier.FaroeIslands, new FaroeIslands() }, + { CountryIdentifier.FijiIslands, new FijiIslands() }, + { CountryIdentifier.Finland, new Finland() }, + { CountryIdentifier.France, new France() }, + { CountryIdentifier.FrenchGuiana, new FrenchGuiana() }, + { CountryIdentifier.FrenchPolynesia, new FrenchPolynesia() }, // Future countries can be added here in the same format. }; From 84bc92c0b7e6a03df0e29ecb23be2fd6b8753af6 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 11:40:34 +0100 Subject: [PATCH 02/14] initialize estonia --- src/World.Net/Helpers/CountryInitializer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index e898d83..dfc17e7 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -71,6 +71,7 @@ public static Dictionary Initialize() { CountryIdentifier.TimorLeste, new TimorLeste() }, { CountryIdentifier.Ecuador, new Ecuador() }, { CountryIdentifier.Egypt, new Egypt() }, + { CountryIdentifier.Estonia, new Estonia() }, { CountryIdentifier.FaroeIslands, new FaroeIslands() }, { CountryIdentifier.FijiIslands, new FijiIslands() }, { CountryIdentifier.Finland, new Finland() }, From 983c251ae4096d41e639e504423c2e7ce7873ab8 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 11:48:59 +0100 Subject: [PATCH 03/14] add Ethiopia details --- src/World.Net/Countries/Ethiopia.cs | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/World.Net/Countries/Ethiopia.cs diff --git a/src/World.Net/Countries/Ethiopia.cs b/src/World.Net/Countries/Ethiopia.cs new file mode 100644 index 0000000..2da8ab0 --- /dev/null +++ b/src/World.Net/Countries/Ethiopia.cs @@ -0,0 +1,39 @@ +namespace World.Net.Countries +{ + internal class Ethiopia : ICountry + { + public CountryIdentifier Id => CountryIdentifier.Ethiopia; + + public string Name => nameof(Ethiopia); + + public string OfficialName => "Federal Democratic Republic of Ethiopia"; + + public string NativeName => "ኢትዮጵያ"; + + public string Capital => "Addis Ababa"; + + public int NumericCode => 231; + + public string ISO2Code => "ET"; + + public string ISO3Code => "ETH"; + + public string[] CallingCode => ["251"]; + + public IEnumerable States => + [ + 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") + ]; + } +} From 42615bc4c833819428c001b97f84370fbf0bd42d Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 12:37:26 +0100 Subject: [PATCH 04/14] rename estonia test class --- .../Countries/{EstoniaTests.cs => EstoniaTest.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/World.Net.UnitTests/Countries/{EstoniaTests.cs => EstoniaTest.cs} (97%) diff --git a/src/World.Net.UnitTests/Countries/EstoniaTests.cs b/src/World.Net.UnitTests/Countries/EstoniaTest.cs similarity index 97% rename from src/World.Net.UnitTests/Countries/EstoniaTests.cs rename to src/World.Net.UnitTests/Countries/EstoniaTest.cs index 37c8b77..e9a235d 100644 --- a/src/World.Net.UnitTests/Countries/EstoniaTests.cs +++ b/src/World.Net.UnitTests/Countries/EstoniaTest.cs @@ -1,6 +1,6 @@ namespace World.Net.UnitTests.Countries { - public sealed class EstoniaTests + public sealed class EstoniaTest { private const string ESTONIA_NAME = "Estonia"; private const int ESTONIA_STATE_COUNT = 15; From 3ea2802d9c5504fc5d1ea0eade8a7c37113ddaff Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 12:41:10 +0100 Subject: [PATCH 05/14] add ethiopia test class --- .../Countries/EthiopiaTest.cs | 40 +++++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 1 + 2 files changed, 41 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/EthiopiaTest.cs diff --git a/src/World.Net.UnitTests/Countries/EthiopiaTest.cs b/src/World.Net.UnitTests/Countries/EthiopiaTest.cs new file mode 100644 index 0000000..606a0e9 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EthiopiaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class EthiopiaTest + { + 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"; + private const int ETHIOPIA_NUMERIC_CODE = 231; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEthiopia() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Ethiopia; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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); + } + } +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index dfc17e7..d4c47e5 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -72,6 +72,7 @@ public static Dictionary Initialize() { CountryIdentifier.Ecuador, new Ecuador() }, { CountryIdentifier.Egypt, new Egypt() }, { CountryIdentifier.Estonia, new Estonia() }, + { CountryIdentifier.Ethiopia, new Ethiopia() }, { CountryIdentifier.FaroeIslands, new FaroeIslands() }, { CountryIdentifier.FijiIslands, new FijiIslands() }, { CountryIdentifier.Finland, new Finland() }, From 511d7d2563a676066c24b2cca47d5231cd2294aa Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 13:14:31 +0100 Subject: [PATCH 06/14] add FalklandIslands details --- src/World.Net/Countries/FalklandIslands.cs | 29 +++++++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 1 + 2 files changed, 30 insertions(+) create mode 100644 src/World.Net/Countries/FalklandIslands.cs diff --git a/src/World.Net/Countries/FalklandIslands.cs b/src/World.Net/Countries/FalklandIslands.cs new file mode 100644 index 0000000..3a14e3b --- /dev/null +++ b/src/World.Net/Countries/FalklandIslands.cs @@ -0,0 +1,29 @@ +namespace World.Net.Countries +{ + internal class FalklandIslands : ICountry + { + public CountryIdentifier Id => CountryIdentifier.FalklandIslands; + + public string Name => nameof(FalklandIslands); + + public string OfficialName => "Falkland Islands"; + + public string NativeName => "Falkland Islands"; + + public string Capital => "Stanley"; + + public int NumericCode => 238; + + public string ISO2Code => "FK"; + + public string ISO3Code => "FLK"; + + public string[] CallingCode => ["500"]; + + public IEnumerable States => + [ + new("Falkland Islands", "FK", "Overseas Territory") + ]; + } + +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index d4c47e5..eab88eb 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -73,6 +73,7 @@ public static Dictionary Initialize() { CountryIdentifier.Egypt, new Egypt() }, { CountryIdentifier.Estonia, new Estonia() }, { CountryIdentifier.Ethiopia, new Ethiopia() }, + { CountryIdentifier.FalklandIslands, new FalklandIslands() }, { CountryIdentifier.FaroeIslands, new FaroeIslands() }, { CountryIdentifier.FijiIslands, new FijiIslands() }, { CountryIdentifier.Finland, new Finland() }, From ffe2b65d7a8caf1ac27e02e3c77d8893727f914d Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 13:14:40 +0100 Subject: [PATCH 07/14] add FalklandIslands tests --- .../Countries/FalklandIslandsTest.cs | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs diff --git a/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs b/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs new file mode 100644 index 0000000..c8c8d7d --- /dev/null +++ b/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace World.Net.UnitTests.Countries +{ + public sealed class FalklandIslandsTest + { + private const string FALKLANDS_NAME = "FalklandIslands"; + private const string FALKLANDS_OFFICIAL_NAME = "Falkland Islands"; + private const string FALKLANDS_NATIVE_NAME = "Falkland Islands"; + private const string FALKLANDS_CAPITAL = "Stanley"; + private const int FALKLANDS_NUMERIC_CODE = 238; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForFalklandIslands() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.FalklandIslands; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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); + } + } +} From 1c7d0b949e149759a8dd3640819e12ee2fd35862 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 13:19:58 +0100 Subject: [PATCH 08/14] add Eswatini --- src/World.Net/Countries/Estonia.cs | 2 +- src/World.Net/Countries/Eswatini.cs | 32 ++++++++++++++++++++++ src/World.Net/Countries/Ethiopia.cs | 2 +- src/World.Net/Countries/FalklandIslands.cs | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/World.Net/Countries/Eswatini.cs diff --git a/src/World.Net/Countries/Estonia.cs b/src/World.Net/Countries/Estonia.cs index 1361a74..162b4c8 100644 --- a/src/World.Net/Countries/Estonia.cs +++ b/src/World.Net/Countries/Estonia.cs @@ -1,7 +1,7 @@  namespace World.Net.Countries { - internal class Estonia : ICountry + internal sealed class Estonia : ICountry { public CountryIdentifier Id => CountryIdentifier.Estonia; diff --git a/src/World.Net/Countries/Eswatini.cs b/src/World.Net/Countries/Eswatini.cs new file mode 100644 index 0000000..9ecce67 --- /dev/null +++ b/src/World.Net/Countries/Eswatini.cs @@ -0,0 +1,32 @@ +namespace World.Net.Countries +{ + internal sealed class Eswatini : ICountry + { + public CountryIdentifier Id => CountryIdentifier.Eswatini; + + public string Name => nameof(Eswatini); + + public string OfficialName => "Kingdom of Eswatini"; + + public string NativeName => "eSwatini"; + + public string Capital => "Mbabane"; + + public int NumericCode => 748; + + public string ISO2Code => "SZ"; + + public string ISO3Code => "SWZ"; + + public string[] CallingCode => ["268"]; + + public IEnumerable States => + [ + new State("Hhohho", "HH", "Region"), + new State("Lubombo", "LU", "Region"), + new State("Manzini", "MA", "Region"), + new State("Shiselweni", "SH", "Region") + ]; + } + +} diff --git a/src/World.Net/Countries/Ethiopia.cs b/src/World.Net/Countries/Ethiopia.cs index 2da8ab0..4c74fc8 100644 --- a/src/World.Net/Countries/Ethiopia.cs +++ b/src/World.Net/Countries/Ethiopia.cs @@ -1,6 +1,6 @@ namespace World.Net.Countries { - internal class Ethiopia : ICountry + internal sealed class Ethiopia : ICountry { public CountryIdentifier Id => CountryIdentifier.Ethiopia; diff --git a/src/World.Net/Countries/FalklandIslands.cs b/src/World.Net/Countries/FalklandIslands.cs index 3a14e3b..765cad3 100644 --- a/src/World.Net/Countries/FalklandIslands.cs +++ b/src/World.Net/Countries/FalklandIslands.cs @@ -1,6 +1,6 @@ namespace World.Net.Countries { - internal class FalklandIslands : ICountry + internal sealed class FalklandIslands : ICountry { public CountryIdentifier Id => CountryIdentifier.FalklandIslands; From 0b6237ed512ec1ccf00c48da72e68997a13ca7d5 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 13:20:09 +0100 Subject: [PATCH 09/14] add Eswatini test class --- .../Countries/EswatiniTest.cs | 40 +++++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 1 + 2 files changed, 41 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/EswatiniTest.cs diff --git a/src/World.Net.UnitTests/Countries/EswatiniTest.cs b/src/World.Net.UnitTests/Countries/EswatiniTest.cs new file mode 100644 index 0000000..4ea9a4e --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EswatiniTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries +{ + public class EswatiniTest + { + private const string ESWATINI_NAME = "Eswatini"; + private const int ESWATINI_STATE_COUNT = 4; + private const string ESWATINI_OFFICIAL_NAME = "Kingdom of Eswatini"; + private const string ESWATINI_NATIVE_NAME = "eSwatini"; + private const string ESWATINI_CAPITAL = "Mbabane"; + private const int ESWATINI_NUMERIC_CODE = 748; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEswatini() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Eswatini; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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); + } + } +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index eab88eb..0f9c8e1 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -73,6 +73,7 @@ public static Dictionary Initialize() { CountryIdentifier.Egypt, new Egypt() }, { CountryIdentifier.Estonia, new Estonia() }, { CountryIdentifier.Ethiopia, new Ethiopia() }, + { CountryIdentifier.Eswatini, new Eswatini() }, { CountryIdentifier.FalklandIslands, new FalklandIslands() }, { CountryIdentifier.FaroeIslands, new FaroeIslands() }, { CountryIdentifier.FijiIslands, new FijiIslands() }, From 48b03669f7544f535eaf5c0fe3179b7b2eeb500d Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 17:52:40 +0100 Subject: [PATCH 10/14] add el salvador --- .../Countries/ElSalvadorTest.cs | 40 ++++++++++++++++++ src/World.Net/Countries/ElSalvador.cs | 41 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/ElSalvadorTest.cs create mode 100644 src/World.Net/Countries/ElSalvador.cs diff --git a/src/World.Net.UnitTests/Countries/ElSalvadorTest.cs b/src/World.Net.UnitTests/Countries/ElSalvadorTest.cs new file mode 100644 index 0000000..2093cb5 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ElSalvadorTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class ElSalvadorTest + { + 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"; + private const int ELSALVADOR_NUMERIC_CODE = 222; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForElSalvador() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.ElSalvador; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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); + } + } +} diff --git a/src/World.Net/Countries/ElSalvador.cs b/src/World.Net/Countries/ElSalvador.cs new file mode 100644 index 0000000..4b832bd --- /dev/null +++ b/src/World.Net/Countries/ElSalvador.cs @@ -0,0 +1,41 @@ +namespace World.Net.Countries +{ + internal class ElSalvador : ICountry + { + public CountryIdentifier Id => CountryIdentifier.ElSalvador; + + public string Name => nameof(ElSalvador); + + public string OfficialName => "Republic of El Salvador"; + + public string NativeName => "República de El Salvador"; + + public string Capital => "San Salvador"; + + public int NumericCode => 222; + + public string ISO2Code => "SV"; + + public string ISO3Code => "SLV"; + + public string[] CallingCode => ["503"]; + + public IEnumerable States => + [ + 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") + ]; + } +} From a6b7d9f84f23f8ca206259ce826a80e28b6db244 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 17:53:13 +0100 Subject: [PATCH 11/14] add equatorial --- .../Countries/EquatorialGuineaTest.cs | 41 +++++++++++++++++++ src/World.Net/Countries/EquatorialGuinea.cs | 36 ++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs create mode 100644 src/World.Net/Countries/EquatorialGuinea.cs diff --git a/src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs b/src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs new file mode 100644 index 0000000..5124266 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs @@ -0,0 +1,41 @@ +namespace World.Net.UnitTests.Countries +{ + public class EquatorialGuineaTest + { + 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"; + private const int EQUATORIALGUINEA_NUMERIC_CODE = 226; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEquatorialGuinea() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.EquatorialGuinea; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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); + } + + } +} diff --git a/src/World.Net/Countries/EquatorialGuinea.cs b/src/World.Net/Countries/EquatorialGuinea.cs new file mode 100644 index 0000000..1dede84 --- /dev/null +++ b/src/World.Net/Countries/EquatorialGuinea.cs @@ -0,0 +1,36 @@ +namespace World.Net.Countries +{ + internal sealed class EquatorialGuinea : ICountry + { + public CountryIdentifier Id => CountryIdentifier.EquatorialGuinea; + + public string Name => nameof(EquatorialGuinea); + + public string OfficialName => "Republic of Equatorial Guinea"; + + public string NativeName => "República de Guinea Ecuatorial"; + + public string Capital => "Malabo"; + + public int NumericCode => 226; + + public string ISO2Code => "GQ"; + + public string ISO3Code => "GNQ"; + + public string[] CallingCode => new[] { "240" }; + + public IEnumerable States => + [ + 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") + ]; + } + +} From ee912f3d3a24c9ebf30461dfc49b7c3d97ac9d19 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 17:53:30 +0100 Subject: [PATCH 12/14] add eritrea --- .../Countries/EritreaTest.cs | 46 +++++++++++++++++++ src/World.Net/Countries/Eritrea.cs | 34 ++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 3 ++ 3 files changed, 83 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/EritreaTest.cs create mode 100644 src/World.Net/Countries/Eritrea.cs diff --git a/src/World.Net.UnitTests/Countries/EritreaTest.cs b/src/World.Net.UnitTests/Countries/EritreaTest.cs new file mode 100644 index 0000000..f551075 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EritreaTest.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace World.Net.UnitTests.Countries +{ + public class EritreaTest + { + private const string ERITREA_NAME = "Eritrea"; + private const int ERITREA_STATE_COUNT = 6; + private const string ERITREA_OFFICIAL_NAME = "State of Eritrea"; + private const string ERITREA_NATIVE_NAME = "ሃገረ ኤርትራ"; + private const string ERITREA_CAPITAL = "Asmara"; + private const int ERITREA_NUMERIC_CODE = 232; + private const string ERITREA_ISO2_CODE = "ER"; + private const string ERITREA_ISO3_CODE = "ERI"; + private readonly string[] ERITREA_CALLING_CODE = ["291"]; + private static readonly string[] VALID_STATE_TYPES = { "Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEritrea() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Eritrea; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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); + } + } +} diff --git a/src/World.Net/Countries/Eritrea.cs b/src/World.Net/Countries/Eritrea.cs new file mode 100644 index 0000000..0722f30 --- /dev/null +++ b/src/World.Net/Countries/Eritrea.cs @@ -0,0 +1,34 @@ +namespace World.Net.Countries +{ + internal sealed class Eritrea : ICountry + { + public CountryIdentifier Id => CountryIdentifier.Eritrea; + + public string Name => nameof(Eritrea); + + public string OfficialName => "State of Eritrea"; + + public string NativeName => "ሃገረ ኤርትራ"; // Tigrinya: Hagere Ertra + + public string Capital => "Asmara"; + + public int NumericCode => 232; + + public string ISO2Code => "ER"; + + public string ISO3Code => "ERI"; + + public string[] CallingCode => ["291"]; + + public IEnumerable States => + [ + 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") + ]; + } + +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 0f9c8e1..ad7dd7c 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -71,6 +71,9 @@ public static Dictionary Initialize() { CountryIdentifier.TimorLeste, new TimorLeste() }, { CountryIdentifier.Ecuador, new Ecuador() }, { CountryIdentifier.Egypt, new Egypt() }, + { CountryIdentifier.ElSalvador, new ElSalvador() }, + { CountryIdentifier.EquatorialGuinea, new EquatorialGuinea() }, + { CountryIdentifier.Eritrea, new Eritrea() }, { CountryIdentifier.Estonia, new Estonia() }, { CountryIdentifier.Ethiopia, new Ethiopia() }, { CountryIdentifier.Eswatini, new Eswatini() }, From fd2f5051bc3a89069250860ef1a8e105aeead6a8 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 17:55:57 +0100 Subject: [PATCH 13/14] update initializer --- src/World.Net/Helpers/CountryInitializer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index b95ca29..7ceff95 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -71,16 +71,16 @@ public static Dictionary Initialize() { CountryIdentifier.TimorLeste, new TimorLeste() }, { CountryIdentifier.Ecuador, new Ecuador() }, { CountryIdentifier.Egypt, new Egypt() }, - { CountryIdentifier.Estonia, new Estonia() }, - { CountryIdentifier.Ethiopia, new Ethiopia() }, - { CountryIdentifier.Eswatini, new Eswatini() }, - { CountryIdentifier.FalklandIslands, new FalklandIslands() }, { CountryIdentifier.ElSalvador, new ElSalvador() }, { CountryIdentifier.EquatorialGuinea, new EquatorialGuinea() }, { CountryIdentifier.Eritrea, new Eritrea() }, { CountryIdentifier.Estonia, new Estonia() }, { CountryIdentifier.Ethiopia, new Ethiopia() }, { CountryIdentifier.Eswatini, new Eswatini() }, + { CountryIdentifier.FalklandIslands, new FalklandIslands() }, + { CountryIdentifier.Estonia, new Estonia() }, + { CountryIdentifier.Ethiopia, new Ethiopia() }, + { CountryIdentifier.Eswatini, new Eswatini() }, { CountryIdentifier.FalklandIslands, new FalklandIslands() }, { CountryIdentifier.FaroeIslands, new FaroeIslands() }, { CountryIdentifier.FijiIslands, new FijiIslands() }, From b04bd065f23c4902ab452571b843d811d32039fe Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 17:59:04 +0100 Subject: [PATCH 14/14] remove duplicate keys --- src/World.Net/Helpers/CountryInitializer.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 7ceff95..ad7dd7c 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -77,10 +77,6 @@ public static Dictionary Initialize() { CountryIdentifier.Estonia, new Estonia() }, { CountryIdentifier.Ethiopia, new Ethiopia() }, { CountryIdentifier.Eswatini, new Eswatini() }, - { CountryIdentifier.FalklandIslands, new FalklandIslands() }, - { CountryIdentifier.Estonia, new Estonia() }, - { CountryIdentifier.Ethiopia, new Ethiopia() }, - { CountryIdentifier.Eswatini, new Eswatini() }, { CountryIdentifier.FalklandIslands, new FalklandIslands() }, { CountryIdentifier.FaroeIslands, new FaroeIslands() }, { CountryIdentifier.FijiIslands, new FijiIslands() },