diff --git a/src/World.Net.UnitTests/Countries/JamaicaTest.cs b/src/World.Net.UnitTests/Countries/JamaicaTest.cs new file mode 100644 index 0000000..67439db --- /dev/null +++ b/src/World.Net.UnitTests/Countries/JamaicaTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; +public sealed class JamaicaTest +{ + private const string JAMAICA_COUNTRY_NAME = "Jamaica"; + private const string JAMAICA_NATIVE_NAME = "Jamaica"; + private const string JAMAICA_CAPITAL = "Kingston"; + private const string JAMAICA_OFFICIAL_NAME = "Jamaica"; + private const string JAMAICA_ISO2_CODE = "JM"; + private const string JAMAICA_ISO3_CODE = "JAM"; + private const int JAMAICA_NUMERIC_CODE = 388; + private readonly string[] JAMAICA_CALLING_CODE = ["+1-876"]; + private const int JAMAICA_STATE_COUNT = 14; + private static readonly string[] VALID_STATE_TYPES = { "Parish" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForJamaica() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Jamaica; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(JAMAICA_COUNTRY_NAME, country.Name); + Assert.Equal(JAMAICA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(JAMAICA_NATIVE_NAME, country.NativeName); + Assert.Equal(JAMAICA_CAPITAL, country.Capital); + Assert.Equal(JAMAICA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(JAMAICA_ISO2_CODE, country.ISO2Code); + Assert.Equal(JAMAICA_ISO3_CODE, country.ISO3Code); + Assert.Equal(JAMAICA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(JAMAICA_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/JapanTest.cs b/src/World.Net.UnitTests/Countries/JapanTest.cs new file mode 100644 index 0000000..ef974b9 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/JapanTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; +public sealed class JapanTest +{ + private const string JAPAN_COUNTRY_NAME = "Japan"; + private const string JAPAN_NATIVE_NAME = "日本"; + private const string JAPAN_CAPITAL = "Tokyo"; + private const string JAPAN_OFFICIAL_NAME = "Japan"; + private const string JAPAN_ISO2_CODE = "JP"; + private const string JAPAN_ISO3_CODE = "JPN"; + private const int JAPAN_NUMERIC_CODE = 392; + private readonly string[] JAPAN_CALLING_CODE = ["+81"]; + private const int JAPAN_STATE_COUNT = 47; + private static readonly string[] VALID_STATE_TYPES = { "Prefecture" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForJapan() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Japan; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(JAPAN_COUNTRY_NAME, country.Name); + Assert.Equal(JAPAN_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(JAPAN_NATIVE_NAME, country.NativeName); + Assert.Equal(JAPAN_CAPITAL, country.Capital); + Assert.Equal(JAPAN_NUMERIC_CODE, country.NumericCode); + Assert.Equal(JAPAN_ISO2_CODE, country.ISO2Code); + Assert.Equal(JAPAN_ISO3_CODE, country.ISO3Code); + Assert.Equal(JAPAN_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(JAPAN_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/JerseyTest.cs b/src/World.Net.UnitTests/Countries/JerseyTest.cs new file mode 100644 index 0000000..fad36bd --- /dev/null +++ b/src/World.Net.UnitTests/Countries/JerseyTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; +public sealed class JerseyTest +{ + private const string JERSEY_COUNTRY_NAME = "Jersey"; + private const string JERSEY_NATIVE_NAME = "Jersey"; + private const string JERSEY_CAPITAL = "Saint Helier"; + private const string JERSEY_OFFICIAL_NAME = "Bailiwick of Jersey"; + private const string JERSEY_ISO2_CODE = "JE"; + private const string JERSEY_ISO3_CODE = "JEY"; + private const int JERSEY_NUMERIC_CODE = 832; + private readonly string[] JERSEY_CALLING_CODE = ["+44"]; + private const int JERSEY_STATE_COUNT = 12; + private static readonly string[] VALID_STATE_TYPES = { "parish" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForJersey() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Jersey; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(JERSEY_COUNTRY_NAME, country.Name); + Assert.Equal(JERSEY_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(JERSEY_NATIVE_NAME, country.NativeName); + Assert.Equal(JERSEY_CAPITAL, country.Capital); + Assert.Equal(JERSEY_NUMERIC_CODE, country.NumericCode); + Assert.Equal(JERSEY_ISO2_CODE, country.ISO2Code); + Assert.Equal(JERSEY_ISO3_CODE, country.ISO3Code); + Assert.Equal(JERSEY_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(JERSEY_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/JordanTest.cs b/src/World.Net.UnitTests/Countries/JordanTest.cs new file mode 100644 index 0000000..4c383d7 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/JordanTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; +public sealed class JordanTest +{ + private const string JORDAN_COUNTRY_NAME = "Jordan"; + private const string JORDAN_NATIVE_NAME = "الأردن"; + private const string JORDAN_CAPITAL = "Amman"; + private const string JORDAN_OFFICIAL_NAME = "Hashemite Kingdom of Jordan"; + private const string JORDAN_ISO2_CODE = "JO"; + private const string JORDAN_ISO3_CODE = "JOR"; + private const int JORDAN_NUMERIC_CODE = 400; + private readonly string[] JORDAN_CALLING_CODE = ["+962"]; + private const int JORDAN_STATE_COUNT = 12; + private static readonly string[] VALID_STATE_TYPES = { "governorate" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForJordan() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Jordan; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(JORDAN_COUNTRY_NAME, country.Name); + Assert.Equal(JORDAN_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(JORDAN_NATIVE_NAME, country.NativeName); + Assert.Equal(JORDAN_CAPITAL, country.Capital); + Assert.Equal(JORDAN_NUMERIC_CODE, country.NumericCode); + Assert.Equal(JORDAN_ISO2_CODE, country.ISO2Code); + Assert.Equal(JORDAN_ISO3_CODE, country.ISO3Code); + Assert.Equal(JORDAN_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(JORDAN_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net/Countries/Jamaica.cs b/src/World.Net/Countries/Jamaica.cs new file mode 100644 index 0000000..7a5365e --- /dev/null +++ b/src/World.Net/Countries/Jamaica.cs @@ -0,0 +1,48 @@ +namespace World.Net.Countries; +internal sealed class Jamaica : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Jamaica; + + // + public string Name { get; } = "Jamaica"; + + // + public string OfficialName { get; } = "Jamaica"; + + // + public string NativeName => "Jamaica"; + + // + public string Capital { get; } = "Kingston"; + + // + public int NumericCode { get; } = 388; + + // + public string ISO2Code { get; } = "JM"; + + // + public string ISO3Code { get; } = "JAM"; + + // + public string[] CallingCode { get; } = ["+1-876"]; + + // + public IEnumerable States => + [ + new("Clarendon", "JM-13", "Parish"), + new("Hanover", "JM-09", "Parish"), + new("Kingston", "JM-01", "Parish"), + new("Manchester", "JM-12", "Parish"), + new("Portland", "JM-04", "Parish"), + new("Saint Andrew", "JM-02", "Parish"), + new("Saint Ann", "JM-06", "Parish"), + new("Saint Catherine", "JM-14", "Parish"), + new("Saint Elizabeth", "JM-11", "Parish"), + new("Saint James", "JM-08", "Parish"), + new("Saint Mary", "JM-05", "Parish"), + new("Saint Thomas", "JM-03", "Parish"), + new("Trelawny", "JM-07", "Parish"), + new("Westmoreland", "JM-10", "Parish"), + ]; +} diff --git a/src/World.Net/Countries/Japan.cs b/src/World.Net/Countries/Japan.cs new file mode 100644 index 0000000..59689d4 --- /dev/null +++ b/src/World.Net/Countries/Japan.cs @@ -0,0 +1,82 @@ +namespace World.Net.Countries; +internal sealed class Japan : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Japan; + + // + public string Name { get; } = "Japan"; + + // + public string OfficialName { get; } = "Japan"; + + // + public string NativeName => "日本"; + + // + public string Capital { get; } = "Tokyo"; + + // + public int NumericCode { get; } = 392; + + // + public string ISO2Code { get; } = "JP"; + + // + public string ISO3Code { get; } = "JPN"; + + // + public string[] CallingCode { get; } = ["+81"]; + + // + public IEnumerable States => + [ + new("Aichi", "JP-23", "Prefecture"), + new("Akita", "JP-05", "Prefecture"), + new("Aomori", "JP-02", "Prefecture"), + new("Chiba", "JP-12", "Prefecture"), + new("Ehime", "JP-38", "Prefecture"), + new("Fukui", "JP-18", "Prefecture"), + new("Fukuoka", "JP-40", "Prefecture"), + new("Fukushima", "JP-07", "Prefecture"), + new("Gifu", "JP-21", "Prefecture"), + new("Gunma", "JP-10", "Prefecture"), + new("Hiroshima", "JP-34", "Prefecture"), + new("Hokkaidō", "JP-01", "Prefecture"), + new("Hyōgo", "JP-28", "Prefecture"), + new("Ibaraki", "JP-08", "Prefecture"), + new("Ishikawa", "JP-17", "Prefecture"), + new("Iwate", "JP-03", "Prefecture"), + new("Kagawa", "JP-37", "Prefecture"), + new("Kagoshima", "JP-46", "Prefecture"), + new("Kanagawa", "JP-14", "Prefecture"), + new("Kōchi", "JP-39", "Prefecture"), + new("Kumamoto", "JP-43", "Prefecture"), + new("Kyōto", "JP-26", "Prefecture"), + new("Mie", "JP-24", "Prefecture"), + new("Miyagi", "JP-04", "Prefecture"), + new("Miyazaki", "JP-45", "Prefecture"), + new("Nagano", "JP-20", "Prefecture"), + new("Nagasaki", "JP-42", "Prefecture"), + new("Nara", "JP-29", "Prefecture"), + new("Niigata", "JP-15", "Prefecture"), + new("Ōita", "JP-44", "Prefecture"), + new("Okayama", "JP-33", "Prefecture"), + new("Okinawa", "JP-47", "Prefecture"), + new("Ōsaka", "JP-27", "Prefecture"), + new("Saga", "JP-41", "Prefecture"), + new("Saitama", "JP-11", "Prefecture"), + new("Shiga", "JP-25", "Prefecture"), + new("Shimane", "JP-32", "Prefecture"), + new("Shizuoka", "JP-22", "Prefecture"), + new("Tochigi", "JP-09", "Prefecture"), + new("Tokushima", "JP-36", "Prefecture"), + new("Tokyo", "JP-13", "Prefecture"), + new("Tottori", "JP-31", "Prefecture"), + new("Toyama", "JP-16", "Prefecture"), + new("Wakayama", "JP-30", "Prefecture"), + new("Yamagata", "JP-06", "Prefecture"), + new("Yamaguchi", "JP-35", "Prefecture"), + new("Yamanashi", "JP-19", "Prefecture"), + + ]; +} diff --git a/src/World.Net/Countries/Jersey.cs b/src/World.Net/Countries/Jersey.cs new file mode 100644 index 0000000..ca7847c --- /dev/null +++ b/src/World.Net/Countries/Jersey.cs @@ -0,0 +1,46 @@ +namespace World.Net.Countries; +internal sealed class Jersey : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Jersey; + + // + public string Name { get; } = "Jersey"; + + // + public string OfficialName { get; } = "Bailiwick of Jersey"; + + // + public string NativeName => "Jersey"; + + // + public string Capital { get; } = "Saint Helier"; + + // + public int NumericCode { get; } = 832; + + // + public string ISO2Code { get; } = "JE"; + + // + public string ISO3Code { get; } = "JEY"; + + // + public string[] CallingCode { get; } = ["+44"]; + + // + public IEnumerable States => + [ + new("Grouville", "JE-01", "parish"), + new("St Brelade", "JE-02", "parish"), + new("St Clement", "JE-03", "parish"), + new("St Helier", "JE-04", "parish"), + new("St John", "JE-05", "parish"), + new("St Lawrence", "JE-06", "parish"), + new("St Martin", "JE-07", "parish"), + new("St Mary", "JE-08", "parish"), + new("St Ouen", "JE-09", "parish"), + new("St Peter", "JE-10", "parish"), + new("St Saviour", "JE-11", "parish"), + new("Trinity", "JE-12", "parish"), + ]; +} diff --git a/src/World.Net/Countries/Jordan.cs b/src/World.Net/Countries/Jordan.cs new file mode 100644 index 0000000..fd6d8f4 --- /dev/null +++ b/src/World.Net/Countries/Jordan.cs @@ -0,0 +1,46 @@ +namespace World.Net.Countries; +internal sealed class Jordan : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Jordan; + + // + public string Name { get; } = "Jordan"; + + // + public string OfficialName { get; } = "Hashemite Kingdom of Jordan"; + + // + public string NativeName => "الأردن"; + + // + public string Capital { get; } = "Amman"; + + // + public int NumericCode { get; } = 400; + + // + public string ISO2Code { get; } = "JO"; + + // + public string ISO3Code { get; } = "JOR"; + + // + public string[] CallingCode { get; } = ["+962"]; + + // + public IEnumerable States => + [ + new("Ajloun", "JO-AJ", "governorate"), + new("Amman", "JO-AM", "governorate"), + new("Aqaba", "JO-AQ", "governorate"), + new("Balqa", "JO-BA", "governorate"), + new("Irbid", "JO-IR", "governorate"), + new("Jerash", "JO-JA", "governorate"), + new("Karak", "JO-KA", "governorate"), + new("Ma'an", "JO-MN", "governorate"), + new("Madaba", "JO-MD", "governorate"), + new("Mafraq", "JO-MA", "governorate"), + new("Tafilah", "JO-AT", "governorate"), + new("Zarqa", "JO-AZ", "governorate"), + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index ba11d9e..673508c 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -88,6 +88,10 @@ public static Dictionary Initialize() { CountryIdentifier.Ireland, new Ireland() }, { CountryIdentifier.Israel, new Israel() }, { CountryIdentifier.Italy, new Italy() }, + { CountryIdentifier.Jamaica, new Jamaica() }, + { CountryIdentifier.Japan, new Japan() }, + { CountryIdentifier.Jersey, new Jersey() }, + { CountryIdentifier.Jordan, new Jordan() } // Future countries can be added here in the same format. };