Skip to content

Commit 6ce72c9

Browse files
authored
Merge pull request #52 from deanology/DoTiEcEg
Add support for Dominican Republic, Timor-Leste, Ecuador, and Egypt w…
2 parents 0523b0f + b315673 commit 6ce72c9

9 files changed

Lines changed: 405 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class DominicanRepublicTest
4+
{
5+
private const string DOMINICANREPUBLIC_COUNTRY_NAME = "Dominican Republic";
6+
private const string DOMINICANREPUBLIC_NATIVE_NAME = "República Dominicana";
7+
private const string DOMINICANREPUBLIC_CAPITAL = "Santo Domingo";
8+
private const string DOMINICANREPUBLIC_OFFICIAL_NAME = "Dominican Republic";
9+
private const string DOMINICANREPUBLIC_ISO2_CODE = "DO";
10+
private const string DOMINICANREPUBLIC_ISO3_CODE = "DOM";
11+
private const int DOMINICANREPUBLIC_NUMERIC_CODE = 214;
12+
private readonly string[] DOMINICANREPUBLIC_CALLING_CODE = ["+1-809", "+1-829", "+1-849"];
13+
private const int DOMINICANREPUBLIC_STATE_COUNT = 32; // 31 provinces + 1 National District
14+
private static readonly string[] VALID_STATE_TYPES = { "Province", "National District" };
15+
16+
[Fact]
17+
public void GetCountry_ReturnsCorrectInformation_ForDominicanRepublic()
18+
{
19+
// Arrange
20+
CountryIdentifier existingCountryId = CountryIdentifier.DominicanRepublic;
21+
22+
// Act
23+
var country = CountryProvider.GetCountry(existingCountryId);
24+
25+
// Assert
26+
Assert.NotNull(country);
27+
Assert.Equal(existingCountryId, country.Id);
28+
Assert.Equal(DOMINICANREPUBLIC_COUNTRY_NAME, country.Name);
29+
Assert.Equal(DOMINICANREPUBLIC_OFFICIAL_NAME, country.OfficialName);
30+
Assert.Equal(DOMINICANREPUBLIC_NATIVE_NAME, country.NativeName);
31+
Assert.Equal(DOMINICANREPUBLIC_CAPITAL, country.Capital);
32+
Assert.Equal(DOMINICANREPUBLIC_NUMERIC_CODE, country.NumericCode);
33+
Assert.Equal(DOMINICANREPUBLIC_ISO2_CODE, country.ISO2Code);
34+
Assert.Equal(DOMINICANREPUBLIC_ISO3_CODE, country.ISO3Code);
35+
Assert.Equal(DOMINICANREPUBLIC_CALLING_CODE, country.CallingCode);
36+
Assert.NotNull(country.States);
37+
Assert.Equal(DOMINICANREPUBLIC_STATE_COUNT, country.States.Count());
38+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class EcuadorTest
4+
{
5+
private const string ECUADOR_COUNTRY_NAME = "Ecuador";
6+
private const string ECUADOR_NATIVE_NAME = "República del Ecuador";
7+
private const string ECUADOR_CAPITAL = "Quito";
8+
private const string ECUADOR_OFFICIAL_NAME = "Republic of Ecuador";
9+
private const string ECUADOR_ISO2_CODE = "EC";
10+
private const string ECUADOR_ISO3_CODE = "ECU";
11+
private const int ECUADOR_NUMERIC_CODE = 218;
12+
private readonly string[] ECUADOR_CALLING_CODE = ["+593"];
13+
private const int ECUADOR_STATE_COUNT = 24; // 24 provinces
14+
private static readonly string[] VALID_STATE_TYPES = { "Province" };
15+
16+
[Fact]
17+
public void GetCountry_ReturnsCorrectInformation_ForEcuador()
18+
{
19+
// Arrange
20+
CountryIdentifier existingCountryId = CountryIdentifier.Ecuador;
21+
22+
// Act
23+
var country = CountryProvider.GetCountry(existingCountryId);
24+
25+
// Assert
26+
Assert.NotNull(country);
27+
Assert.Equal(existingCountryId, country.Id);
28+
Assert.Equal(ECUADOR_COUNTRY_NAME, country.Name);
29+
Assert.Equal(ECUADOR_OFFICIAL_NAME, country.OfficialName);
30+
Assert.Equal(ECUADOR_NATIVE_NAME, country.NativeName);
31+
Assert.Equal(ECUADOR_CAPITAL, country.Capital);
32+
Assert.Equal(ECUADOR_NUMERIC_CODE, country.NumericCode);
33+
Assert.Equal(ECUADOR_ISO2_CODE, country.ISO2Code);
34+
Assert.Equal(ECUADOR_ISO3_CODE, country.ISO3Code);
35+
Assert.Equal(ECUADOR_CALLING_CODE, country.CallingCode);
36+
Assert.NotNull(country.States);
37+
Assert.Equal(ECUADOR_STATE_COUNT, country.States.Count());
38+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class EgyptTest
4+
{
5+
private const string EGYPT_COUNTRY_NAME = "Egypt";
6+
private const string EGYPT_NATIVE_NAME = "جمهورية مصر العربية";
7+
private const string EGYPT_CAPITAL = "Cairo";
8+
private const string EGYPT_OFFICIAL_NAME = "Arab Republic of Egypt";
9+
private const string EGYPT_ISO2_CODE = "EG";
10+
private const string EGYPT_ISO3_CODE = "EGY";
11+
private const int EGYPT_NUMERIC_CODE = 818;
12+
private readonly string[] EGYPT_CALLING_CODE = ["+20"];
13+
private const int EGYPT_STATE_COUNT = 27; // 27 Governorates
14+
private static readonly string[] VALID_STATE_TYPES = { "Governorate" };
15+
16+
[Fact]
17+
public void GetCountry_ReturnsCorrectInformation_ForEgypt()
18+
{
19+
// Arrange
20+
CountryIdentifier existingCountryId = CountryIdentifier.Egypt;
21+
22+
// Act
23+
var country = CountryProvider.GetCountry(existingCountryId);
24+
25+
// Assert
26+
Assert.NotNull(country);
27+
Assert.Equal(existingCountryId, country.Id);
28+
Assert.Equal(EGYPT_COUNTRY_NAME, country.Name);
29+
Assert.Equal(EGYPT_OFFICIAL_NAME, country.OfficialName);
30+
Assert.Equal(EGYPT_NATIVE_NAME, country.NativeName);
31+
Assert.Equal(EGYPT_CAPITAL, country.Capital);
32+
Assert.Equal(EGYPT_NUMERIC_CODE, country.NumericCode);
33+
Assert.Equal(EGYPT_ISO2_CODE, country.ISO2Code);
34+
Assert.Equal(EGYPT_ISO3_CODE, country.ISO3Code);
35+
Assert.Equal(EGYPT_CALLING_CODE, country.CallingCode);
36+
Assert.NotNull(country.States);
37+
Assert.Equal(EGYPT_STATE_COUNT, country.States.Count());
38+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class TimorLesteTest
4+
{
5+
private const string TIMORLESTE_COUNTRY_NAME = "Timor-Leste";
6+
private const string TIMORLESTE_NATIVE_NAME = "Repúblika Demokrátika Timór-Leste";
7+
private const string TIMORLESTE_CAPITAL = "Dili";
8+
private const string TIMORLESTE_OFFICIAL_NAME = "Democratic Republic of Timor-Leste";
9+
private const string TIMORLESTE_ISO2_CODE = "TL";
10+
private const string TIMORLESTE_ISO3_CODE = "TLS";
11+
private const int TIMORLESTE_NUMERIC_CODE = 626;
12+
private readonly string[] TIMORLESTE_CALLING_CODE = ["+670"];
13+
private const int TIMORLESTE_STATE_COUNT = 13; // 12 municipalities + 1 special administrative region
14+
private static readonly string[] VALID_STATE_TYPES = { "Municipality", "Special Administrative Region" };
15+
16+
[Fact]
17+
public void GetCountry_ReturnsCorrectInformation_ForTimorLeste()
18+
{
19+
// Arrange
20+
CountryIdentifier existingCountryId = CountryIdentifier.TimorLeste;
21+
22+
// Act
23+
var country = CountryProvider.GetCountry(existingCountryId);
24+
25+
// Assert
26+
Assert.NotNull(country);
27+
Assert.Equal(existingCountryId, country.Id);
28+
Assert.Equal(TIMORLESTE_COUNTRY_NAME, country.Name);
29+
Assert.Equal(TIMORLESTE_OFFICIAL_NAME, country.OfficialName);
30+
Assert.Equal(TIMORLESTE_NATIVE_NAME, country.NativeName);
31+
Assert.Equal(TIMORLESTE_CAPITAL, country.Capital);
32+
Assert.Equal(TIMORLESTE_NUMERIC_CODE, country.NumericCode);
33+
Assert.Equal(TIMORLESTE_ISO2_CODE, country.ISO2Code);
34+
Assert.Equal(TIMORLESTE_ISO3_CODE, country.ISO3Code);
35+
Assert.Equal(TIMORLESTE_CALLING_CODE, country.CallingCode);
36+
Assert.NotNull(country.States);
37+
Assert.Equal(TIMORLESTE_STATE_COUNT, country.States.Count());
38+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
39+
}
40+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
namespace World.Net.Countries;
2+
3+
internal sealed class DominicanRepublic : ICountry
4+
{
5+
//<inheritdoc/>
6+
public CountryIdentifier Id => CountryIdentifier.DominicanRepublic;
7+
8+
//<inheritdoc/>
9+
public string Name { get; } = "Dominican Republic";
10+
11+
//<inheritdoc/>
12+
public string OfficialName { get; } = "Dominican Republic";
13+
14+
//<inheritdoc/>
15+
public string NativeName => "República Dominicana";
16+
17+
//<inheritdoc/>
18+
public string Capital { get; } = "Santo Domingo";
19+
20+
//<inheritdoc/>
21+
public int NumericCode { get; } = 214;
22+
23+
//<inheritdoc/>
24+
public string ISO2Code { get; } = "DO";
25+
26+
//<inheritdoc/>
27+
public string ISO3Code { get; } = "DOM";
28+
29+
//<inheritdoc/>
30+
public string[] CallingCode { get; } = ["+1-809", "+1-829", "+1-849"];
31+
32+
//<inheritdoc/>
33+
//<inheritdoc/>
34+
public IEnumerable<State> States =>
35+
[
36+
new("Azua", "DO-02"),
37+
new("Bahoruco", "DO-03"),
38+
new("Barahona", "DO-04"),
39+
new("Dajabón", "DO-05"),
40+
new("Distrito Nacional", "DO-01", "National District"),
41+
new("Duarte", "DO-06"),
42+
new("El Seibo", "DO-08"),
43+
new("Elias Piña", "DO-07"),
44+
new("Espaillat", "DO-09"),
45+
new("Hato Mayor", "DO-30"),
46+
new("Hermanas Mirabal", "DO-19"),
47+
new("Independencia", "DO-10"),
48+
new("La Altagracia", "DO-11"),
49+
new("La Romana", "DO-12"),
50+
new("La Vega", "DO-13"),
51+
new("Maria Trinidad Sanchez", "DO-14"),
52+
new("Monseñor Nouel", "DO-28"),
53+
new("Monte Cristi", "DO-15"),
54+
new("Monte Plata", "DO-29"),
55+
new("Pedernales", "DO-16"),
56+
new("Peravia", "DO-17"),
57+
new("Puerto Plata", "DO-18"),
58+
new("Samana", "DO-20"),
59+
new("San Cristobal", "DO-21"),
60+
new("San Jose de Ocoa", "DO-31"),
61+
new("San Juan", "DO-22"),
62+
new("San Pedro de Macoris", "DO-23"),
63+
new("Sanchez Ramirez", "DO-24"),
64+
new("Santiago", "DO-25"),
65+
new("Santiago Rodriguez", "DO-26"),
66+
new("Santo Domingo", "DO-32"),
67+
new("Valverde", "DO-27")
68+
];
69+
}

src/World.Net/Countries/Ecuador.cs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
namespace World.Net.Countries;
2+
3+
internal sealed class Ecuador : ICountry
4+
{
5+
//<inheritdoc/>
6+
public CountryIdentifier Id => CountryIdentifier.Ecuador;
7+
8+
//<inheritdoc/>
9+
public string Name { get; } = "Ecuador";
10+
11+
//<inheritdoc/>
12+
public string OfficialName { get; } = "Republic of Ecuador";
13+
14+
//<inheritdoc/>
15+
public string NativeName => "República del Ecuador";
16+
17+
//<inheritdoc/>
18+
public string Capital { get; } = "Quito";
19+
20+
//<inheritdoc/>
21+
public int NumericCode { get; } = 218;
22+
23+
//<inheritdoc/>
24+
public string ISO2Code { get; } = "EC";
25+
26+
//<inheritdoc/>
27+
public string ISO3Code { get; } = "ECU";
28+
29+
//<inheritdoc/>
30+
public string[] CallingCode { get; } = ["+593"];
31+
32+
//<inheritdoc/>
33+
public IEnumerable<State> States =>
34+
[
35+
new("Azuay", "EC-A"),
36+
new("Bolívar", "EC-B"),
37+
new("Cañar", "EC-F"),
38+
new("Carchi", "EC-C"),
39+
new("Chimborazo", "EC-H"),
40+
new("Cotopaxi", "EC-X"),
41+
new("El Oro", "EC-O"),
42+
new("Esmeraldas", "EC-E"),
43+
new("Galápagos", "EC-W"),
44+
new("Guayas", "EC-G"),
45+
new("Imbabura", "EC-I"),
46+
new("Loja", "EC-L"),
47+
new("Los Ríos", "EC-R"),
48+
new("Manabí", "EC-M"),
49+
new("Morona Santiago", "EC-S"),
50+
new("Napo", "EC-N"),
51+
new("Orellana", "EC-D"),
52+
new("Pastaza", "EC-Y"),
53+
new("Pichincha", "EC-P"),
54+
new("Santa Elena", "EC-SE"),
55+
new("Santo Domingo de los Tsáchilas", "EC-SD"),
56+
new("Sucumbíos", "EC-U"),
57+
new("Tungurahua", "EC-T"),
58+
new("Zamora Chinchipe", "EC-Z")
59+
];
60+
}

src/World.Net/Countries/Egypt.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
namespace World.Net.Countries;
2+
3+
internal sealed class Egypt : ICountry
4+
{
5+
//<inheritdoc/>
6+
public CountryIdentifier Id => CountryIdentifier.Egypt;
7+
8+
//<inheritdoc/>
9+
public string Name { get; } = "Egypt";
10+
11+
//<inheritdoc/>
12+
public string OfficialName { get; } = "Arab Republic of Egypt";
13+
14+
//<inheritdoc/>
15+
public string NativeName => "جمهورية مصر العربية";
16+
17+
//<inheritdoc/>
18+
public string Capital { get; } = "Cairo";
19+
20+
//<inheritdoc/>
21+
public int NumericCode { get; } = 818;
22+
23+
//<inheritdoc/>
24+
public string ISO2Code { get; } = "EG";
25+
26+
//<inheritdoc/>
27+
public string ISO3Code { get; } = "EGY";
28+
29+
//<inheritdoc/>
30+
public string[] CallingCode { get; } = ["+20"];
31+
32+
//<inheritdoc/>
33+
public IEnumerable<State> States =>
34+
[
35+
new("Alexandria", "EG-ALX", "Governorate"),
36+
new("Aswan", "EG-ASN", "Governorate"),
37+
new("Asyut", "EG-AST", "Governorate"),
38+
new("Beheira", "EG-BH", "Governorate"),
39+
new("Beni Suef", "EG-BNS", "Governorate"),
40+
new("Cairo", "EG-C", "Governorate"),
41+
new("Dakahlia", "EG-DK", "Governorate"),
42+
new("Damietta", "EG-DT", "Governorate"),
43+
new("Faiyum", "EG-FYM", "Governorate"),
44+
new("Gharbia", "EG-GH", "Governorate"),
45+
new("Giza", "EG-GZ", "Governorate"),
46+
new("Ismailia", "EG-IS", "Governorate"),
47+
new("Kafr El Sheikh", "EG-KFS", "Governorate"),
48+
new("Luxor", "EG-LX", "Governorate"),
49+
new("Matrouh", "EG-MT", "Governorate"),
50+
new("Minya", "EG-MN", "Governorate"),
51+
new("Monufia", "EG-MNF", "Governorate"),
52+
new("New Valley", "EG-WAD", "Governorate"),
53+
new("North Sinai", "EG-SIN", "Governorate"),
54+
new("Port Said", "EG-PTS", "Governorate"),
55+
new("Qalyubia", "EG-KB", "Governorate"),
56+
new("Qena", "EG-QN", "Governorate"),
57+
new("Red Sea", "EG-BA", "Governorate"),
58+
new("Sharqia", "EG-SHR", "Governorate"),
59+
new("Sohag", "EG-SHG", "Governorate"),
60+
new("South Sinai", "EG-JS", "Governorate"),
61+
new("Suez", "EG-SUZ", "Governorate")
62+
];
63+
}

0 commit comments

Comments
 (0)