diff --git a/src/World.Net.UnitTests/Countries/EstoniaTest.cs b/src/World.Net.UnitTests/Countries/EstoniaTest.cs new file mode 100644 index 0000000..e9a235d --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EstoniaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class EstoniaTest + { + private const string ESTONIA_NAME = "Estonia"; + private const int ESTONIA_STATE_COUNT = 15; + private const string ESTONIA_OFFICIAL_NAME = "Republic of Estonia"; + private const string ESTONIA_NATIVE_NAME = "Eesti"; + private const string ESTONIA_CAPITAL = "Tallinn"; + private const int ESTONIA_NUMERIC_CODE = 233; + private const string ESTONIA_ISO2_CODE = "EE"; + private const string ESTONIA_ISO3_CODE = "EST"; + private readonly string[] ESTONIA_CALLING_CODE = ["372"]; + private static readonly string[] VALID_STATE_TYPES = { "County" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEstonia() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Estonia; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(ESTONIA_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(ESTONIA_STATE_COUNT, country.States.Count()); + Assert.Equal(ESTONIA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(ESTONIA_NATIVE_NAME, country.NativeName); + Assert.Equal(ESTONIA_CAPITAL, country.Capital); + Assert.Equal(ESTONIA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(ESTONIA_ISO2_CODE, country.ISO2Code); + Assert.Equal(ESTONIA_ISO3_CODE, country.ISO3Code); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + Assert.Equal(ESTONIA_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/EswatiniTest.cs b/src/World.Net.UnitTests/Countries/EswatiniTest.cs new file mode 100644 index 0000000..4ea9a4e --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EswatiniTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries +{ + public class EswatiniTest + { + private const string ESWATINI_NAME = "Eswatini"; + private const int ESWATINI_STATE_COUNT = 4; + private const string ESWATINI_OFFICIAL_NAME = "Kingdom of Eswatini"; + private const string ESWATINI_NATIVE_NAME = "eSwatini"; + private const string ESWATINI_CAPITAL = "Mbabane"; + private const int ESWATINI_NUMERIC_CODE = 748; + private const string ESWATINI_ISO2_CODE = "SZ"; + private const string ESWATINI_ISO3_CODE = "SWZ"; + private readonly string[] ESWATINI_CALLING_CODE = ["268"]; + private static readonly string[] VALID_STATE_TYPES = { "Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEswatini() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Eswatini; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(ESWATINI_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(ESWATINI_STATE_COUNT, country.States.Count()); + Assert.Equal(ESWATINI_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(ESWATINI_NATIVE_NAME, country.NativeName); + Assert.Equal(ESWATINI_CAPITAL, country.Capital); + Assert.Equal(ESWATINI_NUMERIC_CODE, country.NumericCode); + Assert.Equal(ESWATINI_ISO2_CODE, country.ISO2Code); + Assert.Equal(ESWATINI_ISO3_CODE, country.ISO3Code); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + Assert.Equal(ESWATINI_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/EthiopiaTest.cs b/src/World.Net.UnitTests/Countries/EthiopiaTest.cs new file mode 100644 index 0000000..606a0e9 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/EthiopiaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class EthiopiaTest + { + private const string ETHIOPIA_NAME = "Ethiopia"; + private const int ETHIOPIA_STATE_COUNT = 12; + private const string ETHIOPIA_OFFICIAL_NAME = "Federal Democratic Republic of Ethiopia"; + private const string ETHIOPIA_NATIVE_NAME = "ኢትዮጵያ"; + private const string ETHIOPIA_CAPITAL = "Addis Ababa"; + private const int ETHIOPIA_NUMERIC_CODE = 231; + private const string ETHIOPIA_ISO2_CODE = "ET"; + private const string ETHIOPIA_ISO3_CODE = "ETH"; + private readonly string[] ETHIOPIA_CALLING_CODE = ["251"]; + private static readonly string[] VALID_STATE_TYPES = { "Region", "Administration" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForEthiopia() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Ethiopia; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(ETHIOPIA_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(ETHIOPIA_STATE_COUNT, country.States.Count()); + Assert.Equal(ETHIOPIA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(ETHIOPIA_NATIVE_NAME, country.NativeName); + Assert.Equal(ETHIOPIA_CAPITAL, country.Capital); + Assert.Equal(ETHIOPIA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(ETHIOPIA_ISO2_CODE, country.ISO2Code); + Assert.Equal(ETHIOPIA_ISO3_CODE, country.ISO3Code); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + Assert.Equal(ETHIOPIA_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs b/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs new file mode 100644 index 0000000..c8c8d7d --- /dev/null +++ b/src/World.Net.UnitTests/Countries/FalklandIslandsTest.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace World.Net.UnitTests.Countries +{ + public sealed class FalklandIslandsTest + { + private const string FALKLANDS_NAME = "FalklandIslands"; + private const string FALKLANDS_OFFICIAL_NAME = "Falkland Islands"; + private const string FALKLANDS_NATIVE_NAME = "Falkland Islands"; + private const string FALKLANDS_CAPITAL = "Stanley"; + private const int FALKLANDS_NUMERIC_CODE = 238; + private const string FALKLANDS_ISO2_CODE = "FK"; + private const string FALKLANDS_ISO3_CODE = "FLK"; + private readonly string[] FALKLANDS_CALLING_CODE = ["500"]; + private static readonly string[] VALID_STATE_TYPES = { "Overseas Territory" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForFalklandIslands() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.FalklandIslands; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(FALKLANDS_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Single(country.States); + Assert.Equal(FALKLANDS_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(FALKLANDS_NATIVE_NAME, country.NativeName); + Assert.Equal(FALKLANDS_CAPITAL, country.Capital); + Assert.Equal(FALKLANDS_NUMERIC_CODE, country.NumericCode); + Assert.Equal(FALKLANDS_ISO2_CODE, country.ISO2Code); + Assert.Equal(FALKLANDS_ISO3_CODE, country.ISO3Code); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + Assert.Equal(FALKLANDS_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net/Countries/Estonia.cs b/src/World.Net/Countries/Estonia.cs new file mode 100644 index 0000000..162b4c8 --- /dev/null +++ b/src/World.Net/Countries/Estonia.cs @@ -0,0 +1,43 @@ + +namespace World.Net.Countries +{ + internal sealed class Estonia : ICountry + { + public CountryIdentifier Id => CountryIdentifier.Estonia; + + public string Name => nameof(Estonia); + + public string OfficialName => "Republic of Estonia"; + + public string NativeName => "Eesti"; + + public string Capital => "Tallinn"; + + public int NumericCode => 233; + + public string ISO2Code => "EE"; + + public string ISO3Code => "EST"; + + public string[] CallingCode => ["372"]; + + public IEnumerable States => + [ + new("Harju", "37", "County"), + new("Hiiu", "39", "County"), + new("Ida-Viru", "44", "County"), + new("Jõgeva", "49", "County"), + new("Järva", "51", "County"), + new("Lääne", "57", "County"), + new("Lääne-Viru", "59", "County"), + new("Põlva", "65", "County"), + new("Pärnu", "67", "County"), + new("Rapla", "70", "County"), + new("Saare", "74", "County"), + new("Tartu", "78", "County"), + new("Valga", "82", "County"), + new("Viljandi", "84", "County"), + new("Võru", "86", "County") + ]; + } +} diff --git a/src/World.Net/Countries/Eswatini.cs b/src/World.Net/Countries/Eswatini.cs new file mode 100644 index 0000000..9ecce67 --- /dev/null +++ b/src/World.Net/Countries/Eswatini.cs @@ -0,0 +1,32 @@ +namespace World.Net.Countries +{ + internal sealed class Eswatini : ICountry + { + public CountryIdentifier Id => CountryIdentifier.Eswatini; + + public string Name => nameof(Eswatini); + + public string OfficialName => "Kingdom of Eswatini"; + + public string NativeName => "eSwatini"; + + public string Capital => "Mbabane"; + + public int NumericCode => 748; + + public string ISO2Code => "SZ"; + + public string ISO3Code => "SWZ"; + + public string[] CallingCode => ["268"]; + + public IEnumerable States => + [ + new State("Hhohho", "HH", "Region"), + new State("Lubombo", "LU", "Region"), + new State("Manzini", "MA", "Region"), + new State("Shiselweni", "SH", "Region") + ]; + } + +} diff --git a/src/World.Net/Countries/Ethiopia.cs b/src/World.Net/Countries/Ethiopia.cs new file mode 100644 index 0000000..4c74fc8 --- /dev/null +++ b/src/World.Net/Countries/Ethiopia.cs @@ -0,0 +1,39 @@ +namespace World.Net.Countries +{ + internal sealed class Ethiopia : ICountry + { + public CountryIdentifier Id => CountryIdentifier.Ethiopia; + + public string Name => nameof(Ethiopia); + + public string OfficialName => "Federal Democratic Republic of Ethiopia"; + + public string NativeName => "ኢትዮጵያ"; + + public string Capital => "Addis Ababa"; + + public int NumericCode => 231; + + public string ISO2Code => "ET"; + + public string ISO3Code => "ETH"; + + public string[] CallingCode => ["251"]; + + public IEnumerable States => + [ + new("Addis Ababa", "AA", "Administration"), + new("Afar", "AF", "Region"), + new("Amhara", "AM", "Region"), + new("Benishangul-Gumuz", "BE", "Region"), + new("Dire Dawa", "DD", "Administration"), + new("Gambela", "GA", "Region"), + new("Harari", "HA", "Region"), + new("Oromia", "OR", "Region"), + new("Sidama", "SI", "Region"), + new("Somali", "SO", "Region"), + new("Southern Nations, Nationalities, and Peoples' Region", "SN", "Region"), + new("Tigray", "TI", "Region") + ]; + } +} diff --git a/src/World.Net/Countries/FalklandIslands.cs b/src/World.Net/Countries/FalklandIslands.cs new file mode 100644 index 0000000..765cad3 --- /dev/null +++ b/src/World.Net/Countries/FalklandIslands.cs @@ -0,0 +1,29 @@ +namespace World.Net.Countries +{ + internal sealed class FalklandIslands : ICountry + { + public CountryIdentifier Id => CountryIdentifier.FalklandIslands; + + public string Name => nameof(FalklandIslands); + + public string OfficialName => "Falkland Islands"; + + public string NativeName => "Falkland Islands"; + + public string Capital => "Stanley"; + + public int NumericCode => 238; + + public string ISO2Code => "FK"; + + public string ISO3Code => "FLK"; + + public string[] CallingCode => ["500"]; + + public IEnumerable States => + [ + new("Falkland Islands", "FK", "Overseas Territory") + ]; + } + +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index e898d83..0f9c8e1 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -71,6 +71,10 @@ public static Dictionary Initialize() { CountryIdentifier.TimorLeste, new TimorLeste() }, { CountryIdentifier.Ecuador, new Ecuador() }, { CountryIdentifier.Egypt, new Egypt() }, + { CountryIdentifier.Estonia, new Estonia() }, + { CountryIdentifier.Ethiopia, new Ethiopia() }, + { CountryIdentifier.Eswatini, new Eswatini() }, + { CountryIdentifier.FalklandIslands, new FalklandIslands() }, { CountryIdentifier.FaroeIslands, new FaroeIslands() }, { CountryIdentifier.FijiIslands, new FijiIslands() }, { CountryIdentifier.Finland, new Finland() },