diff --git a/src/World.Net.UnitTests/Countries/CentralAfricanRepublicTest.cs b/src/World.Net.UnitTests/Countries/CentralAfricanRepublicTest.cs new file mode 100644 index 0000000..36044fd --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CentralAfricanRepublicTest.cs @@ -0,0 +1,38 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class CentralAfricanRepublicTest + { + private const string CENTRAL_AFRICAN_REPUBLIC_NAME = "Central African Republic"; + private const int CENTRAL_AFRICAN_REPUBLIC_STATE_COUNT = 17; + private const string CENTRAL_AFRICAN_REPUBLIC_OFFICIAL_NAME = "Central African Republic"; + private const string CENTRAL_AFRICAN_REPUBLIC_NATIVE_NAME = "Ködörösêse tî Bêafrîka"; + private const string CENTRAL_AFRICAN_REPUBLIC_CAPITAL = "Bangui"; + private const int CENTRAL_AFRICAN_REPUBLIC_NUMERIC_CODE = 140; + private const string CENTRAL_AFRICAN_REPUBLIC_ISO2_CODE = "CF"; + private const string CENTRAL_AFRICAN_REPUBLIC_ISO3_CODE = "CAF"; + private const string CENTRAL_AFRICAN_REPUBLIC_CALLING_CODE = "+236"; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCentralAfricanRepublic() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.CentralAfricanRepublic; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_STATE_COUNT, country.States.Count()); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_NATIVE_NAME, country.NativeName); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_CAPITAL, country.Capital); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_ISO2_CODE, country.ISO2Code); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_ISO3_CODE, country.ISO3Code); + Assert.Equal(CENTRAL_AFRICAN_REPUBLIC_CALLING_CODE, country.CallingCode); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/ChadTest.cs b/src/World.Net.UnitTests/Countries/ChadTest.cs new file mode 100644 index 0000000..3b5365a --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ChadTest.cs @@ -0,0 +1,38 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class ChadTest + { + private const string CHAD_NAME = "Chad"; + private const int CHAD_STATE_COUNT = 23; + private const string CHAD_OFFICIAL_NAME = "Republic of Chad"; + private const string CHAD_NATIVE_NAME = "Tchad"; + private const string CHAD_CAPITAL = "N'Djamena"; + private const int CHAD_NUMERIC_CODE = 148; + private const string CHAD_ISO2_CODE = "TD"; + private const string CHAD_ISO3_CODE = "TCD"; + private const string CHAD_CALLING_CODE = "+235"; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForChad() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Chad; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CHAD_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(CHAD_STATE_COUNT, country.States.Count()); + 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); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/ChileTest.cs b/src/World.Net.UnitTests/Countries/ChileTest.cs new file mode 100644 index 0000000..b122b73 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ChileTest.cs @@ -0,0 +1,38 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class ChileTest + { + private const string CHILE_NAME = "Chile"; + private const int CHILE_STATE_COUNT = 16; + private const string CHILE_OFFICIAL_NAME = "Republic of Chile"; + private const string CHILE_NATIVE_NAME = "Chile"; + private const string CHILE_CAPITAL = "Santiago"; + private const int CHILE_NUMERIC_CODE = 152; + private const string CHILE_ISO2_CODE = "CL"; + private const string CHILE_ISO3_CODE = "CHL"; + private const string CHILE_CALLING_CODE = "+56"; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForChile() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.Chile; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CHILE_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(CHILE_STATE_COUNT, country.States.Count()); + 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); + } + } +} diff --git a/src/World.Net.UnitTests/Countries/ChinaTest.cs b/src/World.Net.UnitTests/Countries/ChinaTest.cs new file mode 100644 index 0000000..717c142 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/ChinaTest.cs @@ -0,0 +1,38 @@ +namespace World.Net.UnitTests.Countries +{ + public sealed class ChinaTest + { + private const string CHINA_NAME = "China"; + private const int CHINA_STATE_COUNT = 34; + private const string CHINA_OFFICIAL_NAME = "People's Republic of China"; + private const string CHINA_NATIVE_NAME = "中国"; + private const string CHINA_CAPITAL = "Beijing"; + private const int CHINA_NUMERIC_CODE = 156; + private const string CHINA_ISO2_CODE = "CN"; + private const string CHINA_ISO3_CODE = "CHN"; + private const string CHINA_CALLING_CODE = "+86"; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForChina() + { + // Arrange + CountryIdentifier existingCountryId = CountryIdentifier.China; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CHINA_NAME, country.Name); + Assert.NotNull(country.States); + Assert.Equal(CHINA_STATE_COUNT, country.States.Count()); + 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); + } + } +} diff --git a/src/World.Net/Countries/CentralAfricanRepublic.cs b/src/World.Net/Countries/CentralAfricanRepublic.cs new file mode 100644 index 0000000..c785820 --- /dev/null +++ b/src/World.Net/Countries/CentralAfricanRepublic.cs @@ -0,0 +1,54 @@ +namespace World.Net.Countries +{ + internal sealed class CentralAfricanRepublic : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.CentralAfricanRepublic; + + /// + public string Name => "Central African Republic"; + + /// + public string OfficialName { get; } = "Central African Republic"; + + /// + public string NativeName { get; } = "Ködörösêse tî Bêafrîka"; + + /// + public string Capital { get; } = "Bangui"; + + /// + public int NumericCode { get; } = 140; + + /// + public string ISO2Code { get; } = "CF"; + + /// + public string ISO3Code { get; } = "CAF"; + + /// + public string CallingCode { get; } = "+236"; + + /// + public IEnumerable States { get; } = + [ + new("Bamingui-Bangoran", "CF-BB", "Prefecture"), + new("Bangui", "CF-BGF", "Commune"), + new("Basse-Kotto", "CF-BK", "Prefecture"), + new("Haut-Mbomou", "CF-HM", "Prefecture"), + new("Haute-Kotto", "CF-HK", "Prefecture"), + new("Kémo", "CF-KG", "Prefecture"), + new("Lobaye", "CF-LB", "Prefecture"), + new("Mambéré-Kadéï", "CF-HS", "Prefecture"), + new("Mbomou", "CF-MB", "Prefecture"), + new("Nana-Grébizi", "CF-KB", "Economic Prefecture"), + new("Nana-Mambéré", "CF-NM", "Prefecture"), + new("Ombella-M'Poko", "CF-MP", "Prefecture"), + new("Ouaka", "CF-UK", "Prefecture"), + new("Ouham", "CF-AC", "Prefecture"), + new("Ouham-Pendé", "CF-OP", "Prefecture"), + new("Sangha-Mbaéré", "CF-SE", "Prefecture"), + new("Vakaga", "CF-VK", "Prefecture"), + ]; + } +} diff --git a/src/World.Net/Countries/Chad.cs b/src/World.Net/Countries/Chad.cs new file mode 100644 index 0000000..9beea8f --- /dev/null +++ b/src/World.Net/Countries/Chad.cs @@ -0,0 +1,60 @@ +namespace World.Net.Countries +{ + internal sealed class Chad : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.Chad; + + /// + public string Name => nameof(Chad); + + /// + public string OfficialName { get; } = "Republic of Chad"; + + /// + public string NativeName { get; } = "Tchad"; + + /// + public string Capital { get; } = "N'Djamena"; + + /// + public int NumericCode { get; } = 148; + + /// + public string ISO2Code { get; } = "TD"; + + /// + public string ISO3Code { get; } = "TCD"; + + /// + public string CallingCode { get; } = "+235"; + + /// + public IEnumerable States { get; } = + [ + new("Bahr el Gazel", "TD-BG", "Province"), + new("Batha", "TD-BA", "Province"), + new("Borkou", "TD-BO", "Province"), + new("Chari-Baguirmi", "TD-CB", "Province"), + new("Ennedi-Est", "TD-EE", "Province"), + new("Ennedi-Ouest", "TD-EO", "Province"), + new("Guéra", "TD-GR", "Province"), + new("Hadjer-Lamis", "TD-HL", "Province"), + new("Kanem", "TD-KA", "Province"), + new("Lac", "TD-LC", "Province"), + new("Logone Occidental", "TD-LO", "Province"), + new("Logone Oriental", "TD-LR", "Province"), + new("Mandoul", "TD-MA", "Province"), + new("Mayo-Kebbi Est", "TD-ME", "Province"), + new("Mayo-Kebbi Ouest", "TD-MO", "Province"), + new("Moyen-Chari", "TD-MC", "Province"), + new("N'Djamena", "TD-ND", "Province"), + new("Ouaddaï", "TD-OD", "Province"), + new("Salamat", "TD-SA", "Province"), + new("Sila", "TD-SI", "Province"), + new("Tandjilé", "TD-TA", "Province"), + new("Tibesti", "TD-TI", "Province"), + new("Wadi Fira", "TD-WF", "Province"), + ]; + } +} diff --git a/src/World.Net/Countries/Chile.cs b/src/World.Net/Countries/Chile.cs new file mode 100644 index 0000000..9f3963b --- /dev/null +++ b/src/World.Net/Countries/Chile.cs @@ -0,0 +1,53 @@ +namespace World.Net.Countries +{ + internal sealed class Chile : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.Chile; + + /// + public string Name => nameof(Chile); + + /// + public string OfficialName { get; } = "Republic of Chile"; + + /// + public string NativeName { get; } = "Chile"; + + /// + public string Capital { get; } = "Santiago"; + + /// + public int NumericCode { get; } = 152; + + /// + public string ISO2Code { get; } = "CL"; + + /// + public string ISO3Code { get; } = "CHL"; + + /// + public string CallingCode { get; } = "+56"; + + /// + public IEnumerable States { get; } = + [ + new("Aisén del General Carlos Ibañez del Campo", "CL-AI", "Region"), + new("Antofagasta", "CL-AN", "Region"), + new("Arica y Parinacota", "CL-AP", "Region"), + new("Atacama", "CL-AT", "Region"), + new("Biobío", "CL-BI", "Region"), + new("Coquimbo", "CL-CO", "Region"), + new("La Araucanía", "CL-AR", "Region"), + new("Libertador General Bernardo O'Higgins", "CL-LI", "Region"), + new("Los Lagos", "CL-LL", "Region"), + new("Los Ríos", "CL-LR", "Region"), + new("Magallanes y de la Antártica Chilena", "CL-MA", "Region"), + new("Maule", "CL-ML", "Region"), + new("Ñuble", "CL-NB", "Region"), + new("Región Metropolitana de Santiago", "CL-RM", "Region"), + new("Tarapacá", "CL-TA", "Region"), + new("Valparaíso", "CL-VS", "Region"), + ]; + } +} diff --git a/src/World.Net/Countries/China.cs b/src/World.Net/Countries/China.cs new file mode 100644 index 0000000..7fcd138 --- /dev/null +++ b/src/World.Net/Countries/China.cs @@ -0,0 +1,71 @@ +namespace World.Net.Countries +{ + internal sealed class China : ICountry + { + /// + public CountryIdentifier Id => CountryIdentifier.China; + + /// + public string Name => nameof(China); + + /// + public string OfficialName { get; } = "People's Republic of China"; + + /// + public string NativeName { get; } = "中国"; + + /// + public string Capital { get; } = "Beijing"; + + /// + public int NumericCode { get; } = 156; + + /// + public string ISO2Code { get; } = "CN"; + + /// + public string ISO3Code { get; } = "CHN"; + + /// + public string CallingCode { get; } = "+86"; + + /// + public IEnumerable States { get; } = + [ + new("Anhui", "CN-AH", "Province"), + new("Beijing", "CN-BJ", "Municipality"), + new("Chongqing", "CN-CQ", "Municipality"), + new("Fujian", "CN-FJ", "Province"), + new("Gansu", "CN-GS", "Province"), + new("Guangdong", "CN-GD", "Province"), + new("Guangxi Zhuang", "CN-GX", "Autonomous Region"), + new("Guizhou", "CN-GZ", "Province"), + new("Hainan", "CN-HI", "Province"), + new("Hebei", "CN-HE", "Province"), + new("Heilongjiang", "CN-HL", "Province"), + new("Henan", "CN-HA", "Province"), + new("Hong Kong SAR", "CN-HK", "Special Administrative Region"), + new("Hubei", "CN-HB", "Province"), + new("Hunan", "CN-HN", "Province"), + new("Inner Mongolia", "CN-NM", "Autonomous Region"), + new("Jiangsu", "CN-JS", "Province"), + new("Jiangxi", "CN-JX", "Province"), + new("Jilin", "CN-JL", "Province"), + new("Liaoning", "CN-LN", "Province"), + new("Macau SAR", "CN-MO", "Special Administrative Region"), + new("Ningxia Huizu", "CN-NX", "Autonomous Region"), + new("Qinghai", "CN-QH", "Province"), + new("Shaanxi", "CN-SN", "Province"), + new("Shandong", "CN-SD", "Province"), + new("Shanghai", "CN-SH", "Municipality"), + new("Shanxi", "CN-SX", "Province"), + new("Sichuan", "CN-SC", "Province"), + new("Taiwan", "CN-TW", "Province"), + new("Tianjin", "CN-TJ", "Municipality"), + new("Xinjiang", "CN-XJ", "Autonomous Region"), + new("Xizang", "CN-XZ", "Autonomous Region"), + new("Yunnan", "CN-YN", "Province"), + new("Zhejiang", "CN-ZJ", "Province"), + ]; + } +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 893be47..9df1f7c 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.Chad, new Chad() }, + { CountryIdentifier.Chile, new Chile() }, + { CountryIdentifier.China, new China() }, + { CountryIdentifier.CentralAfricanRepublic, new CentralAfricanRepublic() }, // Future countries can be added here in the same format. };