From 3b5e6cadc233802725a9a5369e26de126c1be315 Mon Sep 17 00:00:00 2001 From: Reagan Reuben Date: Sun, 16 Mar 2025 18:14:31 +0100 Subject: [PATCH] add details for congo, Cook Islands, Costa Rica, Cote D''Ivoire --- .../Countries/CongoTest.cs | 39 +++++++++++ .../Countries/CookIslandsTest.cs | 38 +++++++++++ .../Countries/CostaRicaTest.cs | 39 +++++++++++ .../Countries/CoteDIvoireTest.cs | 39 +++++++++++ src/World.Net/Countries/Congo.cs | 49 +++++++++++++ src/World.Net/Countries/CookIslands.cs | 35 ++++++++++ src/World.Net/Countries/CostaRica.cs | 44 ++++++++++++ src/World.Net/Countries/CoteD'Ivoire.cs | 68 +++++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 6 +- 9 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 src/World.Net.UnitTests/Countries/CongoTest.cs create mode 100644 src/World.Net.UnitTests/Countries/CookIslandsTest.cs create mode 100644 src/World.Net.UnitTests/Countries/CostaRicaTest.cs create mode 100644 src/World.Net.UnitTests/Countries/CoteDIvoireTest.cs create mode 100644 src/World.Net/Countries/Congo.cs create mode 100644 src/World.Net/Countries/CookIslands.cs create mode 100644 src/World.Net/Countries/CostaRica.cs create mode 100644 src/World.Net/Countries/CoteD'Ivoire.cs diff --git a/src/World.Net.UnitTests/Countries/CongoTest.cs b/src/World.Net.UnitTests/Countries/CongoTest.cs new file mode 100644 index 0000000..a54da45 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CongoTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class CongoTest + { + private const string CONGO_NAME = "Congo"; + private const int CONGO_STATE_COUNT = 12; + private const string CONGO_OFFICIAL_NAME = "Democratic Republic of the Congo"; + private const string CONGO_NATIVE_NAME = "République du Congo"; + private const string CONGO_CAPITAL = "Brazzaville"; + private const int CONGO_NUMERIC_CODE = 178; + private const string CONGO_ISO2_CODE = "CG"; + private const string CONGO_ISO3_CODE = "COG"; + private const string CONGO_CALLING_CODE = "+242"; + + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCongo() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Congo; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CONGO_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(CONGO_STATE_COUNT, country.States.Count()); + Assert.Equal(CONGO_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CONGO_NATIVE_NAME, country.NativeName); + Assert.Equal(CONGO_CAPITAL, country.Capital); + Assert.Equal(CONGO_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CONGO_ISO2_CODE, country.ISO2Code); + Assert.Equal(CONGO_ISO3_CODE, country.ISO3Code); + Assert.Equal(CONGO_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/CookIslandsTest.cs b/src/World.Net.UnitTests/Countries/CookIslandsTest.cs new file mode 100644 index 0000000..2e4f1cb --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CookIslandsTest.cs @@ -0,0 +1,38 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class CookIslandsTest + { + private const string COOKISLANDS_NAME = "Cook Islands"; + private const string COOKISLANDS_OFFICIAL_NAME = "Cook Islands"; + private const string COOKISLANDS_NATIVE_NAME = "Cook Islands"; + private const string COOKISLANDS_CAPITAL = "Avarua"; + private const int COOKISLANDS_NUMERIC_CODE = 184; + private const string COOKISLANDS_ISO2_CODE = "CK"; + private const string COOKISLANDS_ISO3_CODE = "COK"; + private const string COOKISLANDS_CALLING_CODE = "+682"; + + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCookIslands() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.CookIslands; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(COOKISLANDS_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Empty(country.States); + Assert.Equal(COOKISLANDS_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(COOKISLANDS_NATIVE_NAME, country.NativeName); + Assert.Equal(COOKISLANDS_CAPITAL, country.Capital); + Assert.Equal(COOKISLANDS_NUMERIC_CODE, country.NumericCode); + Assert.Equal(COOKISLANDS_ISO2_CODE, country.ISO2Code); + Assert.Equal(COOKISLANDS_ISO3_CODE, country.ISO3Code); + Assert.Equal(COOKISLANDS_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/CostaRicaTest.cs b/src/World.Net.UnitTests/Countries/CostaRicaTest.cs new file mode 100644 index 0000000..c69d673 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CostaRicaTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class CostaRicaTest + { + private const string COSTARICA_NAME = "Costa Rica"; + private const int COSTARICA_STATE_COUNT = 7; + private const string COSTARICA_OFFICIAL_NAME = "Republic of Costa Rica"; + private const string COSTARICA_NATIVE_NAME = "Costa Rica"; + private const string COSTARICA_CAPITAL = "San Jose"; + private const int COSTARICA_NUMERIC_CODE = 188; + private const string COSTARICA_ISO2_CODE = "CR"; + private const string COSTARICA_ISO3_CODE = "CRI"; + private const string COSTARICA_CALLING_CODE = "+506"; + + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCostaRica() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.CostaRica; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(COSTARICA_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(COSTARICA_STATE_COUNT, country.States.Count()); + Assert.Equal(COSTARICA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(COSTARICA_NATIVE_NAME, country.NativeName); + Assert.Equal(COSTARICA_CAPITAL, country.Capital); + Assert.Equal(COSTARICA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(COSTARICA_ISO2_CODE, country.ISO2Code); + Assert.Equal(COSTARICA_ISO3_CODE, country.ISO3Code); + Assert.Equal(COSTARICA_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/CoteDIvoireTest.cs b/src/World.Net.UnitTests/Countries/CoteDIvoireTest.cs new file mode 100644 index 0000000..e7a6c19 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CoteDIvoireTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class CoteDIvoireTest + { + private const string COTEDIVOIRE_NAME = "Ivory Coast"; + private const int COTEDIVOIRE_STATE_COUNT = 31; + private const string COTEDIVOIRE_OFFICIAL_NAME = "Republic of Côte d'Ivoire"; + private const string COTEDIVOIRE_NATIVE_NAME = "Côte d'Ivoire"; + private const string COTEDIVOIRE_CAPITAL = "Yamoussoukro"; + private const int COTEDIVOIRE_NUMERIC_CODE = 384; + private const string COTEDIVOIRE_ISO2_CODE = "CI"; + private const string COTEDIVOIRE_ISO3_CODE = "CIV"; + private const string COTEDIVOIRE_CALLING_CODE = "+225"; + + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCookIslands() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.CoteDIvoire; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(COTEDIVOIRE_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(COTEDIVOIRE_STATE_COUNT, country.States.Count()); + Assert.Equal(COTEDIVOIRE_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(COTEDIVOIRE_NATIVE_NAME, country.NativeName); + Assert.Equal(COTEDIVOIRE_CAPITAL, country.Capital); + Assert.Equal(COTEDIVOIRE_NUMERIC_CODE, country.NumericCode); + Assert.Equal(COTEDIVOIRE_ISO2_CODE, country.ISO2Code); + Assert.Equal(COTEDIVOIRE_ISO3_CODE, country.ISO3Code); + Assert.Equal(COTEDIVOIRE_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net/Countries/Congo.cs b/src/World.Net/Countries/Congo.cs new file mode 100644 index 0000000..6e37a74 --- /dev/null +++ b/src/World.Net/Countries/Congo.cs @@ -0,0 +1,49 @@ +namespace World.Net.Countries +{ + internal sealed class Congo : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.Congo; + + /// + public string Name => nameof(Congo); + + /// + public string OfficialName { get; } = "Democratic Republic of the Congo"; + + /// + public string NativeName { get; } = "République du Congo"; + + /// + public string Capital { get; } = "Brazzaville"; + + /// + public int NumericCode { get; } = 178; + + /// + public string ISO2Code { get; } = "CG"; + + /// + public string ISO3Code { get; } = "COG"; + + /// + public string CallingCode { get; } = "+242"; + + /// + public IEnumerable States { get; } = + [ + new("Bouenza", "CG-11", "Department"), + new("Brazzaville", "CG-BZV", "Department"), + new("Cuvette", "CG-8", "Department"), + new("Cuvette-Ouest", "CG-15", "Department"), + new("Kouilou", "CG-5", "Department"), + new("Lékoumou", "CG-2", "Department"), + new("Likouala", "CG-7", "Department"), + new("Niari", "CG-9", "Department"), + new("Plateaux", "CG-14", "Department"), + new("Pointe-Noire", "CG-16", "Department"), + new("Pool", "CG-12", "Department"), + new("Sangha", "CG-13", "Department"), + ]; + } +} diff --git a/src/World.Net/Countries/CookIslands.cs b/src/World.Net/Countries/CookIslands.cs new file mode 100644 index 0000000..b2c1104 --- /dev/null +++ b/src/World.Net/Countries/CookIslands.cs @@ -0,0 +1,35 @@ +namespace World.Net.Countries +{ + internal sealed class CookIslands : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.CookIslands; + + /// + public string Name => "Cook Islands"; + + /// + public string OfficialName { get; } = "Cook Islands"; + + /// + public string NativeName { get; } = "Cook Islands"; + + /// + public string Capital { get; } = "Avarua"; + + /// + public int NumericCode { get; } = 184; + + /// + public string ISO2Code { get; } = "CK"; + + /// + public string ISO3Code { get; } = "COK"; + + /// + public string CallingCode { get; } = "+682"; + + /// + public IEnumerable States { get; } = []; + } +} diff --git a/src/World.Net/Countries/CostaRica.cs b/src/World.Net/Countries/CostaRica.cs new file mode 100644 index 0000000..b947951 --- /dev/null +++ b/src/World.Net/Countries/CostaRica.cs @@ -0,0 +1,44 @@ +namespace World.Net.Countries +{ + internal sealed class CostaRica : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.CostaRica; + + /// + public string Name => "Costa Rica"; + + /// + public string OfficialName { get; } = "Republic of Costa Rica"; + + /// + public string NativeName { get; } = "Costa Rica"; + + /// + public string Capital { get; } = "San Jose"; + + /// + public int NumericCode { get; } = 188; + + /// + public string ISO2Code { get; } = "CR"; + + /// + public string ISO3Code { get; } = "CRI"; + + /// + public string CallingCode { get; } = "+506"; + + /// + public IEnumerable States { get; } = + [ + new("Alajuela", "CR-A", "Province"), + new("Cartago", "CR-C", "Province"), + new("Guanacaste", "CR-G", "Province"), + new("Heredia", "CR-H", "Province"), + new("Limón", "CR-L", "Province"), + new("Puntarenas", "CR-P", "Province"), + new("San José", "CR-SJ", "Province"), + ]; + } +} diff --git a/src/World.Net/Countries/CoteD'Ivoire.cs b/src/World.Net/Countries/CoteD'Ivoire.cs new file mode 100644 index 0000000..a930e54 --- /dev/null +++ b/src/World.Net/Countries/CoteD'Ivoire.cs @@ -0,0 +1,68 @@ +namespace World.Net.Countries +{ + internal sealed class CoteDIvoire : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.CoteDIvoire; + + /// + public string Name => "Ivory Coast"; + + /// + public string OfficialName { get; } = "Republic of Côte d'Ivoire"; + + /// + public string NativeName { get; } = "Côte d'Ivoire"; + + /// + public string Capital { get; } = "Yamoussoukro"; + + /// + public int NumericCode { get; } = 384; + + /// + public string ISO2Code { get; } = "CI"; + + /// + public string ISO3Code { get; } = "CIV"; + + /// + public string CallingCode { get; } = "+225"; + + /// + public IEnumerable States { get; } = + [ + new("Abidjan", "CI-AB", "Autonomous District"), + new("Agnéby", "CI-16", "Region"), + new("Bafing", "CI-17", "Region"), + new("Bas-Sassandra", "CI-BS", "District"), + new("Bas-Sassandra", "CI-09", "Region"), + new("Comoé", "CI-CM", "District"), + new("Denguélé", "CI-DN", "District"), + new("Denguélé", "CI-10", "Region"), + new("Dix-Huit Montagnes", "CI-06", "Region"), + new("Fromager", "CI-18", "Region"), + new("Gôh-Djiboua", "CI-GD", "District"), + new("Haut-Sassandra", "CI-02", "Region"), + new("Lacs", "CI-07", "Region"), + new("Lacs", "CI-LC", "District"), + new("Lagunes", "CI-01", "Region"), + new("Lagunes", "CI-LG", "District"), + new("Marahoué", "CI-12", "Region"), + new("Montagnes", "CI-MG", "District"), + new("Moyen-Cavally", "CI-19", "Region"), + new("Moyen-Comoé", "CI-05", "Region"), + new("N'zi-Comoé", "CI-11", "Region"), + new("Sassandra-Marahoué", "CI-SM", "District"), + new("Savanes", "CI-03", "Region"), + new("Sud-Bandama", "CI-15", "Region"), + new("Sud-Comoé", "CI-13", "Region"), + new("Vallée du Bandama", "CI-04", "Region"), + new("Vallée du Bandama", "CI-VB", "District"), + new("Woroba", "CI-WR", "District"), + new("Worodougou", "CI-14", "Region"), + new("Yamoussoukro", "CI-YM", "District"), + new("Zanzan", "CI-ZZ", "District"), + ]; + } +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 893be47..0cd4ef4 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -45,11 +45,15 @@ 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() }, + { CountryIdentifier.Congo, new Congo() }, + { CountryIdentifier.CostaRica, new CostaRica() }, + { CountryIdentifier.CookIslands, new CookIslands() }, + { CountryIdentifier.CoteDIvoire, new CoteDIvoire() }, // Future countries can be added here in the same format. };