diff --git a/src/World.Net.UnitTests/Countries/AmericanSamoa.cs b/src/World.Net.UnitTests/Countries/AmericanSamoaTest.cs similarity index 100% rename from src/World.Net.UnitTests/Countries/AmericanSamoa.cs rename to src/World.Net.UnitTests/Countries/AmericanSamoaTest.cs diff --git a/src/World.Net.UnitTests/Countries/BurundiTest.cs b/src/World.Net.UnitTests/Countries/BurundiTest.cs new file mode 100644 index 0000000..cbf4796 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/BurundiTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class BurundiTest +{ + private const string BURUNDI_COUNTRY_NAME = "Burundi"; + private const string BURUNDI_NATIVE_NAME = "Uburundi"; + private const string BURUNDI_CAPITAL = "Gitega"; + private const string BURUNDI_OFFICIAL_NAME = "Republic of Burundi"; + private const string BURUNDI_ISO2_CODE = "BI"; + private const string BURUNDI_ISO3_CODE = "BDI"; + private const int BURUNDI_NUMERIC_CODE = 108; + private const string BURUNDI_CALLING_CODE = "+257"; + private const int BURUNDI_STATE_COUNT = 18; + private static readonly string[] VALID_STATE_TYPES = { "Province" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForBurundi() + { + // Arrange + int existingCountryId = CountryIdentifier.Burundi; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(BURUNDI_COUNTRY_NAME, country.Name); + Assert.Equal(BURUNDI_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(BURUNDI_NATIVE_NAME, country.NativeName); + Assert.Equal(BURUNDI_CAPITAL, country.Capital); + Assert.Equal(BURUNDI_NUMERIC_CODE, country.NumericCode); + Assert.Equal(BURUNDI_ISO2_CODE, country.ISO2Code); + Assert.Equal(BURUNDI_ISO3_CODE, country.ISO3Code); + Assert.Equal(BURUNDI_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(BURUNDI_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/CambodiaTest.cs b/src/World.Net.UnitTests/Countries/CambodiaTest.cs new file mode 100644 index 0000000..473f462 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CambodiaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CambodiaTest +{ + private const string CAMBODIA_COUNTRY_NAME = "Cambodia"; + private const string CAMBODIA_NATIVE_NAME = "កម្ពុជា"; + private const string CAMBODIA_CAPITAL = "Phnom Penh"; + private const string CAMBODIA_OFFICIAL_NAME = "Kingdom of Cambodia"; + private const string CAMBODIA_ISO2_CODE = "KH"; + private const string CAMBODIA_ISO3_CODE = "KHM"; + private const int CAMBODIA_NUMERIC_CODE = 116; + private const string CAMBODIA_CALLING_CODE = "+855"; + private const int CAMBODIA_STATE_COUNT = 25; + private static readonly string[] VALID_STATE_TYPES = { "Province", "Municipality" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCambodia() + { + // Arrange + int existingCountryId = CountryIdentifier.Cambodia; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CAMBODIA_COUNTRY_NAME, country.Name); + Assert.Equal(CAMBODIA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CAMBODIA_NATIVE_NAME, country.NativeName); + Assert.Equal(CAMBODIA_CAPITAL, country.Capital); + Assert.Equal(CAMBODIA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CAMBODIA_ISO2_CODE, country.ISO2Code); + Assert.Equal(CAMBODIA_ISO3_CODE, country.ISO3Code); + Assert.Equal(CAMBODIA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CAMBODIA_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/CameroonTest.cs b/src/World.Net.UnitTests/Countries/CameroonTest.cs new file mode 100644 index 0000000..7c0c28a --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CameroonTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CameroonTest +{ + private const string CAMEROON_COUNTRY_NAME = "Cameroon"; + private const string CAMEROON_NATIVE_NAME = "République du Cameroun"; + private const string CAMEROON_CAPITAL = "Yaoundé"; + private const string CAMEROON_OFFICIAL_NAME = "Republic of Cameroon"; + private const string CAMEROON_ISO2_CODE = "CM"; + private const string CAMEROON_ISO3_CODE = "CMR"; + private const int CAMEROON_NUMERIC_CODE = 120; + private const string CAMEROON_CALLING_CODE = "+237"; + private const int CAMEROON_STATE_COUNT = 10; + private static readonly string[] VALID_STATE_TYPES = { "Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCameroon() + { + // Arrange + int existingCountryId = CountryIdentifier.Cameroon; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CAMEROON_COUNTRY_NAME, country.Name); + Assert.Equal(CAMEROON_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CAMEROON_NATIVE_NAME, country.NativeName); + Assert.Equal(CAMEROON_CAPITAL, country.Capital); + Assert.Equal(CAMEROON_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CAMEROON_ISO2_CODE, country.ISO2Code); + Assert.Equal(CAMEROON_ISO3_CODE, country.ISO3Code); + Assert.Equal(CAMEROON_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CAMEROON_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/CanadaTest.cs b/src/World.Net.UnitTests/Countries/CanadaTest.cs new file mode 100644 index 0000000..a893897 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CanadaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CanadaTest +{ + private const string CANADA_COUNTRY_NAME = "Canada"; + private const string CANADA_NATIVE_NAME = "Canada"; + private const string CANADA_CAPITAL = "Ottawa"; + private const string CANADA_OFFICIAL_NAME = "Canada"; + private const string CANADA_ISO2_CODE = "CA"; + private const string CANADA_ISO3_CODE = "CAN"; + private const int CANADA_NUMERIC_CODE = 124; + private const string CANADA_CALLING_CODE = "+1"; + private const int CANADA_STATE_COUNT = 13; + private static readonly string[] VALID_STATE_TYPES = { "Province", "Territory" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCanada() + { + // Arrange + int existingCountryId = CountryIdentifier.Canada; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CANADA_COUNTRY_NAME, country.Name); + Assert.Equal(CANADA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CANADA_NATIVE_NAME, country.NativeName); + Assert.Equal(CANADA_CAPITAL, country.Capital); + Assert.Equal(CANADA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CANADA_ISO2_CODE, country.ISO2Code); + Assert.Equal(CANADA_ISO3_CODE, country.ISO3Code); + Assert.Equal(CANADA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CANADA_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/CapeVerdeTest.cs b/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs new file mode 100644 index 0000000..193349d --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CapeVerdeTest +{ + private const string CAPEVERDE_COUNTRY_NAME = "Cape Verde"; + private const string CAPEVERDE_NATIVE_NAME = "Cabo Verde"; + private const string CAPEVERDE_CAPITAL = "Praia"; + private const string CAPEVERDE_OFFICIAL_NAME = "Republic of Cabo Verde"; + private const string CAPEVERDE_ISO2_CODE = "CV"; + private const string CAPEVERDE_ISO3_CODE = "CPV"; + private const int CAPEVERDE_NUMERIC_CODE = 132; + private const string CAPEVERDE_CALLING_CODE = "+238"; + private const int CAPEVERDE_STATE_COUNT = 22; + private static readonly string[] VALID_STATE_TYPES = { "Municipality" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCapeVerde() + { + // Arrange + int existingCountryId = CountryIdentifier.CapeVerde; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CAPEVERDE_COUNTRY_NAME, country.Name); + Assert.Equal(CAPEVERDE_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CAPEVERDE_NATIVE_NAME, country.NativeName); + Assert.Equal(CAPEVERDE_CAPITAL, country.Capital); + Assert.Equal(CAPEVERDE_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CAPEVERDE_ISO2_CODE, country.ISO2Code); + Assert.Equal(CAPEVERDE_ISO3_CODE, country.ISO3Code); + Assert.Equal(CAPEVERDE_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CAPEVERDE_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net/Countries/Burundi.cs b/src/World.Net/Countries/Burundi.cs new file mode 100644 index 0000000..cdc8107 --- /dev/null +++ b/src/World.Net/Countries/Burundi.cs @@ -0,0 +1,54 @@ +namespace World.Net.Countries; + +internal sealed class Burundi : ICountry +{ + // + public int Id => CountryIdentifier.Burundi; + + // + public string Name { get; } = "Burundi"; + + // + public string OfficialName { get; } = "Republic of Burundi"; + + // + public string NativeName => "Uburundi"; + + // + public string Capital { get; } = "Gitega"; + + // + public int NumericCode { get; } = 108; + + // + public string ISO2Code { get; } = "BI"; + + // + public string ISO3Code { get; } = "BDI"; + + // + public string CallingCode { get; } = "+257"; + + // + public IEnumerable States => + [ + new("Bubanza", "BB"), + new("Bujumbura Mairie", "BM"), + new("Bujumbura Rural", "BR"), + new("Bururi", "BU"), + new("Cankuzo", "CA"), + new("Cibitoke", "CI"), + new("Gitega", "GI"), + new("Karuzi", "KR"), + new("Kayanza", "KY"), + new("Kirundo", "KI"), + new("Makamba", "MA"), + new("Muramvya", "MU"), + new("Muyinga", "MY"), + new("Mwaro", "MW"), + new("Ngozi", "NG"), + new("Rumonge", "RM"), + new("Rutana", "RT"), + new("Ruyigi", "RY") + ]; +} diff --git a/src/World.Net/Countries/Cambodia.cs b/src/World.Net/Countries/Cambodia.cs new file mode 100644 index 0000000..31d348e --- /dev/null +++ b/src/World.Net/Countries/Cambodia.cs @@ -0,0 +1,61 @@ +namespace World.Net.Countries; + +internal sealed class Cambodia : ICountry +{ + // + public int Id => CountryIdentifier.Cambodia; + + // + public string Name { get; } = "Cambodia"; + + // + public string OfficialName { get; } = "Kingdom of Cambodia"; + + // + public string NativeName => "កម\u17d2ព\u17bbជ\u17b6"; + + // + public string Capital { get; } = "Phnom Penh"; + + // + public int NumericCode { get; } = 116; + + // + public string ISO2Code { get; } = "KH"; + + // + public string ISO3Code { get; } = "KHM"; + + // + public string CallingCode { get; } = "+855"; + + // + public IEnumerable States => + [ + new("Banteay Meanchey", "1"), + new("Battambang", "2"), + new("Kampong Cham", "3"), + new("Kampong Chhnang", "4"), + new("Kampong Speu", "5"), + new("Kampong Thom", "6"), + new("Kampot", "7"), + new("Kandal", "8"), + new("Koh Kong", "9"), + new("Kratié", "10"), + new("Mondulkiri", "11"), + new("Phnom Penh", "12", "Municipality"), + new("Preah Vihear", "13"), + new("Prey Veng", "14"), + new("Pursat", "15"), + new("Ratanakiri", "16"), + new("Siem Reap", "17"), + new("Preah Sihanouk", "18"), + new("Stung Treng", "19"), + new("Svay Rieng", "20"), + new("Takéo", "21"), + new("Oddar Meanchey", "22"), + new("Kep", "23"), + new("Pailin", "24"), + new("Tbong Khmum", "25") + ]; +} diff --git a/src/World.Net/Countries/Cameroon.cs b/src/World.Net/Countries/Cameroon.cs new file mode 100644 index 0000000..40b337f --- /dev/null +++ b/src/World.Net/Countries/Cameroon.cs @@ -0,0 +1,46 @@ +namespace World.Net.Countries; + +internal sealed class Cameroon : ICountry +{ + // + public int Id => CountryIdentifier.Cameroon; + + // + public string Name { get; } = "Cameroon"; + + // + public string OfficialName { get; } = "Republic of Cameroon"; + + // + public string NativeName => "République du Cameroun"; + + // + public string Capital { get; } = "Yaoundé"; + + // + public int NumericCode { get; } = 120; + + // + public string ISO2Code { get; } = "CM"; + + // + public string ISO3Code { get; } = "CMR"; + + // + public string CallingCode { get; } = "+237"; + + // + public IEnumerable States => + [ + new("Adamawa", "AD", "Region"), + new("Centre", "CE", "Region"), + new("East", "ES", "Region"), + new("Far North", "FN", "Region"), + new("Littoral", "LT", "Region"), + new("North", "NO", "Region"), + new("North West", "NW", "Region"), + new("West", "OU", "Region"), + new("South", "SU", "Region"), + new("South West", "SW", "Region") + ]; +} diff --git a/src/World.Net/Countries/Canada.cs b/src/World.Net/Countries/Canada.cs new file mode 100644 index 0000000..8995085 --- /dev/null +++ b/src/World.Net/Countries/Canada.cs @@ -0,0 +1,49 @@ +namespace World.Net.Countries; + +internal sealed class Canada : ICountry +{ + // + public int Id => CountryIdentifier.Canada; + + // + public string Name { get; } = "Canada"; + + // + public string OfficialName { get; } = "Canada"; + + // + public string NativeName => "Canada"; + + // + public string Capital { get; } = "Ottawa"; + + // + public int NumericCode { get; } = 124; + + // + public string ISO2Code { get; } = "CA"; + + // + public string ISO3Code { get; } = "CAN"; + + // + public string CallingCode { get; } = "+1"; + + // + public IEnumerable States => + [ + new("Alberta", "AB"), + new("British Columbia", "BC"), + new("Manitoba", "MB"), + new("New Brunswick", "NB"), + new("Newfoundland and Labrador", "NL"), + new("Northwest Territories", "NT", "Territory"), + new("Nova Scotia", "NS"), + new("Nunavut", "NU", "Territory"), + new("Ontario", "ON"), + new("Prince Edward Island", "PE"), + new("Quebec", "QC"), + new("Saskatchewan", "SK"), + new("Yukon", "YT", "Territory") + ]; +} diff --git a/src/World.Net/Countries/CapeVerde.cs b/src/World.Net/Countries/CapeVerde.cs new file mode 100644 index 0000000..b2ba4d3 --- /dev/null +++ b/src/World.Net/Countries/CapeVerde.cs @@ -0,0 +1,58 @@ +namespace World.Net.Countries; + +internal sealed class CapeVerde : ICountry +{ + // + public int Id => CountryIdentifier.CapeVerde; + + // + public string Name { get; } = "Cape Verde"; + + // + public string OfficialName { get; } = "Republic of Cabo Verde"; + + // + public string NativeName => "Cabo Verde"; + + // + public string Capital { get; } = "Praia"; + + // + public int NumericCode { get; } = 132; + + // + public string ISO2Code { get; } = "CV"; + + // + public string ISO3Code { get; } = "CPV"; + + // + public string CallingCode { get; } = "+238"; + + // + public IEnumerable States => + [ + new("Boa Vista", "BV", "Municipality"), + new("Brava", "BR", "Municipality"), + new("Calheta de São Miguel", "CS", "Municipality"), + new("Maio", "MA", "Municipality"), + new("Mosteiros", "MO", "Municipality"), + new("Paul", "PA", "Municipality"), + new("Porto Novo", "PN", "Municipality"), + new("Praia", "PR", "Municipality"), + new("Ribeira Brava", "RB", "Municipality"), + new("Ribeira Grande", "RG", "Municipality"), + new("Ribeira Grande de Santiago", "RS", "Municipality"), + new("Sal", "SA", "Municipality"), + new("Santa Catarina", "SC", "Municipality"), + new("Santa Catarina do Fogo", "SF", "Municipality"), + new("Santa Cruz", "SZ", "Municipality"), + new("São Domingos", "SD", "Municipality"), + new("São Filipe", "SF", "Municipality"), + new("São Lourenço dos Órgãos", "SL", "Municipality"), + new("São Salvador do Mundo", "SM", "Municipality"), + new("São Vicente", "SV", "Municipality"), + new("Tarrafal", "TA", "Municipality"), + new("Tarrafal de São Nicolau", "TS", "Municipality") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 49d4e45..59acda1 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -36,6 +36,11 @@ public static Dictionary Initialize() { CountryIdentifier.BosniaAndHerzegovina, new BosniaAndHerzegovina() }, { CountryIdentifier.Botswana, new Botswana() }, { CountryIdentifier.BouvetIsland, new BouvetIsland() }, + { CountryIdentifier.Burundi, new Burundi() }, + { CountryIdentifier.Cambodia, new Cambodia() }, + { CountryIdentifier.Cameroon, new Cameroon() }, + { CountryIdentifier.Canada, new Canada() }, + { CountryIdentifier.CapeVerde, new CapeVerde() }, { CountryIdentifier.Bulgaria, new Bulgaria() }, { CountryIdentifier.BurkinaFaso, new BurkinaFaso() }, { CountryIdentifier.Brazil, new Brazil() },