From e57de560b53d40d894637b901c9d57d329f2668a Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 24 May 2025 11:37:23 +0100 Subject: [PATCH 01/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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/44] 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() }, From 3d9de0c52378f4f056d1d50864db2f841df5fbc5 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 10 Sep 2025 10:47:29 +0100 Subject: [PATCH 15/44] add Kazakhstan details --- src/World.Net/Countries/Kazakhstan.cs | 53 +++++++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 3 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/World.Net/Countries/Kazakhstan.cs diff --git a/src/World.Net/Countries/Kazakhstan.cs b/src/World.Net/Countries/Kazakhstan.cs new file mode 100644 index 0000000..2fca4ee --- /dev/null +++ b/src/World.Net/Countries/Kazakhstan.cs @@ -0,0 +1,53 @@ +namespace World.Net.Countries; + +internal sealed class Kazakhstan : ICountry +{ + /// + public CountryIdentifier Id => CountryIdentifier.Kazakhstan; + + /// + public string Name => "Kazakhstan"; + + /// + public string OfficialName { get; } = "Republic of Kazakhstan"; + + /// + public string NativeName { get; } = "?????????"; + + /// + public string Capital { get; } = "Astana"; + + /// + public int NumericCode { get; } = 398; + + /// + public string ISO2Code { get; } = "KZ"; + + /// + public string ISO3Code { get; } = "KAZ"; + + /// + public string[] CallingCode { get; } = ["+7"]; + + /// + public IEnumerable States { get; } = + [ + new("Akmola", "KZ-AKM", "Region"), + new("Aktobe", "KZ-AKT", "Region"), + new("Almaty", "KZ-ALM", "Region"), + new("Atyrau", "KZ-ATY", "Region"), + new("East Kazakhstan", "KZ-VOS", "Region"), + new("Jambyl", "KZ-ZHA", "Region"), + new("Karaganda", "KZ-KAR", "Region"), + new("Kostanay", "KZ-KUS", "Region"), + new("Kyzylorda", "KZ-KZY", "Region"), + new("Mangystau", "KZ-MAN", "Region"), + new("Pavlodar", "KZ-PAV", "Region"), + new("North Kazakhstan", "KZ-SEV", "Region"), + new("Turkistan", "KZ-TUR", "Region"), + new("West Kazakhstan", "KZ-ZAP", "Region"), + new("Nur-Sultan", "KZ-NUR", "City"), + new("Almaty City", "KZ-ALA", "City"), + new("Shymkent", "KZ-SHY", "City") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 673508c..ed66e81 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -91,7 +91,8 @@ public static Dictionary Initialize() { CountryIdentifier.Jamaica, new Jamaica() }, { CountryIdentifier.Japan, new Japan() }, { CountryIdentifier.Jersey, new Jersey() }, - { CountryIdentifier.Jordan, new Jordan() } + { CountryIdentifier.Jordan, new Jordan() }, + { CountryIdentifier.Kazakhstan, new World.Net.Countries.Kazakhstan() } // Future countries can be added here in the same format. }; From fb386cf5a9573f9a8ea18e40f4604d68eef47ef2 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 10 Sep 2025 10:47:44 +0100 Subject: [PATCH 16/44] add unit tests for Kazakhstan --- .../Countries/KazakhstanTest.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/KazakhstanTest.cs diff --git a/src/World.Net.UnitTests/Countries/KazakhstanTest.cs b/src/World.Net.UnitTests/Countries/KazakhstanTest.cs new file mode 100644 index 0000000..d498c7d --- /dev/null +++ b/src/World.Net.UnitTests/Countries/KazakhstanTest.cs @@ -0,0 +1,47 @@ +namespace World.Net.UnitTests.Countries; + +internal static class KazakhstanTestData +{ + 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; +} + +public sealed class KazakhstanTest +{ + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForKazakhstan() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Kazakhstan; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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)); + } +} From 47bb5a30275e642ffb80ef4e1756d876e1c48b70 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 10 Sep 2025 11:08:52 +0100 Subject: [PATCH 17/44] update initializer --- src/World.Net/Helpers/CountryInitializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index ed66e81..2b22923 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -92,7 +92,7 @@ public static Dictionary Initialize() { CountryIdentifier.Japan, new Japan() }, { CountryIdentifier.Jersey, new Jersey() }, { CountryIdentifier.Jordan, new Jordan() }, - { CountryIdentifier.Kazakhstan, new World.Net.Countries.Kazakhstan() } + { CountryIdentifier.Kazakhstan, new Kazakhstan() } // Future countries can be added here in the same format. }; From ac0b1d40b7ef4dfe84612be0bb70ec749f686f5e Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 09:29:55 +0100 Subject: [PATCH 18/44] update copilot prompt file --- src/.copilot/generate-country.prompt.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/.copilot/generate-country.prompt.md b/src/.copilot/generate-country.prompt.md index 99b4b14..5610f3f 100644 --- a/src/.copilot/generate-country.prompt.md +++ b/src/.copilot/generate-country.prompt.md @@ -29,6 +29,7 @@ When you are asked to "create a country": - Use immutable properties (fixed values, no setters). - Use the correct `CountryIdentifier.` for `Id`. - All data must be ISO/UN recognized and complete. + - **When generating the `States` property, always provide the type for each state object (e.g., `new State("Kakamega", "KE-11", "County")`). Do not omit the type argument, except if the type is exactly `"Province"` (the default), in which case you may skip it.** 4. **Register in CountryInitializer** - Add the new country to `CountryInitializer.Initialize()` in `src/World.Net/Helpers/CountryInitializer.cs`. @@ -96,6 +97,7 @@ src/World.Net.UnitTests/Countries/NigeriaTest.cs - Follow the naming and ordering conventions strictly. - Use only ISO/UN official data for all country properties. - If a country has subdivisions (states, provinces, etc.), list them in the `States` property using the correct type and ISO codes. +- **Always provide the type argument for each state in the `States` property, unless the type is exactly `"Province"` (the default), in which case you may skip it.** - If you are unsure about a country's data, do not create a placeholderskip or request clarification. --- From 4e10df5968cc53d72898504d8b9c0ec5da02da41 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 09:32:01 +0100 Subject: [PATCH 19/44] add kenya details --- .../Countries/KenyaTest.cs | 43 +++++++++++ src/World.Net/Countries/Kenya.cs | 73 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/KenyaTest.cs create mode 100644 src/World.Net/Countries/Kenya.cs diff --git a/src/World.Net.UnitTests/Countries/KenyaTest.cs b/src/World.Net.UnitTests/Countries/KenyaTest.cs new file mode 100644 index 0000000..1c537fd --- /dev/null +++ b/src/World.Net.UnitTests/Countries/KenyaTest.cs @@ -0,0 +1,43 @@ +using World.Net; +using World.Net.Helpers; + +namespace World.Net.UnitTests.Countries; + +public sealed class KenyaTest +{ + private const string KENYA_COUNTRY_NAME = "Kenya"; + private const string KENYA_NATIVE_NAME = "Kenya"; + private const string KENYA_CAPITAL = "Nairobi"; + private const string KENYA_OFFICIAL_NAME = "Republic of Kenya"; + private const string KENYA_ISO2_CODE = "KE"; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForKenya() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Kenya; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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)); + } +} diff --git a/src/World.Net/Countries/Kenya.cs b/src/World.Net/Countries/Kenya.cs new file mode 100644 index 0000000..2800ae3 --- /dev/null +++ b/src/World.Net/Countries/Kenya.cs @@ -0,0 +1,73 @@ +namespace World.Net.Countries; + +internal sealed class Kenya : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Kenya; + + public string Name => "Kenya"; + + public string OfficialName => "Republic of Kenya"; + + public string NativeName => "Kenya"; + + public string Capital => "Nairobi"; + + public int NumericCode => 404; + + public string ISO2Code => "KE"; + + public string ISO3Code => "KEN"; + + public string[] CallingCode => ["+254"]; + + public IEnumerable States => + [ + new("Baringo", "KE-01", "County"), + new("Bomet", "KE-02", "County"), + new("Bungoma", "KE-03", "County"), + new("Busia", "KE-04", "County"), + new("Elgeyo-Marakwet", "KE-05", "County"), + new("Embu", "KE-06", "County"), + new("Garissa", "KE-07", "County"), + new("Homa Bay", "KE-08", "County"), + new("Isiolo", "KE-09", "County"), + new("Kajiado", "KE-10", "County"), + new("Kakamega", "KE-11", "County"), + new("Kericho", "KE-12", "County"), + new("Kiambu", "KE-13", "County"), + new("Kilifi", "KE-14", "County"), + new("Kirinyaga", "KE-15", "County"), + new("Kisii", "KE-16", "County"), + new("Kisumu", "KE-17", "County"), + new("Kitui", "KE-18", "County"), + new("Kwale", "KE-19", "County"), + new("Laikipia", "KE-20", "County"), + new("Lamu", "KE-21", "County"), + new("Machakos", "KE-22", "County"), + new("Makueni", "KE-23", "County"), + new("Mandera", "KE-24", "County"), + new("Marsabit", "KE-25", "County"), + new("Meru", "KE-26", "County"), + new("Migori", "KE-27", "County"), + new("Mombasa", "KE-28", "County"), + new("Murang'a", "KE-29", "County"), + new("Nairobi City", "KE-30", "County"), + new("Nakuru", "KE-31", "County"), + new("Nandi", "KE-32", "County"), + new("Narok", "KE-33", "County"), + new("Nyamira", "KE-34", "County"), + new("Nyandarua", "KE-35", "County"), + new("Nyeri", "KE-36", "County"), + new("Samburu", "KE-37", "County"), + new("Siaya", "KE-38", "County"), + new("Taita-Taveta", "KE-39", "County"), + new("Tana River", "KE-40", "County"), + new("Tharaka-Nithi", "KE-41", "County"), + new("Trans Nzoia", "KE-42", "County"), + new("Turkana", "KE-43", "County"), + new("Uasin Gishu", "KE-44", "County"), + new("Vihiga", "KE-45", "County"), + new("Wajir", "KE-46", "County"), + new("West Pokot", "KE-47", "County") + ]; +} From 9807581fb3f215a4de04e868235efab1e8181940 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 09:32:20 +0100 Subject: [PATCH 20/44] initialize kenya --- src/World.Net/Helpers/CountryInitializer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 2b22923..a0f93a1 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -92,7 +92,8 @@ public static Dictionary Initialize() { CountryIdentifier.Japan, new Japan() }, { CountryIdentifier.Jersey, new Jersey() }, { CountryIdentifier.Jordan, new Jordan() }, - { CountryIdentifier.Kazakhstan, new Kazakhstan() } + { CountryIdentifier.Kazakhstan, new Kazakhstan() }, + { CountryIdentifier.Kenya, new Kenya() }, // Future countries can be added here in the same format. }; From 3b8b3de95e22c763be03b720c5bbab9ac7a61ab7 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 09:44:00 +0100 Subject: [PATCH 21/44] add kiribati details --- .../Countries/KiribatiTest.cs | 43 +++++++++++++++++++ src/World.Net/Countries/Kiribati.cs | 20 +++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/KiribatiTest.cs create mode 100644 src/World.Net/Countries/Kiribati.cs diff --git a/src/World.Net.UnitTests/Countries/KiribatiTest.cs b/src/World.Net.UnitTests/Countries/KiribatiTest.cs new file mode 100644 index 0000000..4997171 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/KiribatiTest.cs @@ -0,0 +1,43 @@ +using World.Net; +using World.Net.Helpers; + +namespace World.Net.UnitTests.Countries; + +public sealed class KiribatiTest +{ + private const string KIRIBATI_COUNTRY_NAME = "Kiribati"; + private const string KIRIBATI_NATIVE_NAME = "Kiribati"; + private const string KIRIBATI_CAPITAL = "South Tarawa"; + private const string KIRIBATI_OFFICIAL_NAME = "Republic of Kiribati"; + private const string KIRIBATI_ISO2_CODE = "KI"; + 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" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForKiribati() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Kiribati; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // 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)); + } +} diff --git a/src/World.Net/Countries/Kiribati.cs b/src/World.Net/Countries/Kiribati.cs new file mode 100644 index 0000000..64de137 --- /dev/null +++ b/src/World.Net/Countries/Kiribati.cs @@ -0,0 +1,20 @@ +namespace World.Net.Countries; + +internal sealed class Kiribati : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Kiribati; + public string Name => "Kiribati"; + public string OfficialName => "Republic of Kiribati"; + public string NativeName => "Kiribati"; + public string Capital => "South Tarawa"; + public int NumericCode => 296; + public string ISO2Code => "KI"; + public string ISO3Code => "KIR"; + public string[] CallingCode => ["+686"]; + public IEnumerable States => + [ + new("Gilbert Islands", "KI-G", "Group"), + new("Line Islands", "KI-L", "Group"), + new("Phoenix Islands", "KI-P", "Group") + ]; +} From 979b905e65991f103fafdfc1c2aca92f8132cc51 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 09:44:09 +0100 Subject: [PATCH 22/44] initialize kiribati --- 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 a0f93a1..0f76427 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -94,6 +94,7 @@ public static Dictionary Initialize() { CountryIdentifier.Jordan, new Jordan() }, { CountryIdentifier.Kazakhstan, new Kazakhstan() }, { CountryIdentifier.Kenya, new Kenya() }, + { CountryIdentifier.Kiribati, new Kiribati() }, // Future countries can be added here in the same format. }; From fd6963bbfd75778883a661044bf6fddc919487cb Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 12:19:24 +0100 Subject: [PATCH 23/44] add kosovo details --- src/World.Net/Countries/Kosovo.cs | 44 +++++++++++++++++++++ src/World.Net/Helpers/CountryIdentifier.cs | 18 ++++----- src/World.Net/Helpers/CountryInitializer.cs | 1 + 3 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 src/World.Net/Countries/Kosovo.cs diff --git a/src/World.Net/Countries/Kosovo.cs b/src/World.Net/Countries/Kosovo.cs new file mode 100644 index 0000000..1921937 --- /dev/null +++ b/src/World.Net/Countries/Kosovo.cs @@ -0,0 +1,44 @@ +namespace World.Net.Countries +{ + internal sealed class Kosovo : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.Kosovo; + + /// + public string Name => "Kosovo"; + + /// + public string OfficialName { get; } = "Republic of Kosovo"; + + /// + public string NativeName { get; } = "Republika e Kosovs"; + + /// + public string Capital { get; } = "Pristina"; + + /// + public int NumericCode { get; } = 383; + + /// + public string ISO2Code { get; } = "XK"; + + /// + public string ISO3Code { get; } = "XKX"; + + /// + public string[] CallingCode { get; } = ["+383"]; + + /// + public IEnumerable States { get; } = + [ + new State("Ferizaj", "XK-05", "District"), + new State("Gjakov", "XK-06", "District"), + new State("Gjilan", "XK-07", "District"), + new State("Mitrovic", "XK-03", "District"), + new State("Pej", "XK-02", "District"), + new State("Prishtin", "XK-01", "District"), + new State("Prizren", "XK-04", "District") + ]; + } +} diff --git a/src/World.Net/Helpers/CountryIdentifier.cs b/src/World.Net/Helpers/CountryIdentifier.cs index 446d70b..a56af6e 100644 --- a/src/World.Net/Helpers/CountryIdentifier.cs +++ b/src/World.Net/Helpers/CountryIdentifier.cs @@ -922,6 +922,14 @@ public enum CountryIdentifier /// Kiribati, + /// + /// The unique identifier for Kosovo. + /// + /// + /// Use this identifier to reference Kosovo in operations that require a country ID. + /// + Kosovo, + /// /// The unique identifier for North Korea. /// @@ -1981,15 +1989,7 @@ public enum CountryIdentifier /// /// Use this identifier to reference Zimbabwe in operations that require a country ID. /// - Zimbabwe, - - /// - /// The unique identifier for Kosovo. - /// - /// - /// Use this identifier to reference Kosovo in operations that require a country ID. - /// - Kosovo, + Zimbabwe, /// /// The unique identifier for Curaçao. diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 0f76427..aabe0ed 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -95,6 +95,7 @@ public static Dictionary Initialize() { CountryIdentifier.Kazakhstan, new Kazakhstan() }, { CountryIdentifier.Kenya, new Kenya() }, { CountryIdentifier.Kiribati, new Kiribati() }, + { CountryIdentifier.Kosovo, new Kosovo() }, // Future countries can be added here in the same format. }; From 4b3e1e360a36d9730828d62aa8d1337ff1494b32 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 12:20:14 +0100 Subject: [PATCH 24/44] add unit test for kosovo --- .../Countries/KosovoTest.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/KosovoTest.cs diff --git a/src/World.Net.UnitTests/Countries/KosovoTest.cs b/src/World.Net.UnitTests/Countries/KosovoTest.cs new file mode 100644 index 0000000..2e2cd1a --- /dev/null +++ b/src/World.Net.UnitTests/Countries/KosovoTest.cs @@ -0,0 +1,54 @@ +using World.Net; +using World.Net.Countries; +using World.Net.Helpers; +using Xunit; + +namespace World.Net.UnitTests.Countries +{ + public class KosovoTest + { + private const CountryIdentifier ExpectedId = CountryIdentifier.Kosovo; + private const string ExpectedName = "Kosovo"; + private const string ExpectedOfficialName = "Republic of Kosovo"; + private const string ExpectedNativeName = "Republika e Kosovs"; + private const string ExpectedCapital = "Pristina"; + private const int ExpectedNumericCode = 383; + private const string ExpectedISO2Code = "XK"; + private const string ExpectedISO3Code = "XKX"; + private static readonly string[] ExpectedCallingCode = ["+383"]; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Ferizaj", "XK-05", "District"), + ("Gjakov", "XK-06", "District"), + ("Gjilan", "XK-07", "District"), + ("Mitrovic", "XK-03", "District"), + ("Pej", "XK-02", "District"), + ("Prishtin", "XK-01", "District"), + ("Prizren", "XK-04", "District") + ]; + + [Fact] + 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); + } + } + } +} From c64f018b59b39bed14ffe616eceb30b5bedd92f3 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 12:25:56 +0100 Subject: [PATCH 25/44] add kuwait --- .../Countries/KuwaitTest.cs | 53 +++++++++++++++++++ src/World.Net/Countries/Kuwait.cs | 23 ++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/KuwaitTest.cs create mode 100644 src/World.Net/Countries/Kuwait.cs diff --git a/src/World.Net.UnitTests/Countries/KuwaitTest.cs b/src/World.Net.UnitTests/Countries/KuwaitTest.cs new file mode 100644 index 0000000..d58bb06 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/KuwaitTest.cs @@ -0,0 +1,53 @@ +using World.Net; +using World.Net.Countries; +using World.Net.Helpers; +using Xunit; + +namespace World.Net.UnitTests.Countries +{ + public class KuwaitTest + { + private const CountryIdentifier ExpectedId = CountryIdentifier.Kuwait; + private const string ExpectedName = "Kuwait"; + private const string ExpectedOfficialName = "State of Kuwait"; + private const string ExpectedNativeName = "???? ??????"; + private const string ExpectedCapital = "Kuwait City"; + private const int ExpectedNumericCode = 414; + private const string ExpectedISO2Code = "KW"; + private const string ExpectedISO3Code = "KWT"; + private static readonly string[] ExpectedCallingCode = ["+965"]; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Al Ahmadi", "KW-AH", "Governorate"), + ("Al Farwaniyah", "KW-FA", "Governorate"), + ("Al Asimah", "KW-KU", "Governorate"), + ("Al Jahra", "KW-JA", "Governorate"), + ("Hawalli", "KW-HA", "Governorate"), + ("Mubarak Al-Kabeer", "KW-MU", "Governorate") + ]; + + [Fact] + 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); + } + } + } +} diff --git a/src/World.Net/Countries/Kuwait.cs b/src/World.Net/Countries/Kuwait.cs new file mode 100644 index 0000000..77df2bf --- /dev/null +++ b/src/World.Net/Countries/Kuwait.cs @@ -0,0 +1,23 @@ +namespace World.Net.Countries; + +internal sealed class Kuwait : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Kuwait; + public string Name { get; } = "Kuwait"; + public string OfficialName { get; } = "State of Kuwait"; + public string NativeName { get; } = "???? ??????"; + public string Capital { get; } = "Kuwait City"; + public int NumericCode { get; } = 414; + public string ISO2Code { get; } = "KW"; + public string ISO3Code { get; } = "KWT"; + public string[] CallingCode { get; } = ["+965"]; + public IEnumerable States { get; } = + [ + new State("Al Ahmadi", "KW-AH", "Governorate"), + new State("Al Farwaniyah", "KW-FA", "Governorate"), + new State("Al Asimah", "KW-KU", "Governorate"), + new State("Al Jahra", "KW-JA", "Governorate"), + new State("Hawalli", "KW-HA", "Governorate"), + new State("Mubarak Al-Kabeer", "KW-MU", "Governorate") + ]; +} From 19cf6c4961590494ad072f79d90df325c4b3090a Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 12:26:16 +0100 Subject: [PATCH 26/44] add Kyrgyzstan --- .../Countries/KyrgyzstanTest.cs | 56 +++++++++++++++++++ src/World.Net/Countries/Kyrgyzstan.cs | 26 +++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs create mode 100644 src/World.Net/Countries/Kyrgyzstan.cs diff --git a/src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs b/src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs new file mode 100644 index 0000000..03db25b --- /dev/null +++ b/src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs @@ -0,0 +1,56 @@ +using World.Net; +using World.Net.Countries; +using World.Net.Helpers; +using Xunit; + +namespace World.Net.UnitTests.Countries +{ + public class KyrgyzstanTest + { + private const CountryIdentifier ExpectedId = CountryIdentifier.Kyrgyzstan; + private const string ExpectedName = "Kyrgyzstan"; + private const string ExpectedOfficialName = "Kyrgyz Republic"; + private const string ExpectedNativeName = "?????? ????????????"; + private const string ExpectedCapital = "Bishkek"; + private const int ExpectedNumericCode = 417; + private const string ExpectedISO2Code = "KG"; + private const string ExpectedISO3Code = "KGZ"; + private static readonly string[] ExpectedCallingCode = ["+996"]; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Batken", "KG-B", "Region"), + ("Chuy", "KG-C", "Region"), + ("Jalal-Abad", "KG-J", "Region"), + ("Naryn", "KG-N", "Region"), + ("Osh", "KG-O", "Region"), + ("Talas", "KG-T", "Region"), + ("Ysyk-Kol", "KG-Y", "Region"), + ("Bishkek", "KG-GB", "City"), + ("Osh City", "KG-GO", "City") + ]; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForKyrgyzstan() + { + 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); + } + } + } +} diff --git a/src/World.Net/Countries/Kyrgyzstan.cs b/src/World.Net/Countries/Kyrgyzstan.cs new file mode 100644 index 0000000..ac1d004 --- /dev/null +++ b/src/World.Net/Countries/Kyrgyzstan.cs @@ -0,0 +1,26 @@ +namespace World.Net.Countries; + +internal sealed class Kyrgyzstan : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Kyrgyzstan; + public string Name { get; } = "Kyrgyzstan"; + public string OfficialName { get; } = "Kyrgyz Republic"; + public string NativeName { get; } = "?????? ????????????"; + public string Capital { get; } = "Bishkek"; + public int NumericCode { get; } = 417; + public string ISO2Code { get; } = "KG"; + public string ISO3Code { get; } = "KGZ"; + public string[] CallingCode { get; } = ["+996"]; + public IEnumerable States { get; } = + [ + new State("Batken", "KG-B", "Region"), + new State("Chuy", "KG-C", "Region"), + new State("Jalal-Abad", "KG-J", "Region"), + new State("Naryn", "KG-N", "Region"), + new State("Osh", "KG-O", "Region"), + new State("Talas", "KG-T", "Region"), + new State("Ysyk-Kol", "KG-Y", "Region"), + new State("Bishkek", "KG-GB", "City"), + new State("Osh City", "KG-GO", "City") + ]; +} From 290a1dad0f1625c56baef1c7f3fece1719ddb614 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 12:26:25 +0100 Subject: [PATCH 27/44] initialize states --- src/World.Net/Helpers/CountryInitializer.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index aabe0ed..fe1834b 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -96,6 +96,8 @@ public static Dictionary Initialize() { CountryIdentifier.Kenya, new Kenya() }, { CountryIdentifier.Kiribati, new Kiribati() }, { CountryIdentifier.Kosovo, new Kosovo() }, + { CountryIdentifier.Kuwait, new Kuwait() }, + { CountryIdentifier.Kyrgyzstan, new Kyrgyzstan() }, // Future countries can be added here in the same format. }; From 41a3bdce9ee0b8b6cb1741980302ba60188098ca Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 12:39:17 +0100 Subject: [PATCH 28/44] update tests --- src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs | 6 +++--- src/World.Net/Countries/Kyrgyzstan.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs b/src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs index 03db25b..71b958a 100644 --- a/src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs +++ b/src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs @@ -1,4 +1,4 @@ -using World.Net; +using World.Net; using World.Net.Countries; using World.Net.Helpers; using Xunit; @@ -10,7 +10,7 @@ public class KyrgyzstanTest private const CountryIdentifier ExpectedId = CountryIdentifier.Kyrgyzstan; private const string ExpectedName = "Kyrgyzstan"; private const string ExpectedOfficialName = "Kyrgyz Republic"; - private const string ExpectedNativeName = "?????? ????????????"; + private const string ExpectedNativeName = "Киргизская Республика"; private const string ExpectedCapital = "Bishkek"; private const int ExpectedNumericCode = 417; private const string ExpectedISO2Code = "KG"; @@ -24,7 +24,7 @@ private static readonly (string Name, string IsoCode, string Type)[] ExpectedSta ("Naryn", "KG-N", "Region"), ("Osh", "KG-O", "Region"), ("Talas", "KG-T", "Region"), - ("Ysyk-Kol", "KG-Y", "Region"), + ("Issyk-Kul", "KG-Y", "Region"), ("Bishkek", "KG-GB", "City"), ("Osh City", "KG-GO", "City") ]; diff --git a/src/World.Net/Countries/Kyrgyzstan.cs b/src/World.Net/Countries/Kyrgyzstan.cs index ac1d004..a71586e 100644 --- a/src/World.Net/Countries/Kyrgyzstan.cs +++ b/src/World.Net/Countries/Kyrgyzstan.cs @@ -1,11 +1,11 @@ -namespace World.Net.Countries; +namespace World.Net.Countries; internal sealed class Kyrgyzstan : ICountry { public CountryIdentifier Id => CountryIdentifier.Kyrgyzstan; public string Name { get; } = "Kyrgyzstan"; public string OfficialName { get; } = "Kyrgyz Republic"; - public string NativeName { get; } = "?????? ????????????"; + public string NativeName { get; } = "Киргизская Республика"; public string Capital { get; } = "Bishkek"; public int NumericCode { get; } = 417; public string ISO2Code { get; } = "KG"; @@ -19,7 +19,7 @@ internal sealed class Kyrgyzstan : ICountry new State("Naryn", "KG-N", "Region"), new State("Osh", "KG-O", "Region"), new State("Talas", "KG-T", "Region"), - new State("Ysyk-Kol", "KG-Y", "Region"), + new State("Issyk-Kul", "KG-Y", "Region"), new State("Bishkek", "KG-GB", "City"), new State("Osh City", "KG-GO", "City") ]; From e064106f71826d34f60ca64e8592cf48f806467e Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 11 Sep 2025 14:34:55 +0100 Subject: [PATCH 29/44] update kuwait --- src/World.Net.UnitTests/Countries/KuwaitTest.cs | 4 ++-- src/World.Net/Countries/Kuwait.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/KuwaitTest.cs b/src/World.Net.UnitTests/Countries/KuwaitTest.cs index d58bb06..98c8c08 100644 --- a/src/World.Net.UnitTests/Countries/KuwaitTest.cs +++ b/src/World.Net.UnitTests/Countries/KuwaitTest.cs @@ -1,4 +1,4 @@ -using World.Net; +using World.Net; using World.Net.Countries; using World.Net.Helpers; using Xunit; @@ -10,7 +10,7 @@ public class KuwaitTest private const CountryIdentifier ExpectedId = CountryIdentifier.Kuwait; private const string ExpectedName = "Kuwait"; private const string ExpectedOfficialName = "State of Kuwait"; - private const string ExpectedNativeName = "???? ??????"; + private const string ExpectedNativeName = "دولة الكويت"; private const string ExpectedCapital = "Kuwait City"; private const int ExpectedNumericCode = 414; private const string ExpectedISO2Code = "KW"; diff --git a/src/World.Net/Countries/Kuwait.cs b/src/World.Net/Countries/Kuwait.cs index 77df2bf..e01047c 100644 --- a/src/World.Net/Countries/Kuwait.cs +++ b/src/World.Net/Countries/Kuwait.cs @@ -1,11 +1,11 @@ -namespace World.Net.Countries; +namespace World.Net.Countries; internal sealed class Kuwait : ICountry { public CountryIdentifier Id => CountryIdentifier.Kuwait; public string Name { get; } = "Kuwait"; public string OfficialName { get; } = "State of Kuwait"; - public string NativeName { get; } = "???? ??????"; + public string NativeName { get; } = "دولة الكويت"; public string Capital { get; } = "Kuwait City"; public int NumericCode { get; } = 414; public string ISO2Code { get; } = "KW"; From b184d48bd8562437c2f37cf9cfb5e23278a49030 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 4 Oct 2025 23:46:09 +0100 Subject: [PATCH 30/44] remove unused --- src/World.Net.UnitTests/Countries/KuwaitTest.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/KuwaitTest.cs b/src/World.Net.UnitTests/Countries/KuwaitTest.cs index 98c8c08..58a97c1 100644 --- a/src/World.Net.UnitTests/Countries/KuwaitTest.cs +++ b/src/World.Net.UnitTests/Countries/KuwaitTest.cs @@ -1,9 +1,4 @@ -using World.Net; -using World.Net.Countries; -using World.Net.Helpers; -using Xunit; - -namespace World.Net.UnitTests.Countries +namespace World.Net.UnitTests.Countries { public class KuwaitTest { From eb96384f3fab7ed64d8cef8760edf5fba35c00a4 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 8 Oct 2025 23:58:57 +0100 Subject: [PATCH 31/44] add loas --- src/World.Net/Countries/Laos.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/World.Net/Countries/Laos.cs diff --git a/src/World.Net/Countries/Laos.cs b/src/World.Net/Countries/Laos.cs new file mode 100644 index 0000000..664a926 --- /dev/null +++ b/src/World.Net/Countries/Laos.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace World.Net.Countries +{ + internal class Laos + { + } +} From efab5757cea8278da0346c3d987b9f2017bf238b Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 8 Oct 2025 23:59:28 +0100 Subject: [PATCH 32/44] add loas --- src/World.Net/Countries/Laos.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/World.Net/Countries/Laos.cs b/src/World.Net/Countries/Laos.cs index 664a926..89e6a4a 100644 --- a/src/World.Net/Countries/Laos.cs +++ b/src/World.Net/Countries/Laos.cs @@ -4,7 +4,7 @@ namespace World.Net.Countries { - internal class Laos + public sealed class Laos : ICountry { } } From 14b28b3060dbb92004de478efc1093edb21a4f8e Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Wed, 8 Oct 2025 23:59:54 +0100 Subject: [PATCH 33/44] remove unused using --- src/World.Net/Countries/Laos.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/World.Net/Countries/Laos.cs b/src/World.Net/Countries/Laos.cs index 89e6a4a..02a911f 100644 --- a/src/World.Net/Countries/Laos.cs +++ b/src/World.Net/Countries/Laos.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace World.Net.Countries +namespace World.Net.Countries { public sealed class Laos : ICountry { From c43d80e35986e56af277efbd80248e9e16412208 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 00:10:58 +0100 Subject: [PATCH 34/44] add full details for Laos --- src/World.Net/Countries/Laos.cs | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/World.Net/Countries/Laos.cs b/src/World.Net/Countries/Laos.cs index 02a911f..3a4879b 100644 --- a/src/World.Net/Countries/Laos.cs +++ b/src/World.Net/Countries/Laos.cs @@ -1,6 +1,55 @@ namespace World.Net.Countries { - public sealed class Laos : ICountry + internal sealed class Laos : ICountry { + /// + public CountryIdentifier Id => CountryIdentifier.Laos; + + /// + public string Name { get; } = "Laos"; + + /// + public string OfficialName { get; } = "Lao People's Democratic Republic"; + + /// + public string NativeName { get; } = "ສາທາລະນະລັດ ປະຊາຊົນລາວ"; + + /// + public string Capital { get; } = "Vientiane"; + + /// + public int NumericCode { get; } = 418; + + /// + public string ISO2Code { get; } = "LA"; + + /// + public string ISO3Code { get; } = "LAO"; + + /// + public string[] CallingCode { get; } = ["+856"]; + + public IEnumerable States { get; } = + [ + new("Attapeu", "LA-AT"), + new("Bokeo", "LA-BK"), + new("Bolikhamxai", "LA-BL"), + new("Champasak", "LA-CH"), + new("Houaphan", "LA-HO"), + new("Khammouan", "LA-KH"), + new("Luang Namtha", "LA-LM"), + new("Luang Prabang", "LA-LP"), + new("Oudomxai", "LA-OU"), + new("Phongsaly", "LA-PH"), + new("Salavan", "LA-SL"), + new("Savannakhét", "LA-SV"), + new("Sekong", "LA-XE"), + new("Vientiane Province", "LA-VI"), + new("Vientiane Prefecture", "LA-VT", "Prefecture"), + new("Xaignabouli", "LA-XA"), + new("Xaisomboun", "LA-XN"), + new("Xiangkhouang", "LA-XI") + ]; } + } From 0eea0f070bc0a7aad02deba13514b140912f6865 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 00:11:10 +0100 Subject: [PATCH 35/44] initalize laos --- 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 fe1834b..7439f40 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -98,6 +98,7 @@ public static Dictionary Initialize() { CountryIdentifier.Kosovo, new Kosovo() }, { CountryIdentifier.Kuwait, new Kuwait() }, { CountryIdentifier.Kyrgyzstan, new Kyrgyzstan() }, + { CountryIdentifier.Laos, new Laos() }, // Future countries can be added here in the same format. }; From e2b95da002deca9c0e2b2c7a627b0c5cb36675c1 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 00:11:21 +0100 Subject: [PATCH 36/44] add laos unit tests --- src/World.Net.UnitTests/Countries/LaosTest.cs | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/LaosTest.cs diff --git a/src/World.Net.UnitTests/Countries/LaosTest.cs b/src/World.Net.UnitTests/Countries/LaosTest.cs new file mode 100644 index 0000000..4b2bcfa --- /dev/null +++ b/src/World.Net.UnitTests/Countries/LaosTest.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace World.Net.UnitTests.Countries +{ + public class LaosTest + { + private const CountryIdentifier ExpectedId = CountryIdentifier.Laos; + private const string ExpectedName = "Laos"; + private const string ExpectedOfficialName = "Lao People's Democratic Republic"; + private const string ExpectedNativeName = "ສາທາລະນະລັດ ປະຊາຊົນລາວ"; + private const string ExpectedCapital = "Vientiane"; + private const int ExpectedNumericCode = 418; + private const string ExpectedISO2Code = "LA"; + private const string ExpectedISO3Code = "LAO"; + private static readonly string[] ExpectedCallingCode = ["+856"]; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Attapeu", "LA-AT", "Province"), + ("Bokeo", "LA-BK", "Province"), + ("Bolikhamxai", "LA-BL", "Province"), + ("Champasak", "LA-CH", "Province"), + ("Houaphan", "LA-HO", "Province"), + ("Khammouan", "LA-KH", "Province"), + ("Luang Namtha", "LA-LM", "Province"), + ("Luang Prabang", "LA-LP", "Province"), + ("Oudomxai", "LA-OU", "Province"), + ("Phongsaly", "LA-PH", "Province"), + ("Salavan", "LA-SL", "Province"), + ("Savannakhét", "LA-SV", "Province"), + ("Sekong", "LA-XE", "Province"), + ("Vientiane Province", "LA-VI", "Province"), + ("Vientiane Prefecture", "LA-VT", "Prefecture"), + ("Xaignabouli", "LA-XA", "Province"), + ("Xaisomboun", "LA-XN", "Province"), + ("Xiangkhouang", "LA-XI", "Province") + ]; + + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForLaos() + { + 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); + } + } + } +} From b2f1961c3c148eed47e9d1f99e6a565337b61af4 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 00:12:06 +0100 Subject: [PATCH 37/44] remove unused using in laos test class --- src/World.Net.UnitTests/Countries/LaosTest.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/LaosTest.cs b/src/World.Net.UnitTests/Countries/LaosTest.cs index 4b2bcfa..be4dbbc 100644 --- a/src/World.Net.UnitTests/Countries/LaosTest.cs +++ b/src/World.Net.UnitTests/Countries/LaosTest.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace World.Net.UnitTests.Countries +namespace World.Net.UnitTests.Countries { public class LaosTest { From a111fa15f8aa3d69bf90ef81a9cc92ef642a592c Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 20:00:30 +0100 Subject: [PATCH 38/44] add latvia --- src/World.Net/Countries/Latvia.cs | 73 +++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/World.Net/Countries/Latvia.cs diff --git a/src/World.Net/Countries/Latvia.cs b/src/World.Net/Countries/Latvia.cs new file mode 100644 index 0000000..d7a3aa1 --- /dev/null +++ b/src/World.Net/Countries/Latvia.cs @@ -0,0 +1,73 @@ +namespace World.Net.Countries +{ + internal sealed class Latvia : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.Latvia; + + /// + public string Name { get; } = "Latvia"; + + /// + public string OfficialName { get; } = "Republic of Latvia"; + + /// + public string NativeName { get; } = "Latvijas Republika"; + + /// + public string Capital { get; } = "Riga"; + + /// + public int NumericCode { get; } = 428; + + /// + public string ISO2Code { get; } = "LV"; + + /// + public string ISO3Code { get; } = "LVA"; + + /// + public string[] CallingCode { get; } = ["+371"]; + + /// + public IEnumerable States { get; } = + [ + new("Aizkraukle", "LV-AI", "Municipality"), + new("Alūksne", "LV-AL", "Municipality"), + new("Balvi", "LV-BL", "Municipality"), + new("Bauska", "LV-BU", "Municipality"), + new("Cēsis", "LV-CE", "Municipality"), + new("Dobele", "LV-DO", "Municipality"), + new("Gulbene", "LV-GU", "Municipality"), + new("Jelgava", "LV-JL", "Municipality"), + new("Jēkabpils", "LV-JK", "Municipality"), + new("Krāslava", "LV-KR", "Municipality"), + new("Kuldīga", "LV-KU", "Municipality"), + new("Limbaži", "LV-LM", "Municipality"), + new("Līvāni", "LV-LV", "Municipality"), + new("Ludza", "LV-LU", "Municipality"), + new("Madona", "LV-MA", "Municipality"), + new("Ogre", "LV-OG", "Municipality"), + new("Preiļi", "LV-PR", "Municipality"), + new("Rēzekne", "LV-RE", "Municipality"), + new("Riga", "LV-RI", "Municipality"), + new("Saldus", "LV-SA", "Municipality"), + new("Sigulda", "LV-SI", "Municipality"), + new("Smiltene", "LV-SM", "Municipality"), + new("Talsi", "LV-TA", "Municipality"), + new("Tukums", "LV-TU", "Municipality"), + new("Valka", "LV-VA", "Municipality"), + new("Valmiera", "LV-VM", "Municipality"), + new("Ventspils", "LV-VE", "Municipality"), + new("Augšdaugava", "LV-AD", "Municipality"), + new("Dienvidkurzeme", "LV-DK", "Municipality"), + new("Rēzekne City", "LV-RC", "Republic City"), + new("Daugavpils City", "LV-DC", "Republic City"), + new("Jelgava City", "LV-JC", "Republic City"), + new("Jūrmala City", "LV-JU", "Republic City"), + new("Liepāja City", "LV-LP", "Republic City"), + new("Riga City", "LV-RG", "Republic City"), + new("Ventspils City", "LV-VC", "Republic City") + ]; + } +} From 3f87a578ade550ab2481668357059cccf8d66a4e Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 20:00:42 +0100 Subject: [PATCH 39/44] initalize latvia --- 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 7439f40..c58af85 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -99,6 +99,7 @@ public static Dictionary Initialize() { CountryIdentifier.Kuwait, new Kuwait() }, { CountryIdentifier.Kyrgyzstan, new Kyrgyzstan() }, { CountryIdentifier.Laos, new Laos() }, + { CountryIdentifier.Latvia, new Latvia() }, // Future countries can be added here in the same format. }; From 248db4f08b4fe49135386f7d2ca12a6c80b902b1 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 20:00:50 +0100 Subject: [PATCH 40/44] add test base class --- .../AssertCountryTestBase.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/World.Net.UnitTests/AssertCountryTestBase.cs diff --git a/src/World.Net.UnitTests/AssertCountryTestBase.cs b/src/World.Net.UnitTests/AssertCountryTestBase.cs new file mode 100644 index 0000000..d98641c --- /dev/null +++ b/src/World.Net.UnitTests/AssertCountryTestBase.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests +{ + public abstract class AssertCountryTestBase + { + protected static void AssertCorrectInformation( + ICountry country, + CountryIdentifier expectedId, + string expectedName, + string expectedOfficialName, + string expectedNativeName, + string expectedCapital, + int expectedNumericCode, + string expectedISO2Code, + string expectedISO3Code, + string[] expectedCallingCode, + (string Name, string IsoCode, string Type)[] expectedStates) + { + 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); + } + } + } +} From 4d361ad44f4cb2fcc50f6d0e727e3d679acb7202 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 20:01:03 +0100 Subject: [PATCH 41/44] add latvia test case --- .../Countries/LatviaTests.cs | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/LatviaTests.cs diff --git a/src/World.Net.UnitTests/Countries/LatviaTests.cs b/src/World.Net.UnitTests/Countries/LatviaTests.cs new file mode 100644 index 0000000..e3b04c4 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/LatviaTests.cs @@ -0,0 +1,75 @@ +namespace World.Net.UnitTests.Countries +{ + public class LatviaTests : AssertCountryTestBase + { + private const CountryIdentifier ExpectedId = CountryIdentifier.Latvia; + private const string ExpectedName = "Latvia"; + private const string ExpectedOfficialName = "Republic of Latvia"; + private const string ExpectedNativeName = "Latvijas Republika"; + private const string ExpectedCapital = "Riga"; + private const int ExpectedNumericCode = 428; + private const string ExpectedISO2Code = "LV"; + private const string ExpectedISO3Code = "LVA"; + private static readonly string[] ExpectedCallingCode = ["+371"]; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + ("Aizkraukle", "LV-AI", "Municipality"), + ("Alūksne", "LV-AL", "Municipality"), + ("Balvi", "LV-BL", "Municipality"), + ("Bauska", "LV-BU", "Municipality"), + ("Cēsis", "LV-CE", "Municipality"), + ("Dobele", "LV-DO", "Municipality"), + ("Gulbene", "LV-GU", "Municipality"), + ("Jelgava", "LV-JL", "Municipality"), + ("Jēkabpils", "LV-JK", "Municipality"), + ("Krāslava", "LV-KR", "Municipality"), + ("Kuldīga", "LV-KU", "Municipality"), + ("Limbaži", "LV-LM", "Municipality"), + ("Līvāni", "LV-LV", "Municipality"), + ("Ludza", "LV-LU", "Municipality"), + ("Madona", "LV-MA", "Municipality"), + ("Ogre", "LV-OG", "Municipality"), + ("Preiļi", "LV-PR", "Municipality"), + ("Rēzekne", "LV-RE", "Municipality"), + ("Riga", "LV-RI", "Municipality"), + ("Saldus", "LV-SA", "Municipality"), + ("Sigulda", "LV-SI", "Municipality"), + ("Smiltene", "LV-SM", "Municipality"), + ("Talsi", "LV-TA", "Municipality"), + ("Tukums", "LV-TU", "Municipality"), + ("Valka", "LV-VA", "Municipality"), + ("Valmiera", "LV-VM", "Municipality"), + ("Ventspils", "LV-VE", "Municipality"), + ("Augšdaugava", "LV-AD", "Municipality"), + ("Dienvidkurzeme", "LV-DK", "Municipality"), + ("Rēzekne City", "LV-RC", "Republic City"), + ("Daugavpils City", "LV-DC", "Republic City"), + ("Jelgava City", "LV-JC", "Republic City"), + ("Jūrmala City", "LV-JU", "Republic City"), + ("Liepāja City", "LV-LP", "Republic City"), + ("Riga City", "LV-RG", "Republic City"), + ("Ventspils City", "LV-VC", "Republic City") + ]; + + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForLaos() + { + var country = CountryProvider.GetCountry(ExpectedId); + + AssertCorrectInformation( + country, + ExpectedId, + ExpectedName, + ExpectedOfficialName, + ExpectedNativeName, + ExpectedCapital, + ExpectedNumericCode, + ExpectedISO2Code, + ExpectedISO3Code, + ExpectedCallingCode, + ExpectedStates + ); + } + } +} From aca12397dae75101b3936cc208d31a16521c7820 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 21:45:40 +0100 Subject: [PATCH 42/44] introduce test base class --- src/World.Net.UnitTests/AssertCountryTestBase.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/World.Net.UnitTests/AssertCountryTestBase.cs b/src/World.Net.UnitTests/AssertCountryTestBase.cs index d98641c..7eb84e7 100644 --- a/src/World.Net.UnitTests/AssertCountryTestBase.cs +++ b/src/World.Net.UnitTests/AssertCountryTestBase.cs @@ -15,6 +15,7 @@ protected static void AssertCorrectInformation( string[] expectedCallingCode, (string Name, string IsoCode, string Type)[] expectedStates) { + Assert.NotNull(country); Assert.Equal(expectedId, country.Id); Assert.Equal(expectedName, country.Name); Assert.Equal(expectedOfficialName, country.OfficialName); @@ -24,6 +25,7 @@ protected static void AssertCorrectInformation( Assert.Equal(expectedISO2Code, country.ISO2Code); Assert.Equal(expectedISO3Code, country.ISO3Code); Assert.Equal(expectedCallingCode, country.CallingCode); + Assert.NotNull(country.States); var states = country.States.ToArray(); Assert.Equal(expectedStates.Length, states.Length); From 169302f40f4cf2647845fe3de28b473095637264 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 21:45:59 +0100 Subject: [PATCH 43/44] refactor finland test --- .../Countries/FinlandTest.cs | 59 +++++++++++++------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/FinlandTest.cs b/src/World.Net.UnitTests/Countries/FinlandTest.cs index 3b223c5..6a89052 100644 --- a/src/World.Net.UnitTests/Countries/FinlandTest.cs +++ b/src/World.Net.UnitTests/Countries/FinlandTest.cs @@ -1,6 +1,6 @@ namespace World.Net.UnitTests.Countries; -public sealed class FinlandTest +public sealed class FinlandTest : AssertCountryTestBase { private const string FINLAND_COUNTRY_NAME = "Finland"; private const string FINLAND_NATIVE_NAME = "Suomen tasavalta / Republiken Finland"; @@ -10,32 +10,53 @@ public sealed class FinlandTest private const string FINLAND_ISO3_CODE = "FIN"; private const int FINLAND_NUMERIC_CODE = 246; private readonly string[] FINLAND_CALLING_CODE = ["+358"]; - private const int FINLAND_STATE_COUNT = 21; - private static readonly string[] VALID_STATE_TYPES = { "Region" }; + private const CountryIdentifier ExpectedId = CountryIdentifier.Finland; + private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + [ + new("Åland", "FI-01", "Region"), + new("Central Finland", "FI-08", "Region"), + new("Central Ostrobothnia", "FI-07", "Region"), + new("Etelä-Karjala", "FI-02", "Region"), + new("Etelä-Pohjanmaa", "FI-03", "Region"), + new("Etelä-Savo", "FI-04", "Region"), + new("Kainuu", "FI-05", "Region"), + new("Kanta-Häme", "FI-06", "Region"), + new("Keski-Pohjanmaa", "FI-09", "Region"), + new("Keski-Suomi", "FI-10", "Region"), + new("Kymenlaakso", "FI-11", "Region"), + new("Lappi", "FI-12", "Region"), + new("Pirkanmaa", "FI-13", "Region"), + new("Pohjanmaa", "FI-14", "Region"), + new("Pohjois-Karjala", "FI-15", "Region"), + new("Pohjois-Pohjanmaa", "FI-16", "Region"), + new("Pohjois-Savo", "FI-17", "Region"), + new("Päijät-Häme", "FI-18", "Region"), + new("Satakunta", "FI-19", "Region"), + new("Uusimaa", "FI-20", "Region"), + new("Varsinais-Suomi", "FI-21", "Region") + ]; [Fact] public void GetCountry_ReturnsCorrectInformation_ForFinland() { // Arrange - CountryIdentifier existingCountryId = CountryIdentifier.Finland; - // Act - var country = CountryProvider.GetCountry(existingCountryId); + var country = CountryProvider.GetCountry(ExpectedId); // Assert - Assert.NotNull(country); - Assert.Equal(existingCountryId, country.Id); - Assert.Equal(FINLAND_COUNTRY_NAME, country.Name); - Assert.Equal(FINLAND_OFFICIAL_NAME, country.OfficialName); - Assert.Equal(FINLAND_NATIVE_NAME, country.NativeName); - Assert.Equal(FINLAND_CAPITAL, country.Capital); - Assert.Equal(FINLAND_NUMERIC_CODE, country.NumericCode); - Assert.Equal(FINLAND_ISO2_CODE, country.ISO2Code); - Assert.Equal(FINLAND_ISO3_CODE, country.ISO3Code); - Assert.Equal(FINLAND_CALLING_CODE, country.CallingCode); - Assert.NotNull(country.States); - Assert.Equal(FINLAND_STATE_COUNT, country.States.Count()); - Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + AssertCorrectInformation( + country, + ExpectedId, + FINLAND_COUNTRY_NAME, + FINLAND_OFFICIAL_NAME, + FINLAND_NATIVE_NAME, + FINLAND_CAPITAL, + FINLAND_NUMERIC_CODE, + FINLAND_ISO2_CODE, + FINLAND_ISO3_CODE, + FINLAND_CALLING_CODE, + ExpectedStates + ); } } From 1c3ebf08bf67d587114fe4105d5faee1330cb918 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 9 Oct 2025 21:47:21 +0100 Subject: [PATCH 44/44] update finland test --- src/World.Net.UnitTests/Countries/FinlandTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/FinlandTest.cs b/src/World.Net.UnitTests/Countries/FinlandTest.cs index 6a89052..57afd0d 100644 --- a/src/World.Net.UnitTests/Countries/FinlandTest.cs +++ b/src/World.Net.UnitTests/Countries/FinlandTest.cs @@ -10,8 +10,8 @@ public sealed class FinlandTest : AssertCountryTestBase private const string FINLAND_ISO3_CODE = "FIN"; private const int FINLAND_NUMERIC_CODE = 246; private readonly string[] FINLAND_CALLING_CODE = ["+358"]; - private const CountryIdentifier ExpectedId = CountryIdentifier.Finland; - private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates = + private const CountryIdentifier EXPECTEDID = CountryIdentifier.Finland; + private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES = [ new("Åland", "FI-01", "Region"), new("Central Finland", "FI-08", "Region"), @@ -41,12 +41,12 @@ public void GetCountry_ReturnsCorrectInformation_ForFinland() { // Arrange // Act - var country = CountryProvider.GetCountry(ExpectedId); + var country = CountryProvider.GetCountry(EXPECTEDID); // Assert AssertCorrectInformation( country, - ExpectedId, + EXPECTEDID, FINLAND_COUNTRY_NAME, FINLAND_OFFICIAL_NAME, FINLAND_NATIVE_NAME, @@ -55,7 +55,7 @@ public void GetCountry_ReturnsCorrectInformation_ForFinland() FINLAND_ISO2_CODE, FINLAND_ISO3_CODE, FINLAND_CALLING_CODE, - ExpectedStates + EXPECTED_STATES ); } }