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); + } + } + } +} diff --git a/src/World.Net.UnitTests/Countries/KuwaitTest.cs b/src/World.Net.UnitTests/Countries/KuwaitTest.cs new file mode 100644 index 0000000..58a97c1 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/KuwaitTest.cs @@ -0,0 +1,48 @@ +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.UnitTests/Countries/KyrgyzstanTest.cs b/src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs new file mode 100644 index 0000000..71b958a --- /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"), + ("Issyk-Kul", "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/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/Countries/Kuwait.cs b/src/World.Net/Countries/Kuwait.cs new file mode 100644 index 0000000..e01047c --- /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") + ]; +} diff --git a/src/World.Net/Countries/Kyrgyzstan.cs b/src/World.Net/Countries/Kyrgyzstan.cs new file mode 100644 index 0000000..a71586e --- /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("Issyk-Kul", "KG-Y", "Region"), + new State("Bishkek", "KG-GB", "City"), + new State("Osh City", "KG-GO", "City") + ]; +} 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..fe1834b 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -95,6 +95,9 @@ public static Dictionary Initialize() { CountryIdentifier.Kazakhstan, new Kazakhstan() }, { 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. };