diff --git a/src/World.Net.UnitTests/Countries/ChristmasIslandTest.cs b/src/World.Net.UnitTests/Countries/ChristmasIslandTest.cs new file mode 100644 index 0000000..804615d --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ChristmasIslandTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class ChristmasIslandTest +{ + private const string CHRISTMAS_ISLAND_COUNTRY_NAME = "Christmas Island"; + private const string CHRISTMAS_ISLAND_NATIVE_NAME = "Christmas Island"; + private const string CHRISTMAS_ISLAND_CAPITAL = "Flying Fish Cove"; + private const string CHRISTMAS_ISLAND_OFFICIAL_NAME = "Territory of Christmas Island"; + private const string CHRISTMAS_ISLAND_ISO2_CODE = "CX"; + private const string CHRISTMAS_ISLAND_ISO3_CODE = "CXR"; + private const int CHRISTMAS_ISLAND_NUMERIC_CODE = 162; + private const string CHRISTMAS_ISLAND_CALLING_CODE = "+61"; + private static readonly string[] VALID_STATE_TYPES = { }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForChristmasIsland() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.ChristmasIsland; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CHRISTMAS_ISLAND_COUNTRY_NAME, country.Name); + Assert.Equal(CHRISTMAS_ISLAND_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CHRISTMAS_ISLAND_NATIVE_NAME, country.NativeName); + Assert.Equal(CHRISTMAS_ISLAND_CAPITAL, country.Capital); + Assert.Equal(CHRISTMAS_ISLAND_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CHRISTMAS_ISLAND_ISO2_CODE, country.ISO2Code); + Assert.Equal(CHRISTMAS_ISLAND_ISO3_CODE, country.ISO3Code); + Assert.Equal(CHRISTMAS_ISLAND_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Empty(country.States); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net.UnitTests/Countries/CocosKeelingIslandsTest.cs b/src/World.Net.UnitTests/Countries/CocosKeelingIslandsTest.cs new file mode 100644 index 0000000..adc1c97 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CocosKeelingIslandsTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CocosKeelingIslandsTest +{ + private const string COCOS_COUNTRY_NAME = "Cocos (Keeling) Islands"; + private const string COCOS_NATIVE_NAME = "Pulu Kokos (Malay)"; + private const string COCOS_CAPITAL = "West Island"; + private const string COCOS_OFFICIAL_NAME = "Territory of Cocos (Keeling) Islands"; + private const string COCOS_ISO2_CODE = "CC"; + private const string COCOS_ISO3_CODE = "CCK"; + private const int COCOS_NUMERIC_CODE = 166; + private const string COCOS_CALLING_CODE = "+61"; + private const int COCOS_STATE_COUNT = 2; + private static readonly string[] VALID_STATE_TYPES = { "Island" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCocosKeelingIslands() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.CocosKeelingIslands; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(COCOS_COUNTRY_NAME, country.Name); + Assert.Equal(COCOS_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(COCOS_NATIVE_NAME, country.NativeName); + Assert.Equal(COCOS_CAPITAL, country.Capital); + Assert.Equal(COCOS_NUMERIC_CODE, country.NumericCode); + Assert.Equal(COCOS_ISO2_CODE, country.ISO2Code); + Assert.Equal(COCOS_ISO3_CODE, country.ISO3Code); + Assert.Equal(COCOS_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(COCOS_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/ColombiaTest.cs b/src/World.Net.UnitTests/Countries/ColombiaTest.cs new file mode 100644 index 0000000..5ef0f12 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ColombiaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class ColombiaTest +{ + private const string COLOMBIA_COUNTRY_NAME = "Colombia"; + private const string COLOMBIA_NATIVE_NAME = "Colombia"; + private const string COLOMBIA_CAPITAL = "Bogotá"; + private const string COLOMBIA_OFFICIAL_NAME = "Republic of Colombia"; + private const string COLOMBIA_ISO2_CODE = "CO"; + private const string COLOMBIA_ISO3_CODE = "COL"; + private const int COLOMBIA_NUMERIC_CODE = 170; + private const string COLOMBIA_CALLING_CODE = "+57"; + private const int COLOMBIA_STATE_COUNT = 32; + private static readonly string[] VALID_STATE_TYPES = { "Department", "Capital District" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForColombia() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Colombia; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(COLOMBIA_COUNTRY_NAME, country.Name); + Assert.Equal(COLOMBIA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(COLOMBIA_NATIVE_NAME, country.NativeName); + Assert.Equal(COLOMBIA_CAPITAL, country.Capital); + Assert.Equal(COLOMBIA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(COLOMBIA_ISO2_CODE, country.ISO2Code); + Assert.Equal(COLOMBIA_ISO3_CODE, country.ISO3Code); + Assert.Equal(COLOMBIA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(COLOMBIA_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/ComorosTest.cs b/src/World.Net.UnitTests/Countries/ComorosTest.cs new file mode 100644 index 0000000..a1f82e6 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ComorosTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class ComorosTest +{ + private const string COMOROS_COUNTRY_NAME = "Comoros"; + private const string COMOROS_NATIVE_NAME = "Komori"; + private const string COMOROS_CAPITAL = "Moroni"; + private const string COMOROS_OFFICIAL_NAME = "Union of the Comoros"; + private const string COMOROS_ISO2_CODE = "KM"; + private const string COMOROS_ISO3_CODE = "COM"; + private const int COMOROS_NUMERIC_CODE = 174; + private const string COMOROS_CALLING_CODE = "+269"; + private const int COMOROS_STATE_COUNT = 3; + private static readonly string[] VALID_STATE_TYPES = { "Autonomous Island" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForComoros() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Comoros; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(COMOROS_COUNTRY_NAME, country.Name); + Assert.Equal(COMOROS_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(COMOROS_NATIVE_NAME, country.NativeName); + Assert.Equal(COMOROS_CAPITAL, country.Capital); + Assert.Equal(COMOROS_NUMERIC_CODE, country.NumericCode); + Assert.Equal(COMOROS_ISO2_CODE, country.ISO2Code); + Assert.Equal(COMOROS_ISO3_CODE, country.ISO3Code); + Assert.Equal(COMOROS_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(COMOROS_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net/Countries/ChristmasIsland.cs b/src/World.Net/Countries/ChristmasIsland.cs new file mode 100644 index 0000000..7f3d412 --- /dev/null +++ b/src/World.Net/Countries/ChristmasIsland.cs @@ -0,0 +1,37 @@ +namespace World.Net.Countries; + +internal sealed class ChristmasIsland : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.ChristmasIsland; + + // + public string Name { get; } = "Christmas Island"; + + // + public string OfficialName { get; } = "Territory of Christmas Island"; + + // + public string NativeName => "Christmas Island"; + + // + public string Capital { get; } = "Flying Fish Cove"; + + // + public int NumericCode { get; } = 162; + + // + public string ISO2Code { get; } = "CX"; + + // + public string ISO3Code { get; } = "CXR"; + + // + public string CallingCode { get; } = "+61"; + + // + public IEnumerable States => + [ + + ]; +} diff --git a/src/World.Net/Countries/CocosKeelingIslands.cs b/src/World.Net/Countries/CocosKeelingIslands.cs new file mode 100644 index 0000000..4690f91 --- /dev/null +++ b/src/World.Net/Countries/CocosKeelingIslands.cs @@ -0,0 +1,38 @@ +namespace World.Net.Countries; + +internal sealed class CocosKeelingIslands : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.CocosKeelingIslands; + + // + public string Name { get; } = "Cocos (Keeling) Islands"; + + // + public string OfficialName { get; } = "Territory of Cocos (Keeling) Islands"; + + // + public string NativeName => "Pulu Kokos (Malay)"; + + // + public string Capital { get; } = "West Island"; + + // + public int NumericCode { get; } = 166; + + // + public string ISO2Code { get; } = "CC"; + + // + public string ISO3Code { get; } = "CCK"; + + // + public string CallingCode { get; } = "+61"; + + // + public IEnumerable States => + [ + new("West Island", "CC-WI", "Island"), + new("Home Island", "CC-HI", "Island") + ]; +} diff --git a/src/World.Net/Countries/Colombia.cs b/src/World.Net/Countries/Colombia.cs new file mode 100644 index 0000000..9467f0d --- /dev/null +++ b/src/World.Net/Countries/Colombia.cs @@ -0,0 +1,68 @@ +namespace World.Net.Countries; + +internal sealed class Colombia : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Colombia; + + // + public string Name { get; } = "Colombia"; + + // + public string OfficialName { get; } = "Republic of Colombia"; + + // + public string NativeName => "Colombia"; + + // + public string Capital { get; } = "Bogotá"; + + // + public int NumericCode { get; } = 170; + + // + public string ISO2Code { get; } = "CO"; + + // + public string ISO3Code { get; } = "COL"; + + // + public string CallingCode { get; } = "+57"; + + // + public IEnumerable States => + [ + new("Amazonas", "CO-AMA", "Department"), + new("Antioquia", "CO-ANT", "Department"), + new("Arauca", "CO-ARA", "Department"), + new("Atlántico", "CO-ATL", "Department"), + new("Bolívar", "CO-BOL", "Department"), + new("Boyacá", "CO-BOY", "Department"), + new("Caldas", "CO-CAL", "Department"), + new("Caquetá", "CO-CAQ", "Department"), + new("Casanare", "CO-CAS", "Department"), + new("Cauca", "CO-CAU", "Department"), + new("Cesar", "CO-CES", "Department"), + new("Chocó", "CO-CHO", "Department"), + new("Córdoba", "CO-COR", "Department"), + new("Cundinamarca", "CO-CUN", "Department"), + new("Guainía", "CO-GUA", "Department"), + new("Guaviare", "CO-GUV", "Department"), + new("Huila", "CO-HUI", "Department"), + new("La Guajira", "CO-LAG", "Department"), + new("Magdalena", "CO-MAG", "Department"), + new("Meta", "CO-MET", "Department"), + new("Nariño", "CO-NAR", "Department"), + new("Norte de Santander", "CO-NSA", "Department"), + new("Putumayo", "CO-PUT", "Department"), + new("Quindío", "CO-QUI", "Department"), + new("Risaralda", "CO-RIS", "Department"), + new("San Andrés, Providencia and Santa Catalina", "CO-SAP", "Department"), + new("Santander", "CO-SAN", "Department"), + new("Sucre", "CO-SUC", "Department"), + new("Tolima", "CO-TOL", "Department"), + new("Valle del Cauca", "CO-VAC", "Department"), + new("Vaupés", "CO-VAU", "Department"), + new("Vichada", "CO-VIC", "Department") + ]; +} diff --git a/src/World.Net/Countries/Comoros.cs b/src/World.Net/Countries/Comoros.cs new file mode 100644 index 0000000..2a1d83e --- /dev/null +++ b/src/World.Net/Countries/Comoros.cs @@ -0,0 +1,39 @@ +namespace World.Net.Countries; + +internal sealed class Comoros : ICountry +{ + // + public CountryIdentifier Id => CountryIdentifier.Comoros; + + // + public string Name { get; } = "Comoros"; + + // + public string OfficialName { get; } = "Union of the Comoros"; + + // + public string NativeName => "Komori"; + + // + public string Capital { get; } = "Moroni"; + + // + public int NumericCode { get; } = 174; + + // + public string ISO2Code { get; } = "KM"; + + // + public string ISO3Code { get; } = "COM"; + + // + public string CallingCode { get; } = "+269"; + + // + public IEnumerable States => + [ + new("Anjouan", "KM-A", "Autonomous Island"), + new("Grande Comore", "KM-G", "Autonomous Island"), + new("Mohéli", "KM-M", "Autonomous Island") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index cc6cb53..893be47 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -45,7 +45,11 @@ public static Dictionary Initialize() { CountryIdentifier.Cambodia, new Cambodia() }, { CountryIdentifier.Cameroon, new Cameroon() }, { CountryIdentifier.Canada, new Canada() }, - { CountryIdentifier.CapeVerde, new CapeVerde() }, + { CountryIdentifier.CapeVerde, new CapeVerde() }, + { CountryIdentifier.ChristmasIsland, new ChristmasIsland() }, + { CountryIdentifier.CocosKeelingIslands, new CocosKeelingIslands() }, + { CountryIdentifier.Colombia, new Colombia() }, + { CountryIdentifier.Comoros, new Comoros() }, // Future countries can be added here in the same format. };