Skip to content

Commit a77a45f

Browse files
authored
Merge pull request #82 from deanology/NewCountries_1
Germany, Ghana, Gibraltar, Greece, Greenland
2 parents 5aaee0f + e973a64 commit a77a45f

11 files changed

Lines changed: 486 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class GermanyTest : AssertCountryTestBase
4+
{
5+
private const string GERMANY_COUNTRY_NAME = "Germany";
6+
private const string GERMANY_NATIVE_NAME = "Deutschland";
7+
private const string GERMANY_CAPITAL = "Berlin";
8+
private const string GERMANY_OFFICIAL_NAME = "Federal Republic of Germany";
9+
private const string GERMANY_ISO2_CODE = "DE";
10+
private const string GERMANY_ISO3_CODE = "DEU";
11+
private const int GERMANY_NUMERIC_CODE = 276;
12+
private readonly string[] GERMANY_CALLING_CODE = ["+49"];
13+
private const CountryIdentifier EXPECTEDID = CountryIdentifier.Germany;
14+
15+
private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES =
16+
[
17+
new("Baden-Württemberg", "DE-BW", "State"),
18+
new("Bavaria", "DE-BY", "State"),
19+
new("Berlin", "DE-BE", "State"),
20+
new("Brandenburg", "DE-BB", "State"),
21+
new("Bremen", "DE-HB", "State"),
22+
new("Hamburg", "DE-HH", "State"),
23+
new("Hesse", "DE-HE", "State"),
24+
new("Lower Saxony", "DE-NI", "State"),
25+
new("Mecklenburg-Vorpommern", "DE-MV", "State"),
26+
new("North Rhine-Westphalia", "DE-NW", "State"),
27+
new("Rhineland-Palatinate", "DE-RP", "State"),
28+
new("Saarland", "DE-SL", "State"),
29+
new("Saxony", "DE-SN", "State"),
30+
new("Saxony-Anhalt", "DE-ST", "State"),
31+
new("Schleswig-Holstein", "DE-SH", "State"),
32+
new("Thuringia", "DE-TH", "State")
33+
];
34+
35+
[Fact]
36+
public void GetCountry_ReturnsCorrectInformation_ForGermany()
37+
{
38+
// Arrange
39+
// Act
40+
var country = CountryProvider.GetCountry(EXPECTEDID);
41+
42+
// Assert
43+
AssertCorrectInformation(
44+
country,
45+
EXPECTEDID,
46+
GERMANY_COUNTRY_NAME,
47+
GERMANY_OFFICIAL_NAME,
48+
GERMANY_NATIVE_NAME,
49+
GERMANY_CAPITAL,
50+
GERMANY_NUMERIC_CODE,
51+
GERMANY_ISO2_CODE,
52+
GERMANY_ISO3_CODE,
53+
GERMANY_CALLING_CODE,
54+
EXPECTED_STATES
55+
);
56+
}
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class GhanaTest : AssertCountryTestBase
4+
{
5+
private const string GHANA_COUNTRY_NAME = "Ghana";
6+
private const string GHANA_NATIVE_NAME = "Ghana";
7+
private const string GHANA_CAPITAL = "Accra";
8+
private const string GHANA_OFFICIAL_NAME = "Republic of Ghana";
9+
private const string GHANA_ISO2_CODE = "GH";
10+
private const string GHANA_ISO3_CODE = "GHA";
11+
private const int GHANA_NUMERIC_CODE = 288;
12+
private readonly string[] GHANA_CALLING_CODE = ["+233"];
13+
private const CountryIdentifier EXPECTEDID = CountryIdentifier.Ghana;
14+
15+
private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES =
16+
[
17+
new("Ahafo", "GH-AF", "Region"),
18+
new("Ashanti", "GH-AH", "Region"),
19+
new("Bono", "GH-BO", "Region"),
20+
new("Bono East", "GH-BE", "Region"),
21+
new("Central", "GH-CP", "Region"),
22+
new("Eastern", "GH-EP", "Region"),
23+
new("Greater Accra", "GH-AA", "Region"),
24+
new("North East", "GH-NE", "Region"),
25+
new("Northern", "GH-NP", "Region"),
26+
new("Oti", "GH-OT", "Region"),
27+
new("Savannah", "GH-SV", "Region"),
28+
new("Upper East", "GH-UE", "Region"),
29+
new("Upper West", "GH-UW", "Region"),
30+
new("Volta", "GH-TV", "Region"),
31+
new("Western", "GH-WP", "Region"),
32+
new("Western North", "GH-WN", "Region")
33+
];
34+
35+
[Fact]
36+
public void GetCountry_ReturnsCorrectInformation_ForGhana()
37+
{
38+
// Arrange
39+
// Act
40+
var country = CountryProvider.GetCountry(EXPECTEDID);
41+
42+
// Assert
43+
AssertCorrectInformation(
44+
country,
45+
EXPECTEDID,
46+
GHANA_COUNTRY_NAME,
47+
GHANA_OFFICIAL_NAME,
48+
GHANA_NATIVE_NAME,
49+
GHANA_CAPITAL,
50+
GHANA_NUMERIC_CODE,
51+
GHANA_ISO2_CODE,
52+
GHANA_ISO3_CODE,
53+
GHANA_CALLING_CODE,
54+
EXPECTED_STATES
55+
);
56+
}
57+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class GibraltarTest : AssertCountryTestBase
4+
{
5+
private const string GIBRALTAR_COUNTRY_NAME = "Gibraltar";
6+
private const string GIBRALTAR_NATIVE_NAME = "Gibraltar";
7+
private const string GIBRALTAR_CAPITAL = "Gibraltar";
8+
private const string GIBRALTAR_OFFICIAL_NAME = "Gibraltar";
9+
private const string GIBRALTAR_ISO2_CODE = "GI";
10+
private const string GIBRALTAR_ISO3_CODE = "GIB";
11+
private const int GIBRALTAR_NUMERIC_CODE = 292;
12+
private readonly string[] GIBRALTAR_CALLING_CODE = ["+350"];
13+
private const CountryIdentifier EXPECTEDID = CountryIdentifier.Gibraltar;
14+
15+
private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES = [];
16+
17+
[Fact]
18+
public void GetCountry_ReturnsCorrectInformation_ForGibraltar()
19+
{
20+
// Arrange
21+
// Act
22+
var country = CountryProvider.GetCountry(EXPECTEDID);
23+
24+
// Assert
25+
AssertCorrectInformation(
26+
country,
27+
EXPECTEDID,
28+
GIBRALTAR_COUNTRY_NAME,
29+
GIBRALTAR_OFFICIAL_NAME,
30+
GIBRALTAR_NATIVE_NAME,
31+
GIBRALTAR_CAPITAL,
32+
GIBRALTAR_NUMERIC_CODE,
33+
GIBRALTAR_ISO2_CODE,
34+
GIBRALTAR_ISO3_CODE,
35+
GIBRALTAR_CALLING_CODE,
36+
EXPECTED_STATES
37+
);
38+
}
39+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class GreeceTest : AssertCountryTestBase
4+
{
5+
private const string GREECE_COUNTRY_NAME = "Greece";
6+
private const string GREECE_NATIVE_NAME = "Ελλάδα";
7+
private const string GREECE_CAPITAL = "Athens";
8+
private const string GREECE_OFFICIAL_NAME = "Hellenic Republic";
9+
private const string GREECE_ISO2_CODE = "GR";
10+
private const string GREECE_ISO3_CODE = "GRC";
11+
private const int GREECE_NUMERIC_CODE = 300;
12+
private readonly string[] GREECE_CALLING_CODE = ["+30"];
13+
private const CountryIdentifier EXPECTEDID = CountryIdentifier.Greece;
14+
15+
private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES =
16+
[
17+
new("Attica", "GR-I", "Region"),
18+
new("Central Greece", "GR-H", "Region"),
19+
new("Central Macedonia", "GR-B", "Region"),
20+
new("Crete", "GR-M", "Region"),
21+
new("Eastern Macedonia and Thrace", "GR-A", "Region"),
22+
new("Epirus", "GR-D", "Region"),
23+
new("Ionian Islands", "GR-F", "Region"),
24+
new("North Aegean", "GR-K", "Region"),
25+
new("Peloponnese", "GR-J", "Region"),
26+
new("South Aegean", "GR-L", "Region"),
27+
new("Thessaly", "GR-E", "Region"),
28+
new("Western Greece", "GR-G", "Region"),
29+
new("Western Macedonia", "GR-C", "Region")
30+
];
31+
32+
[Fact]
33+
public void GetCountry_ReturnsCorrectInformation_ForGreece()
34+
{
35+
// Arrange
36+
// Act
37+
var country = CountryProvider.GetCountry(EXPECTEDID);
38+
39+
// Assert
40+
AssertCorrectInformation(
41+
country,
42+
EXPECTEDID,
43+
GREECE_COUNTRY_NAME,
44+
GREECE_OFFICIAL_NAME,
45+
GREECE_NATIVE_NAME,
46+
GREECE_CAPITAL,
47+
GREECE_NUMERIC_CODE,
48+
GREECE_ISO2_CODE,
49+
GREECE_ISO3_CODE,
50+
GREECE_CALLING_CODE,
51+
EXPECTED_STATES
52+
);
53+
}
54+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
namespace World.Net.UnitTests.Countries;
2+
3+
public sealed class GreenlandTest : AssertCountryTestBase
4+
{
5+
private const string GREENLAND_COUNTRY_NAME = "Greenland";
6+
private const string GREENLAND_NATIVE_NAME = "Kalaallit Nunaat";
7+
private const string GREENLAND_CAPITAL = "Nuuk";
8+
private const string GREENLAND_OFFICIAL_NAME = "Greenland";
9+
private const string GREENLAND_ISO2_CODE = "GL";
10+
private const string GREENLAND_ISO3_CODE = "GRL";
11+
private const int GREENLAND_NUMERIC_CODE = 304;
12+
private readonly string[] GREENLAND_CALLING_CODE = ["+299"];
13+
private const CountryIdentifier EXPECTEDID = CountryIdentifier.Greenland;
14+
15+
private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES =
16+
[
17+
new("Avannaata", "GL-AV", "Municipality"),
18+
new("Kujalleq", "GL-KU", "Municipality"),
19+
new("Qeqertalik", "GL-QT", "Municipality"),
20+
new("Qeqqata", "GL-QE", "Municipality"),
21+
new("Sermersooq", "GL-SM", "Municipality")
22+
];
23+
24+
[Fact]
25+
public void GetCountry_ReturnsCorrectInformation_ForGreenland()
26+
{
27+
// Arrange
28+
// Act
29+
var country = CountryProvider.GetCountry(EXPECTEDID);
30+
31+
// Assert
32+
AssertCorrectInformation(
33+
country,
34+
EXPECTEDID,
35+
GREENLAND_COUNTRY_NAME,
36+
GREENLAND_OFFICIAL_NAME,
37+
GREENLAND_NATIVE_NAME,
38+
GREENLAND_CAPITAL,
39+
GREENLAND_NUMERIC_CODE,
40+
GREENLAND_ISO2_CODE,
41+
GREENLAND_ISO3_CODE,
42+
GREENLAND_CALLING_CODE,
43+
EXPECTED_STATES
44+
);
45+
}
46+
}

src/World.Net/Countries/Germany.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
namespace World.Net.Countries;
2+
3+
internal sealed class Germany : ICountry
4+
{
5+
//<inheritdoc/>
6+
public CountryIdentifier Id => CountryIdentifier.Germany;
7+
8+
//<inheritdoc/>
9+
public string Name { get; } = "Germany";
10+
11+
//<inheritdoc/>
12+
public string OfficialName { get; } = "Federal Republic of Germany";
13+
14+
//<inheritdoc/>
15+
public string NativeName => "Deutschland";
16+
17+
//<inheritdoc/>
18+
public string Capital { get; } = "Berlin";
19+
20+
//<inheritdoc/>
21+
public int NumericCode { get; } = 276;
22+
23+
//<inheritdoc/>
24+
public string ISO2Code { get; } = "DE";
25+
26+
//<inheritdoc/>
27+
public string ISO3Code { get; } = "DEU";
28+
29+
//<inheritdoc/>
30+
public string[] CallingCode { get; } = ["+49"];
31+
32+
//<inheritdoc/>
33+
public IEnumerable<State> States =>
34+
[
35+
new("Baden-Württemberg", "DE-BW", "State"),
36+
new("Bavaria", "DE-BY", "State"),
37+
new("Berlin", "DE-BE", "State"),
38+
new("Brandenburg", "DE-BB", "State"),
39+
new("Bremen", "DE-HB", "State"),
40+
new("Hamburg", "DE-HH", "State"),
41+
new("Hesse", "DE-HE", "State"),
42+
new("Lower Saxony", "DE-NI", "State"),
43+
new("Mecklenburg-Vorpommern", "DE-MV", "State"),
44+
new("North Rhine-Westphalia", "DE-NW", "State"),
45+
new("Rhineland-Palatinate", "DE-RP", "State"),
46+
new("Saarland", "DE-SL", "State"),
47+
new("Saxony", "DE-SN", "State"),
48+
new("Saxony-Anhalt", "DE-ST", "State"),
49+
new("Schleswig-Holstein", "DE-SH", "State"),
50+
new("Thuringia", "DE-TH", "State")
51+
];
52+
}

src/World.Net/Countries/Ghana.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
namespace World.Net.Countries;
2+
3+
internal sealed class Ghana : ICountry
4+
{
5+
//<inheritdoc/>
6+
public CountryIdentifier Id => CountryIdentifier.Ghana;
7+
8+
//<inheritdoc/>
9+
public string Name { get; } = "Ghana";
10+
11+
//<inheritdoc/>
12+
public string OfficialName { get; } = "Republic of Ghana";
13+
14+
//<inheritdoc/>
15+
public string NativeName => "Ghana";
16+
17+
//<inheritdoc/>
18+
public string Capital { get; } = "Accra";
19+
20+
//<inheritdoc/>
21+
public int NumericCode { get; } = 288;
22+
23+
//<inheritdoc/>
24+
public string ISO2Code { get; } = "GH";
25+
26+
//<inheritdoc/>
27+
public string ISO3Code { get; } = "GHA";
28+
29+
//<inheritdoc/>
30+
public string[] CallingCode { get; } = ["+233"];
31+
32+
//<inheritdoc/>
33+
public IEnumerable<State> States =>
34+
[
35+
new("Ahafo", "GH-AF", "Region"),
36+
new("Ashanti", "GH-AH", "Region"),
37+
new("Bono", "GH-BO", "Region"),
38+
new("Bono East", "GH-BE", "Region"),
39+
new("Central", "GH-CP", "Region"),
40+
new("Eastern", "GH-EP", "Region"),
41+
new("Greater Accra", "GH-AA", "Region"),
42+
new("North East", "GH-NE", "Region"),
43+
new("Northern", "GH-NP", "Region"),
44+
new("Oti", "GH-OT", "Region"),
45+
new("Savannah", "GH-SV", "Region"),
46+
new("Upper East", "GH-UE", "Region"),
47+
new("Upper West", "GH-UW", "Region"),
48+
new("Volta", "GH-TV", "Region"),
49+
new("Western", "GH-WP", "Region"),
50+
new("Western North", "GH-WN", "Region")
51+
];
52+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace World.Net.Countries;
2+
3+
internal sealed class Gibraltar : ICountry
4+
{
5+
//<inheritdoc/>
6+
public CountryIdentifier Id => CountryIdentifier.Gibraltar;
7+
8+
//<inheritdoc/>
9+
public string Name { get; } = "Gibraltar";
10+
11+
//<inheritdoc/>
12+
public string OfficialName { get; } = "Gibraltar";
13+
14+
//<inheritdoc/>
15+
public string NativeName => "Gibraltar";
16+
17+
//<inheritdoc/>
18+
public string Capital { get; } = "Gibraltar";
19+
20+
//<inheritdoc/>
21+
public int NumericCode { get; } = 292;
22+
23+
//<inheritdoc/>
24+
public string ISO2Code { get; } = "GI";
25+
26+
//<inheritdoc/>
27+
public string ISO3Code { get; } = "GIB";
28+
29+
//<inheritdoc/>
30+
public string[] CallingCode { get; } = ["+350"];
31+
32+
//<inheritdoc/>
33+
public IEnumerable<State> States => [];
34+
}

0 commit comments

Comments
 (0)