Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions src/World.Net.UnitTests/Countries/KazakhstanTest.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}
53 changes: 53 additions & 0 deletions src/World.Net/Countries/Kazakhstan.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace World.Net.Countries;

internal sealed class Kazakhstan : ICountry
{
///<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.Kazakhstan;

///<inheritdoc/>
public string Name => "Kazakhstan";

///<inheritdoc/>
public string OfficialName { get; } = "Republic of Kazakhstan";

///<inheritdoc/>
public string NativeName { get; } = "?????????";

///<inheritdoc/>
public string Capital { get; } = "Astana";

///<inheritdoc/>
public int NumericCode { get; } = 398;

///<inheritdoc/>
public string ISO2Code { get; } = "KZ";

///<inheritdoc/>
public string ISO3Code { get; } = "KAZ";

///<inheritdoc/>
public string[] CallingCode { get; } = ["+7"];

///<inheritdoc/>
public IEnumerable<State> 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")
];
}
3 changes: 2 additions & 1 deletion src/World.Net/Helpers/CountryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
{ CountryIdentifier.Jamaica, new Jamaica() },
{ CountryIdentifier.Japan, new Japan() },
{ CountryIdentifier.Jersey, new Jersey() },
{ CountryIdentifier.Jordan, new Jordan() }
{ CountryIdentifier.Jordan, new Jordan() },
{ CountryIdentifier.Kazakhstan, new Kazakhstan() }

// Future countries can be added here in the same format.
};
Expand Down