Skip to content

Commit 55ebe0e

Browse files
authored
Add country details for Denmark Djibouti Dominica (#55)
* Add country details for Denmark Djibouti Dominica * resolve comments
1 parent 6ce72c9 commit 55ebe0e

7 files changed

Lines changed: 249 additions & 6 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace World.Net.UnitTests.Countries;
2+
public sealed class DenmarkTest
3+
{
4+
private const string DENMARK_NAME = "Denmark";
5+
private const int DENMARK_STATE_COUNT = 5;
6+
private const string DENMARK_OFFICIAL_NAME = "Kingdom of Denmark";
7+
private const string DENMARK_NATIVE_NAME = "Danmark";
8+
private const string DENMARK_CAPITAL = "Copenhagen";
9+
private const int DENMARK_NUMERIC_CODE = 208;
10+
private const string DENMARK_ISO2_CODE = "DK";
11+
private const string DENMARK_ISO3_CODE = "DNK";
12+
private readonly string[] DENMARK_CALLING_CODE = ["+45"];
13+
private static readonly string[] VALID_STATE_TYPES = { "Region" };
14+
15+
[Fact]
16+
public void GetCountry_ReturnsCorrectInformation_ForDenmark()
17+
{
18+
// Arrange
19+
CountryIdentifier existingCountryId = CountryIdentifier.Denmark;
20+
21+
// Act
22+
var country = CountryProvider.GetCountry(existingCountryId);
23+
24+
//Assert
25+
Assert.Equal(existingCountryId, country.Id);
26+
Assert.Equal(DENMARK_NAME, country.Name);
27+
Assert.NotNull(country.States);
28+
Assert.Equal(DENMARK_STATE_COUNT, country.States.Count());
29+
Assert.Equal(DENMARK_OFFICIAL_NAME, country.OfficialName);
30+
Assert.Equal(DENMARK_NATIVE_NAME, country.NativeName);
31+
Assert.Equal(DENMARK_CAPITAL, country.Capital);
32+
Assert.Equal(DENMARK_NUMERIC_CODE, country.NumericCode);
33+
Assert.Equal(DENMARK_ISO2_CODE, country.ISO2Code);
34+
Assert.Equal(DENMARK_ISO3_CODE, country.ISO3Code);
35+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
36+
Assert.Equal(DENMARK_CALLING_CODE, country.CallingCode);
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace World.Net.UnitTests.Countries;
2+
public sealed class DjiboutiTest
3+
{
4+
private const string DJIBOUTI_NAME = "Djibouti";
5+
private const int DJIBOUTI_STATE_COUNT = 6;
6+
private const string DJIBOUTI_OFFICIAL_NAME = "Republic of Djibouti";
7+
private const string DJIBOUTI_NATIVE_NAME = "Djibouti";
8+
private const string DJIBOUTI_CAPITAL = "Djibouti";
9+
private const int DJIBOUTI_NUMERIC_CODE = 262;
10+
private const string DJIBOUTI_ISO2_CODE = "DJ";
11+
private const string DJIBOUTI_ISO3_CODE = "DJI";
12+
private static readonly string[] VALID_STATE_TYPES = { "Region", "City" };
13+
private readonly string[] DJIBOUTI_CALLING_CODE = ["+253"];
14+
15+
[Fact]
16+
public void GetCountry_ReturnsCorrectInformation_ForDjibouti()
17+
{
18+
// Arrange
19+
CountryIdentifier existingCountryId = CountryIdentifier.Djibouti;
20+
21+
// Act
22+
var country = CountryProvider.GetCountry(existingCountryId);
23+
24+
//Assert
25+
Assert.Equal(existingCountryId, country.Id);
26+
Assert.Equal(DJIBOUTI_NAME, country.Name);
27+
Assert.NotNull(country.States);
28+
Assert.Equal(DJIBOUTI_STATE_COUNT, country.States.Count());
29+
Assert.Equal(DJIBOUTI_OFFICIAL_NAME, country.OfficialName);
30+
Assert.Equal(DJIBOUTI_NATIVE_NAME, country.NativeName);
31+
Assert.Equal(DJIBOUTI_CAPITAL, country.Capital);
32+
Assert.Equal(DJIBOUTI_NUMERIC_CODE, country.NumericCode);
33+
Assert.Equal(DJIBOUTI_ISO2_CODE, country.ISO2Code);
34+
Assert.Equal(DJIBOUTI_ISO3_CODE, country.ISO3Code);
35+
Assert.Equal(DJIBOUTI_CALLING_CODE, country.CallingCode);
36+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
37+
}
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace World.Net.UnitTests.Countries;
2+
public sealed class DominicaTest
3+
{
4+
private const string DOMINICA_NAME = "Dominica";
5+
private const int DOMINICA_STATE_COUNT = 10;
6+
private const string DOMINICA_OFFICIAL_NAME = "Commonwealth of Dominica";
7+
private const string DOMINICA_NATIVE_NAME = "Dominica";
8+
private const string DOMINICA_CAPITAL = "Roseau";
9+
private const int DOMINICA_NUMERIC_CODE = 212;
10+
private const string DOMINICA_ISO2_CODE = "DM";
11+
private const string DOMINICA_ISO3_CODE = "DMA";
12+
private static readonly string[] VALID_STATE_TYPES = { "Parish" };
13+
private readonly string[] DOMINICA_CALLING_CODE = ["+1-767"];
14+
15+
[Fact]
16+
public void GetCountry_ReturnsCorrectInformation_ForDominica()
17+
{
18+
// Arrange
19+
CountryIdentifier existingCountryId = CountryIdentifier.Dominica;
20+
21+
// Act
22+
var country = CountryProvider.GetCountry(existingCountryId);
23+
24+
//Assert
25+
Assert.Equal(existingCountryId, country.Id);
26+
Assert.Equal(DOMINICA_NAME, country.Name);
27+
Assert.NotNull(country.States);
28+
Assert.Equal(DOMINICA_STATE_COUNT, country.States.Count());
29+
Assert.Equal(DOMINICA_OFFICIAL_NAME, country.OfficialName);
30+
Assert.Equal(DOMINICA_NATIVE_NAME, country.NativeName);
31+
Assert.Equal(DOMINICA_CAPITAL, country.Capital);
32+
Assert.Equal(DOMINICA_NUMERIC_CODE, country.NumericCode);
33+
Assert.Equal(DOMINICA_ISO2_CODE, country.ISO2Code);
34+
Assert.Equal(DOMINICA_ISO3_CODE, country.ISO3Code);
35+
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
36+
Assert.Equal(DOMINICA_CALLING_CODE, country.CallingCode);
37+
}
38+
}

src/World.Net/Countries/Denmark.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace World.Net.Countries;
2+
internal sealed class Denmark : ICountry
3+
{
4+
///<inheritdoc/>
5+
public CountryIdentifier Id => CountryIdentifier.Denmark;
6+
7+
///<inheritdoc/>
8+
public string Name => nameof(Denmark);
9+
10+
///<inheritdoc/>
11+
public string OfficialName { get; } = "Kingdom of Denmark";
12+
13+
///<inheritdoc/>
14+
public string NativeName { get; } = "Danmark";
15+
16+
///<inheritdoc/>
17+
public string Capital { get; } = "Copenhagen";
18+
19+
///<inheritdoc/>
20+
public int NumericCode { get; } = 208;
21+
22+
///<inheritdoc/>
23+
public string ISO2Code { get; } = "DK";
24+
25+
///<inheritdoc/>
26+
public string ISO3Code { get; } = "DNK";
27+
28+
///<inheritdoc/>
29+
public string[] CallingCode { get; } = ["+45"];
30+
31+
///<inheritdoc/>
32+
public IEnumerable<State> States { get; } =
33+
[
34+
new("Central Denmark", "DK-82", "Region"),
35+
new("Capital Region of Denmark", "DK-84", "Region"),
36+
new("North Denmark", "DK-81", "Region"),
37+
new("Southern Denmark", "DK-83", "Region"),
38+
new("Zealand", "DK-85", "Region"),
39+
];
40+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace World.Net.Countries;
2+
internal sealed class Djibouti : ICountry
3+
{
4+
///<inheritdoc/>
5+
public CountryIdentifier Id => CountryIdentifier.Djibouti;
6+
7+
///<inheritdoc/>
8+
public string Name => nameof(Djibouti);
9+
10+
///<inheritdoc/>
11+
public string OfficialName { get; } = "Republic of Djibouti";
12+
13+
///<inheritdoc/>
14+
public string NativeName { get; } = "Djibouti";
15+
16+
///<inheritdoc/>
17+
public string Capital { get; } = "Djibouti";
18+
19+
///<inheritdoc/>
20+
public int NumericCode { get; } = 262;
21+
22+
///<inheritdoc/>
23+
public string ISO2Code { get; } = "DJ";
24+
25+
///<inheritdoc/>
26+
public string ISO3Code { get; } = "DJI";
27+
28+
///<inheritdoc/>
29+
public string[] CallingCode { get; } = ["+253"];
30+
31+
///<inheritdoc/>
32+
public IEnumerable<State> States { get; } =
33+
[
34+
new("Ali Sabieh", "DJ-AS", "Region"),
35+
new("Arta", "DJ-AR", "Region"),
36+
new("Dikhil", "DJ-DI", "Region"),
37+
new("Djibouti", "DJ-DJ", "City"),
38+
new("Obock", "DJ-OB", "Region"),
39+
new("Tadjourah", "DJ-TA", "Region"),
40+
];
41+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
namespace World.Net.Countries;
2+
internal sealed class Dominica : ICountry
3+
{
4+
///<inheritdoc/>
5+
public CountryIdentifier Id => CountryIdentifier.Dominica;
6+
7+
///<inheritdoc/>
8+
public string Name => nameof(Dominica);
9+
10+
///<inheritdoc/>
11+
public string OfficialName { get; } = "Commonwealth of Dominica";
12+
13+
///<inheritdoc/>
14+
public string NativeName { get; } = "Dominica";
15+
16+
///<inheritdoc/>
17+
public string Capital { get; } = "Roseau";
18+
19+
///<inheritdoc/>
20+
public int NumericCode { get; } = 212;
21+
22+
///<inheritdoc/>
23+
public string ISO2Code { get; } = "DM";
24+
25+
///<inheritdoc/>
26+
public string ISO3Code { get; } = "DMA";
27+
28+
///<inheritdoc/>
29+
public string[] CallingCode { get; } = ["+1-767"];
30+
31+
///<inheritdoc/>
32+
public IEnumerable<State> States { get; } =
33+
[
34+
new("Saint Andrew", "DM-02", "Parish"),
35+
new("Saint David", "DM-03", "Parish"),
36+
new("Saint George", "DM-04", "Parish"),
37+
new("Saint John", "DM-05", "Parish"),
38+
new("Saint Joseph", "DM-06", "Parish"),
39+
new("Saint Luke", "DM-07", "Parish"),
40+
new("Saint Mark", "DM-08", "Parish"),
41+
new("Saint Patrick", "DM-09", "Parish"),
42+
new("Saint Paul", "DM-10", "Parish"),
43+
new("Saint Peter", "DM-11", "Parish"),
44+
];
45+
}

src/World.Net/Helpers/CountryInitializer.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
4545
{ CountryIdentifier.Cambodia, new Cambodia() },
4646
{ CountryIdentifier.Cameroon, new Cameroon() },
4747
{ CountryIdentifier.Canada, new Canada() },
48-
{ CountryIdentifier.CapeVerde, new CapeVerde() },
49-
{ CountryIdentifier.CaymanIslands, new CaymanIslands() },
50-
{ CountryIdentifier.CentralAfricanRepublic, new CentralAfricanRepublic() },
51-
{ CountryIdentifier.Chad, new Chad() },
52-
{ CountryIdentifier.Chile, new Chile() },
53-
{ CountryIdentifier.China, new China() },
48+
{ CountryIdentifier.CapeVerde, new CapeVerde() },
49+
{ CountryIdentifier.CaymanIslands, new CaymanIslands() },
50+
{ CountryIdentifier.CentralAfricanRepublic, new CentralAfricanRepublic() },
51+
{ CountryIdentifier.Chad, new Chad() },
52+
{ CountryIdentifier.Chile, new Chile() },
53+
{ CountryIdentifier.China, new China() },
5454
{ CountryIdentifier.ChristmasIsland, new ChristmasIsland() },
5555
{ CountryIdentifier.CocosKeelingIslands, new CocosKeelingIslands() },
5656
{ CountryIdentifier.Colombia, new Colombia() },
@@ -68,6 +68,9 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
6868
{ CountryIdentifier.TimorLeste, new TimorLeste() },
6969
{ CountryIdentifier.Ecuador, new Ecuador() },
7070
{ CountryIdentifier.Egypt, new Egypt() },
71+
{ CountryIdentifier.Denmark, new Denmark() },
72+
{ CountryIdentifier.Djibouti, new Djibouti() },
73+
{ CountryIdentifier.Dominica, new Dominica() },
7174

7275
// Future countries can be added here in the same format.
7376
};

0 commit comments

Comments
 (0)