Skip to content

Commit 934a0ea

Browse files
authored
add country details for Estonia Ethiopia FalklandIslands and Eswatini (#57)
* add estonia * initialize estonia * add Ethiopia details * rename estonia test class * add ethiopia test class * add FalklandIslands details * add FalklandIslands tests * add Eswatini * add Eswatini test class
1 parent f0889b6 commit 934a0ea

9 files changed

Lines changed: 312 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 EstoniaTest
4+
{
5+
private const string ESTONIA_NAME = "Estonia";
6+
private const int ESTONIA_STATE_COUNT = 15;
7+
private const string ESTONIA_OFFICIAL_NAME = "Republic of Estonia";
8+
private const string ESTONIA_NATIVE_NAME = "Eesti";
9+
private const string ESTONIA_CAPITAL = "Tallinn";
10+
private const int ESTONIA_NUMERIC_CODE = 233;
11+
private const string ESTONIA_ISO2_CODE = "EE";
12+
private const string ESTONIA_ISO3_CODE = "EST";
13+
private readonly string[] ESTONIA_CALLING_CODE = ["372"];
14+
private static readonly string[] VALID_STATE_TYPES = { "County" };
15+
16+
[Fact]
17+
public void GetCountry_ReturnsCorrectInformation_ForEstonia()
18+
{
19+
// Arrange
20+
CountryIdentifier existingCountryId = CountryIdentifier.Estonia;
21+
22+
// Act
23+
var country = CountryProvider.GetCountry(existingCountryId);
24+
25+
// Assert
26+
Assert.Equal(existingCountryId, country.Id);
27+
Assert.Equal(ESTONIA_NAME, country.Name);
28+
Assert.NotNull(country.States);
29+
Assert.Equal(ESTONIA_STATE_COUNT, country.States.Count());
30+
Assert.Equal(ESTONIA_OFFICIAL_NAME, country.OfficialName);
31+
Assert.Equal(ESTONIA_NATIVE_NAME, country.NativeName);
32+
Assert.Equal(ESTONIA_CAPITAL, country.Capital);
33+
Assert.Equal(ESTONIA_NUMERIC_CODE, country.NumericCode);
34+
Assert.Equal(ESTONIA_ISO2_CODE, country.ISO2Code);
35+
Assert.Equal(ESTONIA_ISO3_CODE, country.ISO3Code);
36+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
37+
Assert.Equal(ESTONIA_CALLING_CODE, country.CallingCode);
38+
}
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 class EswatiniTest
4+
{
5+
private const string ESWATINI_NAME = "Eswatini";
6+
private const int ESWATINI_STATE_COUNT = 4;
7+
private const string ESWATINI_OFFICIAL_NAME = "Kingdom of Eswatini";
8+
private const string ESWATINI_NATIVE_NAME = "eSwatini";
9+
private const string ESWATINI_CAPITAL = "Mbabane";
10+
private const int ESWATINI_NUMERIC_CODE = 748;
11+
private const string ESWATINI_ISO2_CODE = "SZ";
12+
private const string ESWATINI_ISO3_CODE = "SWZ";
13+
private readonly string[] ESWATINI_CALLING_CODE = ["268"];
14+
private static readonly string[] VALID_STATE_TYPES = { "Region" };
15+
16+
[Fact]
17+
public void GetCountry_ReturnsCorrectInformation_ForEswatini()
18+
{
19+
// Arrange
20+
CountryIdentifier existingCountryId = CountryIdentifier.Eswatini;
21+
22+
// Act
23+
var country = CountryProvider.GetCountry(existingCountryId);
24+
25+
// Assert
26+
Assert.Equal(existingCountryId, country.Id);
27+
Assert.Equal(ESWATINI_NAME, country.Name);
28+
Assert.NotNull(country.States);
29+
Assert.Equal(ESWATINI_STATE_COUNT, country.States.Count());
30+
Assert.Equal(ESWATINI_OFFICIAL_NAME, country.OfficialName);
31+
Assert.Equal(ESWATINI_NATIVE_NAME, country.NativeName);
32+
Assert.Equal(ESWATINI_CAPITAL, country.Capital);
33+
Assert.Equal(ESWATINI_NUMERIC_CODE, country.NumericCode);
34+
Assert.Equal(ESWATINI_ISO2_CODE, country.ISO2Code);
35+
Assert.Equal(ESWATINI_ISO3_CODE, country.ISO3Code);
36+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
37+
Assert.Equal(ESWATINI_CALLING_CODE, country.CallingCode);
38+
}
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 EthiopiaTest
4+
{
5+
private const string ETHIOPIA_NAME = "Ethiopia";
6+
private const int ETHIOPIA_STATE_COUNT = 12;
7+
private const string ETHIOPIA_OFFICIAL_NAME = "Federal Democratic Republic of Ethiopia";
8+
private const string ETHIOPIA_NATIVE_NAME = "ኢትዮጵያ";
9+
private const string ETHIOPIA_CAPITAL = "Addis Ababa";
10+
private const int ETHIOPIA_NUMERIC_CODE = 231;
11+
private const string ETHIOPIA_ISO2_CODE = "ET";
12+
private const string ETHIOPIA_ISO3_CODE = "ETH";
13+
private readonly string[] ETHIOPIA_CALLING_CODE = ["251"];
14+
private static readonly string[] VALID_STATE_TYPES = { "Region", "Administration" };
15+
16+
[Fact]
17+
public void GetCountry_ReturnsCorrectInformation_ForEthiopia()
18+
{
19+
// Arrange
20+
CountryIdentifier existingCountryId = CountryIdentifier.Ethiopia;
21+
22+
// Act
23+
var country = CountryProvider.GetCountry(existingCountryId);
24+
25+
// Assert
26+
Assert.Equal(existingCountryId, country.Id);
27+
Assert.Equal(ETHIOPIA_NAME, country.Name);
28+
Assert.NotNull(country.States);
29+
Assert.Equal(ETHIOPIA_STATE_COUNT, country.States.Count());
30+
Assert.Equal(ETHIOPIA_OFFICIAL_NAME, country.OfficialName);
31+
Assert.Equal(ETHIOPIA_NATIVE_NAME, country.NativeName);
32+
Assert.Equal(ETHIOPIA_CAPITAL, country.Capital);
33+
Assert.Equal(ETHIOPIA_NUMERIC_CODE, country.NumericCode);
34+
Assert.Equal(ETHIOPIA_ISO2_CODE, country.ISO2Code);
35+
Assert.Equal(ETHIOPIA_ISO3_CODE, country.ISO3Code);
36+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
37+
Assert.Equal(ETHIOPIA_CALLING_CODE, country.CallingCode);
38+
}
39+
}
40+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace World.Net.UnitTests.Countries
8+
{
9+
public sealed class FalklandIslandsTest
10+
{
11+
private const string FALKLANDS_NAME = "FalklandIslands";
12+
private const string FALKLANDS_OFFICIAL_NAME = "Falkland Islands";
13+
private const string FALKLANDS_NATIVE_NAME = "Falkland Islands";
14+
private const string FALKLANDS_CAPITAL = "Stanley";
15+
private const int FALKLANDS_NUMERIC_CODE = 238;
16+
private const string FALKLANDS_ISO2_CODE = "FK";
17+
private const string FALKLANDS_ISO3_CODE = "FLK";
18+
private readonly string[] FALKLANDS_CALLING_CODE = ["500"];
19+
private static readonly string[] VALID_STATE_TYPES = { "Overseas Territory" };
20+
21+
[Fact]
22+
public void GetCountry_ReturnsCorrectInformation_ForFalklandIslands()
23+
{
24+
// Arrange
25+
CountryIdentifier existingCountryId = CountryIdentifier.FalklandIslands;
26+
27+
// Act
28+
var country = CountryProvider.GetCountry(existingCountryId);
29+
30+
// Assert
31+
Assert.Equal(existingCountryId, country.Id);
32+
Assert.Equal(FALKLANDS_NAME, country.Name);
33+
Assert.NotNull(country.States);
34+
Assert.Single(country.States);
35+
Assert.Equal(FALKLANDS_OFFICIAL_NAME, country.OfficialName);
36+
Assert.Equal(FALKLANDS_NATIVE_NAME, country.NativeName);
37+
Assert.Equal(FALKLANDS_CAPITAL, country.Capital);
38+
Assert.Equal(FALKLANDS_NUMERIC_CODE, country.NumericCode);
39+
Assert.Equal(FALKLANDS_ISO2_CODE, country.ISO2Code);
40+
Assert.Equal(FALKLANDS_ISO3_CODE, country.ISO3Code);
41+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
42+
Assert.Equal(FALKLANDS_CALLING_CODE, country.CallingCode);
43+
}
44+
}
45+
}

src/World.Net/Countries/Estonia.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+

2+
namespace World.Net.Countries
3+
{
4+
internal sealed class Estonia : ICountry
5+
{
6+
public CountryIdentifier Id => CountryIdentifier.Estonia;
7+
8+
public string Name => nameof(Estonia);
9+
10+
public string OfficialName => "Republic of Estonia";
11+
12+
public string NativeName => "Eesti";
13+
14+
public string Capital => "Tallinn";
15+
16+
public int NumericCode => 233;
17+
18+
public string ISO2Code => "EE";
19+
20+
public string ISO3Code => "EST";
21+
22+
public string[] CallingCode => ["372"];
23+
24+
public IEnumerable<State> States =>
25+
[
26+
new("Harju", "37", "County"),
27+
new("Hiiu", "39", "County"),
28+
new("Ida-Viru", "44", "County"),
29+
new("Jõgeva", "49", "County"),
30+
new("Järva", "51", "County"),
31+
new("Lääne", "57", "County"),
32+
new("Lääne-Viru", "59", "County"),
33+
new("Põlva", "65", "County"),
34+
new("Pärnu", "67", "County"),
35+
new("Rapla", "70", "County"),
36+
new("Saare", "74", "County"),
37+
new("Tartu", "78", "County"),
38+
new("Valga", "82", "County"),
39+
new("Viljandi", "84", "County"),
40+
new("Võru", "86", "County")
41+
];
42+
}
43+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace World.Net.Countries
2+
{
3+
internal sealed class Eswatini : ICountry
4+
{
5+
public CountryIdentifier Id => CountryIdentifier.Eswatini;
6+
7+
public string Name => nameof(Eswatini);
8+
9+
public string OfficialName => "Kingdom of Eswatini";
10+
11+
public string NativeName => "eSwatini";
12+
13+
public string Capital => "Mbabane";
14+
15+
public int NumericCode => 748;
16+
17+
public string ISO2Code => "SZ";
18+
19+
public string ISO3Code => "SWZ";
20+
21+
public string[] CallingCode => ["268"];
22+
23+
public IEnumerable<State> States =>
24+
[
25+
new State("Hhohho", "HH", "Region"),
26+
new State("Lubombo", "LU", "Region"),
27+
new State("Manzini", "MA", "Region"),
28+
new State("Shiselweni", "SH", "Region")
29+
];
30+
}
31+
32+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace World.Net.Countries
2+
{
3+
internal sealed class Ethiopia : ICountry
4+
{
5+
public CountryIdentifier Id => CountryIdentifier.Ethiopia;
6+
7+
public string Name => nameof(Ethiopia);
8+
9+
public string OfficialName => "Federal Democratic Republic of Ethiopia";
10+
11+
public string NativeName => "ኢትዮጵያ";
12+
13+
public string Capital => "Addis Ababa";
14+
15+
public int NumericCode => 231;
16+
17+
public string ISO2Code => "ET";
18+
19+
public string ISO3Code => "ETH";
20+
21+
public string[] CallingCode => ["251"];
22+
23+
public IEnumerable<State> States =>
24+
[
25+
new("Addis Ababa", "AA", "Administration"),
26+
new("Afar", "AF", "Region"),
27+
new("Amhara", "AM", "Region"),
28+
new("Benishangul-Gumuz", "BE", "Region"),
29+
new("Dire Dawa", "DD", "Administration"),
30+
new("Gambela", "GA", "Region"),
31+
new("Harari", "HA", "Region"),
32+
new("Oromia", "OR", "Region"),
33+
new("Sidama", "SI", "Region"),
34+
new("Somali", "SO", "Region"),
35+
new("Southern Nations, Nationalities, and Peoples' Region", "SN", "Region"),
36+
new("Tigray", "TI", "Region")
37+
];
38+
}
39+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace World.Net.Countries
2+
{
3+
internal sealed class FalklandIslands : ICountry
4+
{
5+
public CountryIdentifier Id => CountryIdentifier.FalklandIslands;
6+
7+
public string Name => nameof(FalklandIslands);
8+
9+
public string OfficialName => "Falkland Islands";
10+
11+
public string NativeName => "Falkland Islands";
12+
13+
public string Capital => "Stanley";
14+
15+
public int NumericCode => 238;
16+
17+
public string ISO2Code => "FK";
18+
19+
public string ISO3Code => "FLK";
20+
21+
public string[] CallingCode => ["500"];
22+
23+
public IEnumerable<State> States =>
24+
[
25+
new("Falkland Islands", "FK", "Overseas Territory")
26+
];
27+
}
28+
29+
}

src/World.Net/Helpers/CountryInitializer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
7171
{ CountryIdentifier.TimorLeste, new TimorLeste() },
7272
{ CountryIdentifier.Ecuador, new Ecuador() },
7373
{ CountryIdentifier.Egypt, new Egypt() },
74+
{ CountryIdentifier.Estonia, new Estonia() },
75+
{ CountryIdentifier.Ethiopia, new Ethiopia() },
76+
{ CountryIdentifier.Eswatini, new Eswatini() },
77+
{ CountryIdentifier.FalklandIslands, new FalklandIslands() },
7478
{ CountryIdentifier.FaroeIslands, new FaroeIslands() },
7579
{ CountryIdentifier.FijiIslands, new FijiIslands() },
7680
{ CountryIdentifier.Finland, new Finland() },

0 commit comments

Comments
 (0)