Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/.copilot/generate-country.prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ When you are asked to "create a country":
- Use immutable properties (fixed values, no setters).
- Use the correct `CountryIdentifier.<Name>` 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`.
Expand Down Expand Up @@ -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.

---
Expand Down
43 changes: 43 additions & 0 deletions src/World.Net.UnitTests/Countries/KenyaTest.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}
43 changes: 43 additions & 0 deletions src/World.Net.UnitTests/Countries/KiribatiTest.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}
73 changes: 73 additions & 0 deletions src/World.Net/Countries/Kenya.cs
Original file line number Diff line number Diff line change
@@ -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<State> 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")
];
}
20 changes: 20 additions & 0 deletions src/World.Net/Countries/Kiribati.cs
Original file line number Diff line number Diff line change
@@ -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<State> States =>
[
new("Gilbert Islands", "KI-G", "Group"),
new("Line Islands", "KI-L", "Group"),
new("Phoenix Islands", "KI-P", "Group")
];
}
4 changes: 3 additions & 1 deletion src/World.Net/Helpers/CountryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public static Dictionary<CountryIdentifier, ICountry> 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.
};
Expand Down