diff --git a/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs b/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs new file mode 100644 index 0000000..3896b46 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CaymanIslandsTest.cs @@ -0,0 +1,41 @@ +namespace World.Net.UnitTests.Countries +{ + 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)); + } + } +} 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 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)); + } +} 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)); + } +} 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)); + } +} diff --git a/src/World.Net/Countries/CaymanIslands.cs b/src/World.Net/Countries/CaymanIslands.cs new file mode 100644 index 0000000..cf82578 --- /dev/null +++ b/src/World.Net/Countries/CaymanIslands.cs @@ -0,0 +1,29 @@ +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 => "George Town"; + + public int NumericCode => 136; + + public string ISO2Code => "KY"; + + public string ISO3Code => "CYM"; + + public string CallingCode => "+1-345"; + + public IEnumerable States => + [ + new("Cayman Brac", "", "District"), + new("Grand Cayman", "", "District"), + new("Little Cayman", "", "District") + ]; +} 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") + ]; +} 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 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") + ]; +} 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") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 893be47..9c15451 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -45,7 +45,12 @@ 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.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() },