diff --git a/src/World.Net.UnitTests/Countries/DenmarkTest.cs b/src/World.Net.UnitTests/Countries/DenmarkTest.cs new file mode 100644 index 0000000..60e7d7f --- /dev/null +++ b/src/World.Net.UnitTests/Countries/DenmarkTest.cs @@ -0,0 +1,38 @@ +namespace World.Net.UnitTests.Countries; +public sealed class DenmarkTest +{ + private const string DENMARK_NAME = "Denmark"; + private const int DENMARK_STATE_COUNT = 5; + private const string DENMARK_OFFICIAL_NAME = "Kingdom of Denmark"; + private const string DENMARK_NATIVE_NAME = "Danmark"; + private const string DENMARK_CAPITAL = "Copenhagen"; + private const int DENMARK_NUMERIC_CODE = 208; + private const string DENMARK_ISO2_CODE = "DK"; + private const string DENMARK_ISO3_CODE = "DNK"; + private readonly string[] DENMARK_CALLING_CODE = ["+45"]; + private static readonly string[] VALID_STATE_TYPES = { "Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForDenmark() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Denmark; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(DENMARK_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(DENMARK_STATE_COUNT, country.States.Count()); + Assert.Equal(DENMARK_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(DENMARK_NATIVE_NAME, country.NativeName); + Assert.Equal(DENMARK_CAPITAL, country.Capital); + Assert.Equal(DENMARK_NUMERIC_CODE, country.NumericCode); + Assert.Equal(DENMARK_ISO2_CODE, country.ISO2Code); + Assert.Equal(DENMARK_ISO3_CODE, country.ISO3Code); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + Assert.Equal(DENMARK_CALLING_CODE, country.CallingCode); + } +} diff --git a/src/World.Net.UnitTests/Countries/DjiboutiTest.cs b/src/World.Net.UnitTests/Countries/DjiboutiTest.cs new file mode 100644 index 0000000..3427822 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/DjiboutiTest.cs @@ -0,0 +1,38 @@ +namespace World.Net.UnitTests.Countries; +public sealed class DjiboutiTest +{ + private const string DJIBOUTI_NAME = "Djibouti"; + private const int DJIBOUTI_STATE_COUNT = 6; + private const string DJIBOUTI_OFFICIAL_NAME = "Republic of Djibouti"; + private const string DJIBOUTI_NATIVE_NAME = "Djibouti"; + private const string DJIBOUTI_CAPITAL = "Djibouti"; + private const int DJIBOUTI_NUMERIC_CODE = 262; + private const string DJIBOUTI_ISO2_CODE = "DJ"; + private const string DJIBOUTI_ISO3_CODE = "DJI"; + private static readonly string[] VALID_STATE_TYPES = { "Region", "City" }; + private readonly string[] DJIBOUTI_CALLING_CODE = ["+253"]; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForDjibouti() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Djibouti; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(DJIBOUTI_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(DJIBOUTI_STATE_COUNT, country.States.Count()); + Assert.Equal(DJIBOUTI_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(DJIBOUTI_NATIVE_NAME, country.NativeName); + Assert.Equal(DJIBOUTI_CAPITAL, country.Capital); + Assert.Equal(DJIBOUTI_NUMERIC_CODE, country.NumericCode); + Assert.Equal(DJIBOUTI_ISO2_CODE, country.ISO2Code); + Assert.Equal(DJIBOUTI_ISO3_CODE, country.ISO3Code); + Assert.Equal(DJIBOUTI_CALLING_CODE, country.CallingCode); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net.UnitTests/Countries/DominicaTest.cs b/src/World.Net.UnitTests/Countries/DominicaTest.cs new file mode 100644 index 0000000..0c838f9 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/DominicaTest.cs @@ -0,0 +1,38 @@ +namespace World.Net.UnitTests.Countries; +public sealed class DominicaTest +{ + private const string DOMINICA_NAME = "Dominica"; + private const int DOMINICA_STATE_COUNT = 10; + private const string DOMINICA_OFFICIAL_NAME = "Commonwealth of Dominica"; + private const string DOMINICA_NATIVE_NAME = "Dominica"; + private const string DOMINICA_CAPITAL = "Roseau"; + private const int DOMINICA_NUMERIC_CODE = 212; + private const string DOMINICA_ISO2_CODE = "DM"; + private const string DOMINICA_ISO3_CODE = "DMA"; + private static readonly string[] VALID_STATE_TYPES = { "Parish" }; + private readonly string[] DOMINICA_CALLING_CODE = ["+1-767"]; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForDominica() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Dominica; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(DOMINICA_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(DOMINICA_STATE_COUNT, country.States.Count()); + Assert.Equal(DOMINICA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(DOMINICA_NATIVE_NAME, country.NativeName); + Assert.Equal(DOMINICA_CAPITAL, country.Capital); + Assert.Equal(DOMINICA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(DOMINICA_ISO2_CODE, country.ISO2Code); + Assert.Equal(DOMINICA_ISO3_CODE, country.ISO3Code); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + Assert.Equal(DOMINICA_CALLING_CODE, country.CallingCode); + } +} diff --git a/src/World.Net/Countries/Denmark.cs b/src/World.Net/Countries/Denmark.cs new file mode 100644 index 0000000..5ef09fb --- /dev/null +++ b/src/World.Net/Countries/Denmark.cs @@ -0,0 +1,40 @@ +namespace World.Net.Countries; +internal sealed class Denmark : ICountry +{ + /// + public CountryIdentifier Id => CountryIdentifier.Denmark; + + /// + public string Name => nameof(Denmark); + + /// + public string OfficialName { get; } = "Kingdom of Denmark"; + + /// + public string NativeName { get; } = "Danmark"; + + /// + public string Capital { get; } = "Copenhagen"; + + /// + public int NumericCode { get; } = 208; + + /// + public string ISO2Code { get; } = "DK"; + + /// + public string ISO3Code { get; } = "DNK"; + + /// + public string[] CallingCode { get; } = ["+45"]; + + /// + public IEnumerable States { get; } = + [ + new("Central Denmark", "DK-82", "Region"), + new("Capital Region of Denmark", "DK-84", "Region"), + new("North Denmark", "DK-81", "Region"), + new("Southern Denmark", "DK-83", "Region"), + new("Zealand", "DK-85", "Region"), + ]; +} diff --git a/src/World.Net/Countries/Djibouti.cs b/src/World.Net/Countries/Djibouti.cs new file mode 100644 index 0000000..aff884c --- /dev/null +++ b/src/World.Net/Countries/Djibouti.cs @@ -0,0 +1,41 @@ +namespace World.Net.Countries; +internal sealed class Djibouti : ICountry +{ + /// + public CountryIdentifier Id => CountryIdentifier.Djibouti; + + /// + public string Name => nameof(Djibouti); + + /// + public string OfficialName { get; } = "Republic of Djibouti"; + + /// + public string NativeName { get; } = "Djibouti"; + + /// + public string Capital { get; } = "Djibouti"; + + /// + public int NumericCode { get; } = 262; + + /// + public string ISO2Code { get; } = "DJ"; + + /// + public string ISO3Code { get; } = "DJI"; + + /// + public string[] CallingCode { get; } = ["+253"]; + + /// + public IEnumerable States { get; } = + [ + new("Ali Sabieh", "DJ-AS", "Region"), + new("Arta", "DJ-AR", "Region"), + new("Dikhil", "DJ-DI", "Region"), + new("Djibouti", "DJ-DJ", "City"), + new("Obock", "DJ-OB", "Region"), + new("Tadjourah", "DJ-TA", "Region"), + ]; +} diff --git a/src/World.Net/Countries/Dominica.cs b/src/World.Net/Countries/Dominica.cs new file mode 100644 index 0000000..35c01f4 --- /dev/null +++ b/src/World.Net/Countries/Dominica.cs @@ -0,0 +1,45 @@ +namespace World.Net.Countries; +internal sealed class Dominica : ICountry +{ + /// + public CountryIdentifier Id => CountryIdentifier.Dominica; + + /// + public string Name => nameof(Dominica); + + /// + public string OfficialName { get; } = "Commonwealth of Dominica"; + + /// + public string NativeName { get; } = "Dominica"; + + /// + public string Capital { get; } = "Roseau"; + + /// + public int NumericCode { get; } = 212; + + /// + public string ISO2Code { get; } = "DM"; + + /// + public string ISO3Code { get; } = "DMA"; + + /// + public string[] CallingCode { get; } = ["+1-767"]; + + /// + public IEnumerable States { get; } = + [ + new("Saint Andrew", "DM-02", "Parish"), + new("Saint David", "DM-03", "Parish"), + new("Saint George", "DM-04", "Parish"), + new("Saint John", "DM-05", "Parish"), + new("Saint Joseph", "DM-06", "Parish"), + new("Saint Luke", "DM-07", "Parish"), + new("Saint Mark", "DM-08", "Parish"), + new("Saint Patrick", "DM-09", "Parish"), + new("Saint Paul", "DM-10", "Parish"), + new("Saint Peter", "DM-11", "Parish"), + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index b3747cf..cef1808 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -45,12 +45,12 @@ public static Dictionary Initialize() { CountryIdentifier.Cambodia, new Cambodia() }, { CountryIdentifier.Cameroon, new Cameroon() }, { CountryIdentifier.Canada, new Canada() }, - { CountryIdentifier.CapeVerde, new CapeVerde() }, - { CountryIdentifier.CaymanIslands, new CaymanIslands() }, - { CountryIdentifier.CentralAfricanRepublic, new CentralAfricanRepublic() }, - { CountryIdentifier.Chad, new Chad() }, - { CountryIdentifier.Chile, new Chile() }, - { CountryIdentifier.China, new China() }, + { CountryIdentifier.CapeVerde, new CapeVerde() }, + { CountryIdentifier.CaymanIslands, new CaymanIslands() }, + { CountryIdentifier.CentralAfricanRepublic, new CentralAfricanRepublic() }, + { CountryIdentifier.Chad, new Chad() }, + { CountryIdentifier.Chile, new Chile() }, + { CountryIdentifier.China, new China() }, { CountryIdentifier.ChristmasIsland, new ChristmasIsland() }, { CountryIdentifier.CocosKeelingIslands, new CocosKeelingIslands() }, { CountryIdentifier.Colombia, new Colombia() }, @@ -68,6 +68,9 @@ public static Dictionary Initialize() { CountryIdentifier.TimorLeste, new TimorLeste() }, { CountryIdentifier.Ecuador, new Ecuador() }, { CountryIdentifier.Egypt, new Egypt() }, + { CountryIdentifier.Denmark, new Denmark() }, + { CountryIdentifier.Djibouti, new Djibouti() }, + { CountryIdentifier.Dominica, new Dominica() }, // Future countries can be added here in the same format. };