diff --git a/src/World.Net.UnitTests/Countries/GermanyTest.cs b/src/World.Net.UnitTests/Countries/GermanyTest.cs new file mode 100644 index 0000000..45435b5 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/GermanyTest.cs @@ -0,0 +1,57 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class GermanyTest : AssertCountryTestBase +{ + private const string GERMANY_COUNTRY_NAME = "Germany"; + private const string GERMANY_NATIVE_NAME = "Deutschland"; + private const string GERMANY_CAPITAL = "Berlin"; + private const string GERMANY_OFFICIAL_NAME = "Federal Republic of Germany"; + private const string GERMANY_ISO2_CODE = "DE"; + private const string GERMANY_ISO3_CODE = "DEU"; + private const int GERMANY_NUMERIC_CODE = 276; + private readonly string[] GERMANY_CALLING_CODE = ["+49"]; + private const CountryIdentifier EXPECTEDID = CountryIdentifier.Germany; + + private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES = + [ + new("Baden-Württemberg", "DE-BW", "State"), + new("Bavaria", "DE-BY", "State"), + new("Berlin", "DE-BE", "State"), + new("Brandenburg", "DE-BB", "State"), + new("Bremen", "DE-HB", "State"), + new("Hamburg", "DE-HH", "State"), + new("Hesse", "DE-HE", "State"), + new("Lower Saxony", "DE-NI", "State"), + new("Mecklenburg-Vorpommern", "DE-MV", "State"), + new("North Rhine-Westphalia", "DE-NW", "State"), + new("Rhineland-Palatinate", "DE-RP", "State"), + new("Saarland", "DE-SL", "State"), + new("Saxony", "DE-SN", "State"), + new("Saxony-Anhalt", "DE-ST", "State"), + new("Schleswig-Holstein", "DE-SH", "State"), + new("Thuringia", "DE-TH", "State") + ]; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForGermany() + { + // Arrange + // Act + var country = CountryProvider.GetCountry(EXPECTEDID); + + // Assert + AssertCorrectInformation( + country, + EXPECTEDID, + GERMANY_COUNTRY_NAME, + GERMANY_OFFICIAL_NAME, + GERMANY_NATIVE_NAME, + GERMANY_CAPITAL, + GERMANY_NUMERIC_CODE, + GERMANY_ISO2_CODE, + GERMANY_ISO3_CODE, + GERMANY_CALLING_CODE, + EXPECTED_STATES + ); + } +} diff --git a/src/World.Net.UnitTests/Countries/GhanaTest.cs b/src/World.Net.UnitTests/Countries/GhanaTest.cs new file mode 100644 index 0000000..afd8794 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/GhanaTest.cs @@ -0,0 +1,57 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class GhanaTest : AssertCountryTestBase +{ + private const string GHANA_COUNTRY_NAME = "Ghana"; + private const string GHANA_NATIVE_NAME = "Ghana"; + private const string GHANA_CAPITAL = "Accra"; + private const string GHANA_OFFICIAL_NAME = "Republic of Ghana"; + private const string GHANA_ISO2_CODE = "GH"; + private const string GHANA_ISO3_CODE = "GHA"; + private const int GHANA_NUMERIC_CODE = 288; + private readonly string[] GHANA_CALLING_CODE = ["+233"]; + private const CountryIdentifier EXPECTEDID = CountryIdentifier.Ghana; + + private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES = + [ + new("Ahafo", "GH-AF", "Region"), + new("Ashanti", "GH-AH", "Region"), + new("Bono", "GH-BO", "Region"), + new("Bono East", "GH-BE", "Region"), + new("Central", "GH-CP", "Region"), + new("Eastern", "GH-EP", "Region"), + new("Greater Accra", "GH-AA", "Region"), + new("North East", "GH-NE", "Region"), + new("Northern", "GH-NP", "Region"), + new("Oti", "GH-OT", "Region"), + new("Savannah", "GH-SV", "Region"), + new("Upper East", "GH-UE", "Region"), + new("Upper West", "GH-UW", "Region"), + new("Volta", "GH-TV", "Region"), + new("Western", "GH-WP", "Region"), + new("Western North", "GH-WN", "Region") + ]; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForGhana() + { + // Arrange + // Act + var country = CountryProvider.GetCountry(EXPECTEDID); + + // Assert + AssertCorrectInformation( + country, + EXPECTEDID, + GHANA_COUNTRY_NAME, + GHANA_OFFICIAL_NAME, + GHANA_NATIVE_NAME, + GHANA_CAPITAL, + GHANA_NUMERIC_CODE, + GHANA_ISO2_CODE, + GHANA_ISO3_CODE, + GHANA_CALLING_CODE, + EXPECTED_STATES + ); + } +} diff --git a/src/World.Net.UnitTests/Countries/GibraltarTest.cs b/src/World.Net.UnitTests/Countries/GibraltarTest.cs new file mode 100644 index 0000000..4158710 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/GibraltarTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class GibraltarTest : AssertCountryTestBase +{ + private const string GIBRALTAR_COUNTRY_NAME = "Gibraltar"; + private const string GIBRALTAR_NATIVE_NAME = "Gibraltar"; + private const string GIBRALTAR_CAPITAL = "Gibraltar"; + private const string GIBRALTAR_OFFICIAL_NAME = "Gibraltar"; + private const string GIBRALTAR_ISO2_CODE = "GI"; + private const string GIBRALTAR_ISO3_CODE = "GIB"; + private const int GIBRALTAR_NUMERIC_CODE = 292; + private readonly string[] GIBRALTAR_CALLING_CODE = ["+350"]; + private const CountryIdentifier EXPECTEDID = CountryIdentifier.Gibraltar; + + private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES = []; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForGibraltar() + { + // Arrange + // Act + var country = CountryProvider.GetCountry(EXPECTEDID); + + // Assert + AssertCorrectInformation( + country, + EXPECTEDID, + GIBRALTAR_COUNTRY_NAME, + GIBRALTAR_OFFICIAL_NAME, + GIBRALTAR_NATIVE_NAME, + GIBRALTAR_CAPITAL, + GIBRALTAR_NUMERIC_CODE, + GIBRALTAR_ISO2_CODE, + GIBRALTAR_ISO3_CODE, + GIBRALTAR_CALLING_CODE, + EXPECTED_STATES + ); + } +} diff --git a/src/World.Net.UnitTests/Countries/GreeceTest.cs b/src/World.Net.UnitTests/Countries/GreeceTest.cs new file mode 100644 index 0000000..afa2622 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/GreeceTest.cs @@ -0,0 +1,54 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class GreeceTest : AssertCountryTestBase +{ + private const string GREECE_COUNTRY_NAME = "Greece"; + private const string GREECE_NATIVE_NAME = "Ελλάδα"; + private const string GREECE_CAPITAL = "Athens"; + private const string GREECE_OFFICIAL_NAME = "Hellenic Republic"; + private const string GREECE_ISO2_CODE = "GR"; + private const string GREECE_ISO3_CODE = "GRC"; + private const int GREECE_NUMERIC_CODE = 300; + private readonly string[] GREECE_CALLING_CODE = ["+30"]; + private const CountryIdentifier EXPECTEDID = CountryIdentifier.Greece; + + private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES = + [ + new("Attica", "GR-I", "Region"), + new("Central Greece", "GR-H", "Region"), + new("Central Macedonia", "GR-B", "Region"), + new("Crete", "GR-M", "Region"), + new("Eastern Macedonia and Thrace", "GR-A", "Region"), + new("Epirus", "GR-D", "Region"), + new("Ionian Islands", "GR-F", "Region"), + new("North Aegean", "GR-K", "Region"), + new("Peloponnese", "GR-J", "Region"), + new("South Aegean", "GR-L", "Region"), + new("Thessaly", "GR-E", "Region"), + new("Western Greece", "GR-G", "Region"), + new("Western Macedonia", "GR-C", "Region") + ]; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForGreece() + { + // Arrange + // Act + var country = CountryProvider.GetCountry(EXPECTEDID); + + // Assert + AssertCorrectInformation( + country, + EXPECTEDID, + GREECE_COUNTRY_NAME, + GREECE_OFFICIAL_NAME, + GREECE_NATIVE_NAME, + GREECE_CAPITAL, + GREECE_NUMERIC_CODE, + GREECE_ISO2_CODE, + GREECE_ISO3_CODE, + GREECE_CALLING_CODE, + EXPECTED_STATES + ); + } +} diff --git a/src/World.Net.UnitTests/Countries/GreenlandTest.cs b/src/World.Net.UnitTests/Countries/GreenlandTest.cs new file mode 100644 index 0000000..898521a --- /dev/null +++ b/src/World.Net.UnitTests/Countries/GreenlandTest.cs @@ -0,0 +1,46 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class GreenlandTest : AssertCountryTestBase +{ + private const string GREENLAND_COUNTRY_NAME = "Greenland"; + private const string GREENLAND_NATIVE_NAME = "Kalaallit Nunaat"; + private const string GREENLAND_CAPITAL = "Nuuk"; + private const string GREENLAND_OFFICIAL_NAME = "Greenland"; + private const string GREENLAND_ISO2_CODE = "GL"; + private const string GREENLAND_ISO3_CODE = "GRL"; + private const int GREENLAND_NUMERIC_CODE = 304; + private readonly string[] GREENLAND_CALLING_CODE = ["+299"]; + private const CountryIdentifier EXPECTEDID = CountryIdentifier.Greenland; + + private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES = + [ + new("Avannaata", "GL-AV", "Municipality"), + new("Kujalleq", "GL-KU", "Municipality"), + new("Qeqertalik", "GL-QT", "Municipality"), + new("Qeqqata", "GL-QE", "Municipality"), + new("Sermersooq", "GL-SM", "Municipality") + ]; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForGreenland() + { + // Arrange + // Act + var country = CountryProvider.GetCountry(EXPECTEDID); + + // Assert + AssertCorrectInformation( + country, + EXPECTEDID, + GREENLAND_COUNTRY_NAME, + GREENLAND_OFFICIAL_NAME, + GREENLAND_NATIVE_NAME, + GREENLAND_CAPITAL, + GREENLAND_NUMERIC_CODE, + GREENLAND_ISO2_CODE, + GREENLAND_ISO3_CODE, + GREENLAND_CALLING_CODE, + EXPECTED_STATES + ); + } +} diff --git a/src/World.Net/Countries/Germany.cs b/src/World.Net/Countries/Germany.cs new file mode 100644 index 0000000..8daa314 --- /dev/null +++ b/src/World.Net/Countries/Germany.cs @@ -0,0 +1,52 @@ +namespace World.Net.Countries; + +internal sealed class Germany : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Germany; + + // + public string Name { get; } = "Germany"; + + // + public string OfficialName { get; } = "Federal Republic of Germany"; + + // + public string NativeName => "Deutschland"; + + // + public string Capital { get; } = "Berlin"; + + // + public int NumericCode { get; } = 276; + + // + public string ISO2Code { get; } = "DE"; + + // + public string ISO3Code { get; } = "DEU"; + + // + public string[] CallingCode { get; } = ["+49"]; + + // + public IEnumerable States => + [ + new("Baden-Württemberg", "DE-BW", "State"), + new("Bavaria", "DE-BY", "State"), + new("Berlin", "DE-BE", "State"), + new("Brandenburg", "DE-BB", "State"), + new("Bremen", "DE-HB", "State"), + new("Hamburg", "DE-HH", "State"), + new("Hesse", "DE-HE", "State"), + new("Lower Saxony", "DE-NI", "State"), + new("Mecklenburg-Vorpommern", "DE-MV", "State"), + new("North Rhine-Westphalia", "DE-NW", "State"), + new("Rhineland-Palatinate", "DE-RP", "State"), + new("Saarland", "DE-SL", "State"), + new("Saxony", "DE-SN", "State"), + new("Saxony-Anhalt", "DE-ST", "State"), + new("Schleswig-Holstein", "DE-SH", "State"), + new("Thuringia", "DE-TH", "State") + ]; +} diff --git a/src/World.Net/Countries/Ghana.cs b/src/World.Net/Countries/Ghana.cs new file mode 100644 index 0000000..4a0e8ab --- /dev/null +++ b/src/World.Net/Countries/Ghana.cs @@ -0,0 +1,52 @@ +namespace World.Net.Countries; + +internal sealed class Ghana : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Ghana; + + // + public string Name { get; } = "Ghana"; + + // + public string OfficialName { get; } = "Republic of Ghana"; + + // + public string NativeName => "Ghana"; + + // + public string Capital { get; } = "Accra"; + + // + public int NumericCode { get; } = 288; + + // + public string ISO2Code { get; } = "GH"; + + // + public string ISO3Code { get; } = "GHA"; + + // + public string[] CallingCode { get; } = ["+233"]; + + // + public IEnumerable States => + [ + new("Ahafo", "GH-AF", "Region"), + new("Ashanti", "GH-AH", "Region"), + new("Bono", "GH-BO", "Region"), + new("Bono East", "GH-BE", "Region"), + new("Central", "GH-CP", "Region"), + new("Eastern", "GH-EP", "Region"), + new("Greater Accra", "GH-AA", "Region"), + new("North East", "GH-NE", "Region"), + new("Northern", "GH-NP", "Region"), + new("Oti", "GH-OT", "Region"), + new("Savannah", "GH-SV", "Region"), + new("Upper East", "GH-UE", "Region"), + new("Upper West", "GH-UW", "Region"), + new("Volta", "GH-TV", "Region"), + new("Western", "GH-WP", "Region"), + new("Western North", "GH-WN", "Region") + ]; +} diff --git a/src/World.Net/Countries/Gibraltar.cs b/src/World.Net/Countries/Gibraltar.cs new file mode 100644 index 0000000..1ac775d --- /dev/null +++ b/src/World.Net/Countries/Gibraltar.cs @@ -0,0 +1,34 @@ +namespace World.Net.Countries; + +internal sealed class Gibraltar : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Gibraltar; + + // + public string Name { get; } = "Gibraltar"; + + // + public string OfficialName { get; } = "Gibraltar"; + + // + public string NativeName => "Gibraltar"; + + // + public string Capital { get; } = "Gibraltar"; + + // + public int NumericCode { get; } = 292; + + // + public string ISO2Code { get; } = "GI"; + + // + public string ISO3Code { get; } = "GIB"; + + // + public string[] CallingCode { get; } = ["+350"]; + + // + public IEnumerable States => []; +} diff --git a/src/World.Net/Countries/Greece.cs b/src/World.Net/Countries/Greece.cs new file mode 100644 index 0000000..754b055 --- /dev/null +++ b/src/World.Net/Countries/Greece.cs @@ -0,0 +1,49 @@ +namespace World.Net.Countries; + +internal sealed class Greece : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Greece; + + // + public string Name { get; } = "Greece"; + + // + public string OfficialName { get; } = "Hellenic Republic"; + + // + public string NativeName => "Ελλάδα"; + + // + public string Capital { get; } = "Athens"; + + // + public int NumericCode { get; } = 300; + + // + public string ISO2Code { get; } = "GR"; + + // + public string ISO3Code { get; } = "GRC"; + + // + public string[] CallingCode { get; } = ["+30"]; + + // + public IEnumerable States => + [ + new("Attica", "GR-I", "Region"), + new("Central Greece", "GR-H", "Region"), + new("Central Macedonia", "GR-B", "Region"), + new("Crete", "GR-M", "Region"), + new("Eastern Macedonia and Thrace", "GR-A", "Region"), + new("Epirus", "GR-D", "Region"), + new("Ionian Islands", "GR-F", "Region"), + new("North Aegean", "GR-K", "Region"), + new("Peloponnese", "GR-J", "Region"), + new("South Aegean", "GR-L", "Region"), + new("Thessaly", "GR-E", "Region"), + new("Western Greece", "GR-G", "Region"), + new("Western Macedonia", "GR-C", "Region") + ]; +} diff --git a/src/World.Net/Countries/Greenland.cs b/src/World.Net/Countries/Greenland.cs new file mode 100644 index 0000000..b543316 --- /dev/null +++ b/src/World.Net/Countries/Greenland.cs @@ -0,0 +1,41 @@ +namespace World.Net.Countries; + +internal sealed class Greenland : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Greenland; + + // + public string Name { get; } = "Greenland"; + + // + public string OfficialName { get; } = "Greenland"; + + // + public string NativeName => "Kalaallit Nunaat"; + + // + public string Capital { get; } = "Nuuk"; + + // + public int NumericCode { get; } = 304; + + // + public string ISO2Code { get; } = "GL"; + + // + public string ISO3Code { get; } = "GRL"; + + // + public string[] CallingCode { get; } = ["+299"]; + + // + public IEnumerable States => + [ + new("Avannaata", "GL-AV", "Municipality"), + new("Kujalleq", "GL-KU", "Municipality"), + new("Qeqertalik", "GL-QT", "Municipality"), + new("Qeqqata", "GL-QE", "Municipality"), + new("Sermersooq", "GL-SM", "Municipality") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 9fa2b7e..e8319e7 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -86,6 +86,11 @@ public static Dictionary Initialize() { CountryIdentifier.FrenchPolynesia, new FrenchPolynesia() }, { CountryIdentifier.Gabon, new Gabon() }, { CountryIdentifier.Georgia, new Georgia() }, + { CountryIdentifier.Germany, new Germany() }, + { CountryIdentifier.Ghana, new Ghana() }, + { CountryIdentifier.Gibraltar, new Gibraltar() }, + { CountryIdentifier.Greece, new Greece() }, + { CountryIdentifier.Greenland, new Greenland() }, { CountryIdentifier.Iraq, new Iraq() }, { CountryIdentifier.Ireland, new Ireland() }, { CountryIdentifier.Israel, new Israel() },