From e38f799ddf1ef5c376d46077ed8ca1f78a03798f Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 4 Mar 2025 22:20:37 +0100 Subject: [PATCH 01/16] add details for cayman island --- src/World.Net/Countries/CaymanIslands.cs | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/World.Net/Countries/CaymanIslands.cs diff --git a/src/World.Net/Countries/CaymanIslands.cs b/src/World.Net/Countries/CaymanIslands.cs new file mode 100644 index 0000000..084dd23 --- /dev/null +++ b/src/World.Net/Countries/CaymanIslands.cs @@ -0,0 +1,25 @@ + +namespace World.Net.Countries; + +internal sealed class CaymanIslands : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.CaymanIslands; + + public string Name => "Cayman Islands"; + + public string OfficialName => "Cayman Islands"; + + public string NativeName => "Cayman Islands"; + + public string Capital => throw new NotImplementedException(); + + public int NumericCode => throw new NotImplementedException(); + + public string ISO2Code => throw new NotImplementedException(); + + public string ISO3Code => throw new NotImplementedException(); + + public string CallingCode => throw new NotImplementedException(); + + public IEnumerable States => throw new NotImplementedException(); +} From 55ac9ab782a9db21b3ea54d2e5b24d405488a988 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 4 Mar 2025 22:30:31 +0100 Subject: [PATCH 02/16] updated cay man island --- src/World.Net/Countries/CaymanIslands.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/World.Net/Countries/CaymanIslands.cs b/src/World.Net/Countries/CaymanIslands.cs index 084dd23..3e84c0d 100644 --- a/src/World.Net/Countries/CaymanIslands.cs +++ b/src/World.Net/Countries/CaymanIslands.cs @@ -11,15 +11,20 @@ internal sealed class CaymanIslands : ICountry public string NativeName => "Cayman Islands"; - public string Capital => throw new NotImplementedException(); + public string Capital => "George Town"; - public int NumericCode => throw new NotImplementedException(); + public int NumericCode => 136; - public string ISO2Code => throw new NotImplementedException(); + public string ISO2Code => "KY"; - public string ISO3Code => throw new NotImplementedException(); + public string ISO3Code => "CYM"; - public string CallingCode => throw new NotImplementedException(); + public string CallingCode => "+1 345"; - public IEnumerable States => throw new NotImplementedException(); + public IEnumerable States => + [ + new("Cayman Brac", "", ""), + new("Grand Cayman", "", ""), + new("Little Cayman", "", "") + ]; } From d1bb10a5159a5367425bdf43b1038aab86906e0b Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 13 Mar 2025 22:49:37 +0100 Subject: [PATCH 03/16] remove blank line --- src/World.Net/Countries/CaymanIslands.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/World.Net/Countries/CaymanIslands.cs b/src/World.Net/Countries/CaymanIslands.cs index 3e84c0d..fc2a714 100644 --- a/src/World.Net/Countries/CaymanIslands.cs +++ b/src/World.Net/Countries/CaymanIslands.cs @@ -1,5 +1,4 @@ - -namespace World.Net.Countries; +namespace World.Net.Countries; internal sealed class CaymanIslands : ICountry { From 7c43ed19206243ebd626e7273a79fdb9e0f12a30 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Thu, 13 Mar 2025 22:55:21 +0100 Subject: [PATCH 04/16] CaymanIslands tests --- .../Countries/CaymanIslandsTest.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs diff --git a/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs b/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs new file mode 100644 index 0000000..14ce15a --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace World.Net.UnitTests.Countries +{ + class CaymanIslandsTest + { + } +} From 03146081d7c147a85ed92fd1d1cc524d9bff9da3 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Fri, 14 Mar 2025 08:25:59 +0100 Subject: [PATCH 05/16] add cayman island to country initializer --- src/World.Net/Helpers/CountryInitializer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index cc6cb53..1e45c14 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -46,6 +46,7 @@ public static Dictionary Initialize() { CountryIdentifier.Cameroon, new Cameroon() }, { CountryIdentifier.Canada, new Canada() }, { CountryIdentifier.CapeVerde, new CapeVerde() }, + { CountryIdentifier.CaymanIslands, new CaymanIslands() }, // Future countries can be added here in the same format. }; From 0e214d8681e3690075f52ffdba9f657ad9bfcc42 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Fri, 14 Mar 2025 08:26:12 +0100 Subject: [PATCH 06/16] update caymand details --- src/World.Net/Countries/CaymanIslands.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/World.Net/Countries/CaymanIslands.cs b/src/World.Net/Countries/CaymanIslands.cs index fc2a714..cf82578 100644 --- a/src/World.Net/Countries/CaymanIslands.cs +++ b/src/World.Net/Countries/CaymanIslands.cs @@ -18,12 +18,12 @@ internal sealed class CaymanIslands : ICountry public string ISO3Code => "CYM"; - public string CallingCode => "+1 345"; + public string CallingCode => "+1-345"; public IEnumerable States => [ - new("Cayman Brac", "", ""), - new("Grand Cayman", "", ""), - new("Little Cayman", "", "") + new("Cayman Brac", "", "District"), + new("Grand Cayman", "", "District"), + new("Little Cayman", "", "District") ]; } From ca7b0b79295234d15b8481368e7f87a43e03a78f Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Fri, 14 Mar 2025 08:26:22 +0100 Subject: [PATCH 07/16] add cayman island unit tests --- .../Countries/CaymanIslandsTest.cs | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs b/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs index 14ce15a..3896b46 100644 --- a/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs +++ b/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs @@ -1,12 +1,41 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace World.Net.UnitTests.Countries +namespace World.Net.UnitTests.Countries { - class CaymanIslandsTest + public sealed class CaymanIslandsTest { + private const string CAYMAN_ISLANDS_COUNTRY_NAME = "Cayman Islands"; + private const string CAYMAN_ISLANDS_NATIVE_NAME = "Cayman Islands"; + private const string CAYMAN_ISLANDS_CAPITAL = "George Town"; + private const string CAYMAN_ISLANDS_OFFICIAL_NAME = "Cayman Islands"; + private const string CAYMAN_ISLANDS_ISO2_CODE = "KY"; + private const string CAYMAN_ISLANDS_ISO3_CODE = "CYM"; + private const int CAYMAN_ISLANDS_NUMERIC_CODE = 136; + private const string CAYMAN_ISLANDS_CALLING_CODE = "+1-345"; + private const int CAYMAN_ISLANDS_STATE_COUNT = 3; + private static readonly string[] VALID_STATE_TYPES = { "District" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCaymanIslands() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.CaymanIslands; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CAYMAN_ISLANDS_COUNTRY_NAME, country.Name); + Assert.Equal(CAYMAN_ISLANDS_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CAYMAN_ISLANDS_NATIVE_NAME, country.NativeName); + Assert.Equal(CAYMAN_ISLANDS_CAPITAL, country.Capital); + Assert.Equal(CAYMAN_ISLANDS_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CAYMAN_ISLANDS_ISO2_CODE, country.ISO2Code); + Assert.Equal(CAYMAN_ISLANDS_ISO3_CODE, country.ISO3Code); + Assert.Equal(CAYMAN_ISLANDS_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CAYMAN_ISLANDS_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } } } From bac9e6c956cec7f15bc92f693b496032ad34dfd2 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Fri, 14 Mar 2025 09:28:31 +0100 Subject: [PATCH 08/16] add china and chile to initializer --- src/World.Net/Helpers/CountryInitializer.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 1e45c14..56bc4c9 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -47,6 +47,10 @@ public static Dictionary Initialize() { 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() }, // Future countries can be added here in the same format. }; From 0774479e13edbb77801e5259cc12f7e3de6a2b46 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 15 Mar 2025 22:26:49 +0100 Subject: [PATCH 09/16] add central african republic --- .../Countries/CentralAfricanRepublic.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/World.Net/Countries/CentralAfricanRepublic.cs diff --git a/src/World.Net/Countries/CentralAfricanRepublic.cs b/src/World.Net/Countries/CentralAfricanRepublic.cs new file mode 100644 index 0000000..681cb1f --- /dev/null +++ b/src/World.Net/Countries/CentralAfricanRepublic.cs @@ -0,0 +1,40 @@ +namespace World.Net.Countries; + +internal sealed class CentralAfricanRepublic : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.CentralAfricanRepublic; + + public string Name => "Central African Republic"; + + public string OfficialName => "Central African Republic"; + + public string NativeName => "Ködörösêse tî Bêafrîka"; + + public string Capital => "Bangui"; + + public int NumericCode => 140; + + public string ISO2Code => "CF"; + + public string ISO3Code => "CAF"; + + public string CallingCode => "+236"; + + public IEnumerable States => + [ + new("Bamingui-Bangoran", "BB", "Prefecture"), + new("Bangui", "BGF", "Capital District"), + new("Basse-Kotto", "BK", "Prefecture"), + new("Haut-Mbomou", "HM", "Prefecture"), + new("Haut-Oubangui", "HK", "Prefecture"), + new("Kémo", "KG", "Prefecture"), + new("Lobaye", "LB", "Prefecture"), + new("Mambéré-Kadéï", "CF", "Prefecture"), + new("Mbomou", "MB", "Prefecture"), + new("Nana-Mambéré", "NM", "Prefecture"), + new("Nana-Grébizi", "NG", "Prefecture"), + new("Ombella-M'Poko", "OM", "Prefecture"), + new("Sangha-Mbaéré", "SM", "Prefecture"), + new("Vakaga", "VK", "Prefecture") + ]; +} From 6673fd44c42da8e379e1dfd68500880c4ce335bf Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sat, 15 Mar 2025 22:27:06 +0100 Subject: [PATCH 10/16] add central african republic unit tests --- .../Countries/CentralAfricanRepublicTest.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/CentralAfricanRepublicTest.cs diff --git a/src/World.Net.UnitTests/Countries/CentralAfricanRepublicTest.cs b/src/World.Net.UnitTests/Countries/CentralAfricanRepublicTest.cs new file mode 100644 index 0000000..b15d007 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CentralAfricanRepublicTest.cs @@ -0,0 +1,42 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CentralAfricanRepublicTest +{ + private const string CAR_COUNTRY_NAME = "Central African Republic"; + private const string CAR_NATIVE_NAME = "Ködörösêse tî Bêafrîka"; + private const string CAR_CAPITAL = "Bangui"; + private const string CAR_OFFICIAL_NAME = "Central African Republic"; + private const string CAR_ISO2_CODE = "CF"; + private const string CAR_ISO3_CODE = "CAF"; + private const int CAR_NUMERIC_CODE = 140; + private const string CAR_CALLING_CODE = "+236"; + private const int CAR_STATE_COUNT = 14; + private static readonly string[] VALID_STATE_TYPES = { "Prefecture", "Capital District" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCentralAfricanRepublic() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.CentralAfricanRepublic; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CAR_COUNTRY_NAME, country.Name); + Assert.Equal(CAR_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CAR_NATIVE_NAME, country.NativeName); + Assert.Equal(CAR_CAPITAL, country.Capital); + Assert.Equal(CAR_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CAR_ISO2_CODE, country.ISO2Code); + Assert.Equal(CAR_ISO3_CODE, country.ISO3Code); + Assert.Equal(CAR_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CAR_STATE_COUNT, country.States.Count()); + + // Assert that each state has a valid type + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} \ No newline at end of file From 11396ee7549148f89aeb614ce05717bee6ead606 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sun, 16 Mar 2025 06:45:27 +0100 Subject: [PATCH 11/16] add chad country details --- src/World.Net/Countries/Chad.cs | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/World.Net/Countries/Chad.cs diff --git a/src/World.Net/Countries/Chad.cs b/src/World.Net/Countries/Chad.cs new file mode 100644 index 0000000..a7d6b1e --- /dev/null +++ b/src/World.Net/Countries/Chad.cs @@ -0,0 +1,49 @@ +namespace World.Net.Countries; + +internal sealed class Chad : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Chad; + + public string Name => "Chad"; + + public string OfficialName => "Republic of Chad"; + + public string NativeName => "Tchad"; + + public string Capital => "N'Djamena"; + + public int NumericCode => 148; + + public string ISO2Code => "TD"; + + public string ISO3Code => "TCD"; + + public string CallingCode => "+235"; + + public IEnumerable States => + [ + new State("Bahr el Gazel", "BG", "Region"), + new State("Batha", "BA", "Region"), + new State("Borkou", "BO", "Region"), + new State("Chari-Baguirmi", "TD-CH", "Region"), + new State("Ennedi-Est", "EE", "Region"), + new State("Ennedi-Ouest", "EO", "Region"), + new State("Guéra", "GE", "Region"), + new State("Hadjer-Lamis", "HL", "Region"), + new State("Kanem", "KA", "Region"), + new State("Lac", "LC", "Region"), + new State("Logone Occidental", "LO", "Region"), + new State("Logone Oriental", "LO", "Region"), + new State("Mandoul", "MD", "Region"), + new State("Mayo-Kebbi Est", "MK", "Region"), + new State("Mayo-Kebbi Ouest", "MO", "Region"), + new State("Moyen-Chari", "MC", "Region"), + new State("N'Djamena'", "ND", "Region"), + new State("Ouaddaï", "OD", "Region"), + new State("Salamat", "SA", "Region"), + new State("Sila", "SI", "Region"), + new State("Tandjilé", "TA", "Region"), + new State("Tibesti", "TI", "Region"), + new State("Wadi Fira", "WF", "Region") + ]; +} \ No newline at end of file From 83054e7133cc2e1e273a5854eb7e834a43f96385 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sun, 16 Mar 2025 06:45:40 +0100 Subject: [PATCH 12/16] add chad country unit test --- src/World.Net.UnitTests/Countries/ChadTest.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/ChadTest.cs diff --git a/src/World.Net.UnitTests/Countries/ChadTest.cs b/src/World.Net.UnitTests/Countries/ChadTest.cs new file mode 100644 index 0000000..1489538 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ChadTest.cs @@ -0,0 +1,42 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class ChadTest +{ + private const string CHAD_COUNTRY_NAME = "Chad"; + private const string CHAD_NATIVE_NAME = "Tchad"; + private const string CHAD_CAPITAL = "N'Djamena"; + private const string CHAD_OFFICIAL_NAME = "Republic of Chad"; + private const string CHAD_ISO2_CODE = "TD"; + private const string CHAD_ISO3_CODE = "TCD"; + private const int CHAD_NUMERIC_CODE = 148; + private const string CHAD_CALLING_CODE = "+235"; + private const int CHAD_STATE_COUNT = 23; + private static readonly string[] VALID_STATE_TYPES = { "Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForChad() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Chad; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CHAD_COUNTRY_NAME, country.Name); + Assert.Equal(CHAD_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CHAD_NATIVE_NAME, country.NativeName); + Assert.Equal(CHAD_CAPITAL, country.Capital); + Assert.Equal(CHAD_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CHAD_ISO2_CODE, country.ISO2Code); + Assert.Equal(CHAD_ISO3_CODE, country.ISO3Code); + Assert.Equal(CHAD_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CHAD_STATE_COUNT, country.States.Count()); + + // Assert that each state has a valid type + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} From 1e88d6acd460aef8c6dd7110808712708f85c61d Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sun, 16 Mar 2025 23:02:13 +0100 Subject: [PATCH 13/16] add Chile country details --- src/World.Net/Countries/Chile.cs | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/World.Net/Countries/Chile.cs diff --git a/src/World.Net/Countries/Chile.cs b/src/World.Net/Countries/Chile.cs new file mode 100644 index 0000000..a6f5818 --- /dev/null +++ b/src/World.Net/Countries/Chile.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace World.Net.Countries; + +internal sealed class Chile : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.Chile; + + public string Name => "Chile"; + + public string OfficialName => "Republic of Chile"; + + public string NativeName => "República de Chile"; + + public string Capital => "Santiago"; + + public int NumericCode => 152; + + public string ISO2Code => "CL"; + + public string ISO3Code => "CHL"; + + public string CallingCode => "+56"; + + public IEnumerable States => + [ + new("Arica y Parinacota", "AP", "Region"), + new("Antofagasta", "AN", "Region"), + new("Atacama", "AT", "Region"), + new("Aysén del General Carlos Ibáñez del Campo", "AI", "Region"), + new("Biobío", "BI", "Region"), + new("Coquimbo", "CO", "Region"), + new("La Araucanía", "AR", "Region"), + new("Los Lagos", "LL", "Region"), + new("Los Ríos", "LR", "Region"), + new("Magallanes y de la Antártica Chilena", "MA", "Region"), + new("Libertador General Bernardo O''Higgins", "LI", "Region"), + new("Maule", "-ML", "Region"), + new("Ñuble", "NB", "Region"), + new("Metropolitana de Santiago", "RM", "Region"), + new("Tarapacá", "TA", "Region"), + new("Valparaíso", "VS", "Region") + ]; +} From 256fa17143212b8312fd540aa52dce84743a6718 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Sun, 16 Mar 2025 23:02:29 +0100 Subject: [PATCH 14/16] add Chile Tests --- .../Countries/ChileTest.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/ChileTest.cs diff --git a/src/World.Net.UnitTests/Countries/ChileTest.cs b/src/World.Net.UnitTests/Countries/ChileTest.cs new file mode 100644 index 0000000..705c7d6 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ChileTest.cs @@ -0,0 +1,42 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class ChileTest +{ + private const string CHILE_COUNTRY_NAME = "Chile"; + private const string CHILE_NATIVE_NAME = "República de Chile"; + private const string CHILE_CAPITAL = "Santiago"; + private const string CHILE_OFFICIAL_NAME = "Republic of Chile"; + private const string CHILE_ISO2_CODE = "CL"; + private const string CHILE_ISO3_CODE = "CHL"; + private const int CHILE_NUMERIC_CODE = 152; + private const string CHILE_CALLING_CODE = "+56"; + private const int CHILE_STATE_COUNT = 16; + private static readonly string[] VALID_STATE_TYPES = { "Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForChile() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Chile; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CHILE_COUNTRY_NAME, country.Name); + Assert.Equal(CHILE_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CHILE_NATIVE_NAME, country.NativeName); + Assert.Equal(CHILE_CAPITAL, country.Capital); + Assert.Equal(CHILE_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CHILE_ISO2_CODE, country.ISO2Code); + Assert.Equal(CHILE_ISO3_CODE, country.ISO3Code); + Assert.Equal(CHILE_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CHILE_STATE_COUNT, country.States.Count()); + + // Assert that each state has a valid type + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} From f328f06440fba134be48cd078c0ddd5f3b876d86 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Mon, 17 Mar 2025 23:32:40 +0100 Subject: [PATCH 15/16] add china --- src/World.Net/Countries/China.cs | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/World.Net/Countries/China.cs diff --git a/src/World.Net/Countries/China.cs b/src/World.Net/Countries/China.cs new file mode 100644 index 0000000..6d857e5 --- /dev/null +++ b/src/World.Net/Countries/China.cs @@ -0,0 +1,60 @@ +namespace World.Net.Countries; + +internal sealed class China : ICountry +{ + public CountryIdentifier Id => CountryIdentifier.China; + + public string Name => "China"; + + public string OfficialName => "People's Republic of China"; + + public string NativeName => "中国"; + + public string Capital => "Beijing"; + + public int NumericCode => 156; + + public string ISO2Code => "CN"; + + public string ISO3Code => "CHN"; + + public string CallingCode => "+86"; + + public IEnumerable States => + [ + new("Anhui", "AH", "Province"), + new("Beijing", "BJ", "Municipality"), + new("Chongqing", "CQ", "Municipality"), + new("Fujian", "FJ", "Province"), + new("Gansu", "GS", "Province"), + new("Guangdong", "GD", "Province"), + new("Guangxi Zhuang", "GX", "Autonomous Region"), + new("Guizhou", "GZ", "Province"), + new("Hainan", "HI", "Province"), + new("Hebei", "HE", "Province"), + new("Heilongjiang", "HL", "Province"), + new("Henan", "HA", "Province"), + new("Hong Kong", "HK", "Special Administrative Region"), + new("Hubei", "HB", "Province"), + new("Hunan", "HN", "Province"), + new("Inner Mongolia", "NM", "Autonomous Region"), + new("Jiangsu", "JS", "Province"), + new("Jiangxi", "JX", "Province"), + new("Jilin", "JL", "Province"), + new("Liaoning", "LN", "Province"), + new("Macau SAR", "MO", "Special Administrative Region"), + new("Ningxia Huizu", "NX", "Autonomous Region"), + new("Qinghai", "QH", "Province"), + new("Shaanxi", "SN", "Province"), + new("Shandong", "SD", "Province"), + new("Shanghai", "SH", "Municipality"), + new("Shanxi", "SX", "Province"), + new("Sichuan", "SC", "Province"), + new("Taiwan", "TW", "Municipality"), + new("Tianjin", "TJ", "Municipality"), + new("Tibet", "XZ", "Autonomous Region"), + new("Xinjiang", "XJ", "Autonomous Region"), + new("Yunnan", "YN", "Province"), + new("Zhejiang", "ZJ", "Province") + ]; +} From 4aa5b3bac44b8252dfa3e3fb155991f027323350 Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu Date: Tue, 18 Mar 2025 21:55:17 +0100 Subject: [PATCH 16/16] add china unit tests --- .../Countries/ChinaTest.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/ChinaTest.cs diff --git a/src/World.Net.UnitTests/Countries/ChinaTest.cs b/src/World.Net.UnitTests/Countries/ChinaTest.cs new file mode 100644 index 0000000..85d95d2 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ChinaTest.cs @@ -0,0 +1,42 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class ChinaTest +{ + private const string CHINA_COUNTRY_NAME = "China"; + private const string CHINA_NATIVE_NAME = "中国"; + private const string CHINA_CAPITAL = "Beijing"; + private const string CHINA_OFFICIAL_NAME = "People's Republic of China"; + private const string CHINA_ISO2_CODE = "CN"; + private const string CHINA_ISO3_CODE = "CHN"; + private const int CHINA_NUMERIC_CODE = 156; + private const string CHINA_CALLING_CODE = "+86"; + private const int CHINA_STATE_COUNT = 34; // 23 Provinces, 4 Municipalities, 5 Autonomous Regions, 2 SAR + private static readonly string[] VALID_STATE_TYPES = { "Province", "Municipality", "Autonomous Region", "Special Administrative Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForChina() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.China; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CHINA_COUNTRY_NAME, country.Name); + Assert.Equal(CHINA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CHINA_NATIVE_NAME, country.NativeName); + Assert.Equal(CHINA_CAPITAL, country.Capital); + Assert.Equal(CHINA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CHINA_ISO2_CODE, country.ISO2Code); + Assert.Equal(CHINA_ISO3_CODE, country.ISO3Code); + Assert.Equal(CHINA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CHINA_STATE_COUNT, country.States.Count()); + + // Assert that each state has a valid type + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +}