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 placeholder—skip or request clarification. --- 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.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/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") + ]; +} 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") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 2b22923..0f76427 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -92,7 +92,9 @@ 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() }, + { CountryIdentifier.Kiribati, new Kiribati() }, // Future countries can be added here in the same format. };