Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/World.Net.UnitTests/Countries/DenmarkTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace World.Net.UnitTests.Countries;
public sealed class DenmarkTest
{
private const string DENMARK_NAME = "Denmark";
private const int DENMARK_STATE_COUNT = 5;
private const string DENMARK_OFFICIAL_NAME = "Kingdom of Denmark";
private const string DENMARK_NATIVE_NAME = "Danmark";
private const string DENMARK_CAPITAL = "Copenhagen";
private const int DENMARK_NUMERIC_CODE = 208;
private const string DENMARK_ISO2_CODE = "DK";
private const string DENMARK_ISO3_CODE = "DNK";
private readonly string[] DENMARK_CALLING_CODE = ["+45"];
private static readonly string[] VALID_STATE_TYPES = { "Region" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForDenmark()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Denmark;

// Act
var country = CountryProvider.GetCountry(existingCountryId);

//Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(DENMARK_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(DENMARK_STATE_COUNT, country.States.Count());
Assert.Equal(DENMARK_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(DENMARK_NATIVE_NAME, country.NativeName);
Assert.Equal(DENMARK_CAPITAL, country.Capital);
Assert.Equal(DENMARK_NUMERIC_CODE, country.NumericCode);
Assert.Equal(DENMARK_ISO2_CODE, country.ISO2Code);
Assert.Equal(DENMARK_ISO3_CODE, country.ISO3Code);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(DENMARK_CALLING_CODE, country.CallingCode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No state type test

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

}
}
38 changes: 38 additions & 0 deletions src/World.Net.UnitTests/Countries/DjiboutiTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace World.Net.UnitTests.Countries;
public sealed class DjiboutiTest
{
private const string DJIBOUTI_NAME = "Djibouti";
private const int DJIBOUTI_STATE_COUNT = 6;
private const string DJIBOUTI_OFFICIAL_NAME = "Republic of Djibouti";
private const string DJIBOUTI_NATIVE_NAME = "Djibouti";
private const string DJIBOUTI_CAPITAL = "Djibouti";
private const int DJIBOUTI_NUMERIC_CODE = 262;
private const string DJIBOUTI_ISO2_CODE = "DJ";
private const string DJIBOUTI_ISO3_CODE = "DJI";
private static readonly string[] VALID_STATE_TYPES = { "Region", "City" };
private readonly string[] DJIBOUTI_CALLING_CODE = ["+253"];

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No state type test

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForDjibouti()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Djibouti;

// Act
var country = CountryProvider.GetCountry(existingCountryId);

//Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(DJIBOUTI_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(DJIBOUTI_STATE_COUNT, country.States.Count());
Assert.Equal(DJIBOUTI_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(DJIBOUTI_NATIVE_NAME, country.NativeName);
Assert.Equal(DJIBOUTI_CAPITAL, country.Capital);
Assert.Equal(DJIBOUTI_NUMERIC_CODE, country.NumericCode);
Assert.Equal(DJIBOUTI_ISO2_CODE, country.ISO2Code);
Assert.Equal(DJIBOUTI_ISO3_CODE, country.ISO3Code);
Assert.Equal(DJIBOUTI_CALLING_CODE, country.CallingCode);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
38 changes: 38 additions & 0 deletions src/World.Net.UnitTests/Countries/DominicaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace World.Net.UnitTests.Countries;
public sealed class DominicaTest
{
private const string DOMINICA_NAME = "Dominica";
private const int DOMINICA_STATE_COUNT = 10;
private const string DOMINICA_OFFICIAL_NAME = "Commonwealth of Dominica";
private const string DOMINICA_NATIVE_NAME = "Dominica";
private const string DOMINICA_CAPITAL = "Roseau";
private const int DOMINICA_NUMERIC_CODE = 212;
private const string DOMINICA_ISO2_CODE = "DM";
private const string DOMINICA_ISO3_CODE = "DMA";
private static readonly string[] VALID_STATE_TYPES = { "Parish" };
private readonly string[] DOMINICA_CALLING_CODE = ["+1-767"];

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForDominica()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Dominica;

// Act
var country = CountryProvider.GetCountry(existingCountryId);

//Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(DOMINICA_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(DOMINICA_STATE_COUNT, country.States.Count());
Assert.Equal(DOMINICA_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(DOMINICA_NATIVE_NAME, country.NativeName);
Assert.Equal(DOMINICA_CAPITAL, country.Capital);
Assert.Equal(DOMINICA_NUMERIC_CODE, country.NumericCode);
Assert.Equal(DOMINICA_ISO2_CODE, country.ISO2Code);
Assert.Equal(DOMINICA_ISO3_CODE, country.ISO3Code);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(DOMINICA_CALLING_CODE, country.CallingCode);
}
}
40 changes: 40 additions & 0 deletions src/World.Net/Countries/Denmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace World.Net.Countries;
internal sealed class Denmark : ICountry
{
///<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.Denmark;

///<inheritdoc/>
public string Name => nameof(Denmark);

///<inheritdoc/>
public string OfficialName { get; } = "Kingdom of Denmark";

///<inheritdoc/>
public string NativeName { get; } = "Danmark";

///<inheritdoc/>
public string Capital { get; } = "Copenhagen";

///<inheritdoc/>
public int NumericCode { get; } = 208;

///<inheritdoc/>
public string ISO2Code { get; } = "DK";

///<inheritdoc/>
public string ISO3Code { get; } = "DNK";

///<inheritdoc/>
public string[] CallingCode { get; } = ["+45"];

///<inheritdoc/>
public IEnumerable<State> States { get; } =
[
new("Central Denmark", "DK-82", "Region"),
new("Capital Region of Denmark", "DK-84", "Region"),
new("North Denmark", "DK-81", "Region"),
new("Southern Denmark", "DK-83", "Region"),
new("Zealand", "DK-85", "Region"),
];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public IEnumerable States { get; } =
[
new("Central Denmark", "DK-82", "Region"),
new("Capital Region of Denmark", "DK-84", "Region"),
new("North Denmark", "DK-81", "Region"),
new("Southern Denmark", "DK-83", "Region"),
new("Zealand", "DK-85", "Region"),
];

Denmark isn't part of the list

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

}
41 changes: 41 additions & 0 deletions src/World.Net/Countries/Djibouti.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace World.Net.Countries;
internal sealed class Djibouti : ICountry
{
///<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.Djibouti;

///<inheritdoc/>
public string Name => nameof(Djibouti);

///<inheritdoc/>
public string OfficialName { get; } = "Republic of Djibouti";

///<inheritdoc/>
public string NativeName { get; } = "Djibouti";

///<inheritdoc/>
public string Capital { get; } = "Djibouti";

///<inheritdoc/>
public int NumericCode { get; } = 262;

///<inheritdoc/>
public string ISO2Code { get; } = "DJ";

///<inheritdoc/>
public string ISO3Code { get; } = "DJI";

///<inheritdoc/>
public string[] CallingCode { get; } = ["+253"];

///<inheritdoc/>
public IEnumerable<State> States { get; } =
[
new("Ali Sabieh", "DJ-AS", "Region"),
new("Arta", "DJ-AR", "Region"),
new("Dikhil", "DJ-DI", "Region"),
new("Djibouti", "DJ-DJ", "City"),
new("Obock", "DJ-OB", "Region"),
new("Tadjourah", "DJ-TA", "Region"),
];
}
45 changes: 45 additions & 0 deletions src/World.Net/Countries/Dominica.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace World.Net.Countries;
internal sealed class Dominica : ICountry
{
///<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.Dominica;

///<inheritdoc/>
public string Name => nameof(Dominica);

///<inheritdoc/>
public string OfficialName { get; } = "Commonwealth of Dominica";

///<inheritdoc/>
public string NativeName { get; } = "Dominica";

///<inheritdoc/>
public string Capital { get; } = "Roseau";

///<inheritdoc/>
public int NumericCode { get; } = 212;

///<inheritdoc/>
public string ISO2Code { get; } = "DM";

///<inheritdoc/>
public string ISO3Code { get; } = "DMA";

///<inheritdoc/>
public string[] CallingCode { get; } = ["+1-767"];

///<inheritdoc/>
public IEnumerable<State> States { get; } =
[
new("Saint Andrew", "DM-02", "Parish"),
new("Saint David", "DM-03", "Parish"),
new("Saint George", "DM-04", "Parish"),
new("Saint John", "DM-05", "Parish"),
new("Saint Joseph", "DM-06", "Parish"),
new("Saint Luke", "DM-07", "Parish"),
new("Saint Mark", "DM-08", "Parish"),
new("Saint Patrick", "DM-09", "Parish"),
new("Saint Paul", "DM-10", "Parish"),
new("Saint Peter", "DM-11", "Parish"),
];
}
15 changes: 9 additions & 6 deletions src/World.Net/Helpers/CountryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
{ CountryIdentifier.Cambodia, new Cambodia() },
{ CountryIdentifier.Cameroon, new Cameroon() },
{ CountryIdentifier.Canada, new Canada() },
{ CountryIdentifier.CapeVerde, new CapeVerde() },
{ CountryIdentifier.CaymanIslands, new CaymanIslands() },
{ CountryIdentifier.CentralAfricanRepublic, new CentralAfricanRepublic() },
{ CountryIdentifier.Chad, new Chad() },
{ CountryIdentifier.Chile, new Chile() },
{ CountryIdentifier.China, new China() },
{ CountryIdentifier.CapeVerde, new CapeVerde() },
{ CountryIdentifier.CaymanIslands, new CaymanIslands() },
{ CountryIdentifier.CentralAfricanRepublic, new CentralAfricanRepublic() },
{ CountryIdentifier.Chad, new Chad() },
{ CountryIdentifier.Chile, new Chile() },
{ CountryIdentifier.China, new China() },
{ CountryIdentifier.ChristmasIsland, new ChristmasIsland() },
{ CountryIdentifier.CocosKeelingIslands, new CocosKeelingIslands() },
{ CountryIdentifier.Colombia, new Colombia() },
Expand All @@ -68,6 +68,9 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
{ CountryIdentifier.TimorLeste, new TimorLeste() },
{ CountryIdentifier.Ecuador, new Ecuador() },
{ CountryIdentifier.Egypt, new Egypt() },
{ CountryIdentifier.Denmark, new Denmark() },
{ CountryIdentifier.Djibouti, new Djibouti() },
{ CountryIdentifier.Dominica, new Dominica() },

// Future countries can be added here in the same format.
};
Expand Down