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
39 changes: 39 additions & 0 deletions src/World.Net.UnitTests/Countries/ChristmasIslandTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace World.Net.UnitTests.Countries;

public sealed class ChristmasIslandTest
{
private const string CHRISTMAS_ISLAND_COUNTRY_NAME = "Christmas Island";
private const string CHRISTMAS_ISLAND_NATIVE_NAME = "Christmas Island";
private const string CHRISTMAS_ISLAND_CAPITAL = "Flying Fish Cove";
private const string CHRISTMAS_ISLAND_OFFICIAL_NAME = "Territory of Christmas Island";
private const string CHRISTMAS_ISLAND_ISO2_CODE = "CX";
private const string CHRISTMAS_ISLAND_ISO3_CODE = "CXR";
private const int CHRISTMAS_ISLAND_NUMERIC_CODE = 162;
private const string CHRISTMAS_ISLAND_CALLING_CODE = "+61";
private static readonly string[] VALID_STATE_TYPES = { };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForChristmasIsland()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.ChristmasIsland;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(CHRISTMAS_ISLAND_COUNTRY_NAME, country.Name);
Assert.Equal(CHRISTMAS_ISLAND_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(CHRISTMAS_ISLAND_NATIVE_NAME, country.NativeName);
Assert.Equal(CHRISTMAS_ISLAND_CAPITAL, country.Capital);
Assert.Equal(CHRISTMAS_ISLAND_NUMERIC_CODE, country.NumericCode);
Assert.Equal(CHRISTMAS_ISLAND_ISO2_CODE, country.ISO2Code);
Assert.Equal(CHRISTMAS_ISLAND_ISO3_CODE, country.ISO3Code);
Assert.Equal(CHRISTMAS_ISLAND_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Empty(country.States);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
40 changes: 40 additions & 0 deletions src/World.Net.UnitTests/Countries/CocosKeelingIslandsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace World.Net.UnitTests.Countries;

public sealed class CocosKeelingIslandsTest
{
private const string COCOS_COUNTRY_NAME = "Cocos (Keeling) Islands";
private const string COCOS_NATIVE_NAME = "Pulu Kokos (Malay)";
private const string COCOS_CAPITAL = "West Island";
private const string COCOS_OFFICIAL_NAME = "Territory of Cocos (Keeling) Islands";
private const string COCOS_ISO2_CODE = "CC";
private const string COCOS_ISO3_CODE = "CCK";
private const int COCOS_NUMERIC_CODE = 166;
private const string COCOS_CALLING_CODE = "+61";
private const int COCOS_STATE_COUNT = 2;
private static readonly string[] VALID_STATE_TYPES = { "Island" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForCocosKeelingIslands()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.CocosKeelingIslands;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(COCOS_COUNTRY_NAME, country.Name);
Assert.Equal(COCOS_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(COCOS_NATIVE_NAME, country.NativeName);
Assert.Equal(COCOS_CAPITAL, country.Capital);
Assert.Equal(COCOS_NUMERIC_CODE, country.NumericCode);
Assert.Equal(COCOS_ISO2_CODE, country.ISO2Code);
Assert.Equal(COCOS_ISO3_CODE, country.ISO3Code);
Assert.Equal(COCOS_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Equal(COCOS_STATE_COUNT, country.States.Count());
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
40 changes: 40 additions & 0 deletions src/World.Net.UnitTests/Countries/ColombiaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace World.Net.UnitTests.Countries;

public sealed class ColombiaTest
{
private const string COLOMBIA_COUNTRY_NAME = "Colombia";
private const string COLOMBIA_NATIVE_NAME = "Colombia";
private const string COLOMBIA_CAPITAL = "Bogotá";
private const string COLOMBIA_OFFICIAL_NAME = "Republic of Colombia";
private const string COLOMBIA_ISO2_CODE = "CO";
private const string COLOMBIA_ISO3_CODE = "COL";
private const int COLOMBIA_NUMERIC_CODE = 170;
private const string COLOMBIA_CALLING_CODE = "+57";
private const int COLOMBIA_STATE_COUNT = 32;
private static readonly string[] VALID_STATE_TYPES = { "Department", "Capital District" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForColombia()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Colombia;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(COLOMBIA_COUNTRY_NAME, country.Name);
Assert.Equal(COLOMBIA_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(COLOMBIA_NATIVE_NAME, country.NativeName);
Assert.Equal(COLOMBIA_CAPITAL, country.Capital);
Assert.Equal(COLOMBIA_NUMERIC_CODE, country.NumericCode);
Assert.Equal(COLOMBIA_ISO2_CODE, country.ISO2Code);
Assert.Equal(COLOMBIA_ISO3_CODE, country.ISO3Code);
Assert.Equal(COLOMBIA_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Equal(COLOMBIA_STATE_COUNT, country.States.Count());
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
40 changes: 40 additions & 0 deletions src/World.Net.UnitTests/Countries/ComorosTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace World.Net.UnitTests.Countries;

public sealed class ComorosTest
{
private const string COMOROS_COUNTRY_NAME = "Comoros";
private const string COMOROS_NATIVE_NAME = "Komori";
private const string COMOROS_CAPITAL = "Moroni";
private const string COMOROS_OFFICIAL_NAME = "Union of the Comoros";
private const string COMOROS_ISO2_CODE = "KM";
private const string COMOROS_ISO3_CODE = "COM";
private const int COMOROS_NUMERIC_CODE = 174;
private const string COMOROS_CALLING_CODE = "+269";
private const int COMOROS_STATE_COUNT = 3;
private static readonly string[] VALID_STATE_TYPES = { "Autonomous Island" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForComoros()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Comoros;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(COMOROS_COUNTRY_NAME, country.Name);
Assert.Equal(COMOROS_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(COMOROS_NATIVE_NAME, country.NativeName);
Assert.Equal(COMOROS_CAPITAL, country.Capital);
Assert.Equal(COMOROS_NUMERIC_CODE, country.NumericCode);
Assert.Equal(COMOROS_ISO2_CODE, country.ISO2Code);
Assert.Equal(COMOROS_ISO3_CODE, country.ISO3Code);
Assert.Equal(COMOROS_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Equal(COMOROS_STATE_COUNT, country.States.Count());
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
37 changes: 37 additions & 0 deletions src/World.Net/Countries/ChristmasIsland.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace World.Net.Countries;

internal sealed class ChristmasIsland : ICountry
{
//<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.ChristmasIsland;

//<inheritdoc/>
public string Name { get; } = "Christmas Island";

//<inheritdoc/>
public string OfficialName { get; } = "Territory of Christmas Island";

//<inheritdoc/>
public string NativeName => "Christmas Island";

//<inheritdoc/>
public string Capital { get; } = "Flying Fish Cove";

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

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

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

//<inheritdoc/>
public string CallingCode { get; } = "+61";

//<inheritdoc/>
public IEnumerable<State> States =>
[

];
}
38 changes: 38 additions & 0 deletions src/World.Net/Countries/CocosKeelingIslands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace World.Net.Countries;

internal sealed class CocosKeelingIslands : ICountry
{
//<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.CocosKeelingIslands;

//<inheritdoc/>
public string Name { get; } = "Cocos (Keeling) Islands";

//<inheritdoc/>
public string OfficialName { get; } = "Territory of Cocos (Keeling) Islands";

//<inheritdoc/>
public string NativeName => "Pulu Kokos (Malay)";

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

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

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

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

//<inheritdoc/>
public string CallingCode { get; } = "+61";

//<inheritdoc/>
public IEnumerable<State> States =>
[
new("West Island", "CC-WI", "Island"),
new("Home Island", "CC-HI", "Island")
];
}
68 changes: 68 additions & 0 deletions src/World.Net/Countries/Colombia.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace World.Net.Countries;

internal sealed class Colombia : ICountry
{
//<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.Colombia;

//<inheritdoc/>
public string Name { get; } = "Colombia";

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

//<inheritdoc/>
public string NativeName => "Colombia";

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

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

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

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

//<inheritdoc/>
public string CallingCode { get; } = "+57";

//<inheritdoc/>
public IEnumerable<State> States =>
[
new("Amazonas", "CO-AMA", "Department"),
new("Antioquia", "CO-ANT", "Department"),
new("Arauca", "CO-ARA", "Department"),
new("Atlántico", "CO-ATL", "Department"),
new("Bolívar", "CO-BOL", "Department"),
new("Boyacá", "CO-BOY", "Department"),
new("Caldas", "CO-CAL", "Department"),
new("Caquetá", "CO-CAQ", "Department"),
new("Casanare", "CO-CAS", "Department"),
new("Cauca", "CO-CAU", "Department"),
new("Cesar", "CO-CES", "Department"),
new("Chocó", "CO-CHO", "Department"),
new("Córdoba", "CO-COR", "Department"),
new("Cundinamarca", "CO-CUN", "Department"),
new("Guainía", "CO-GUA", "Department"),
new("Guaviare", "CO-GUV", "Department"),
new("Huila", "CO-HUI", "Department"),
new("La Guajira", "CO-LAG", "Department"),
new("Magdalena", "CO-MAG", "Department"),
new("Meta", "CO-MET", "Department"),
new("Nariño", "CO-NAR", "Department"),
new("Norte de Santander", "CO-NSA", "Department"),
new("Putumayo", "CO-PUT", "Department"),
new("Quindío", "CO-QUI", "Department"),
new("Risaralda", "CO-RIS", "Department"),
new("San Andrés, Providencia and Santa Catalina", "CO-SAP", "Department"),
new("Santander", "CO-SAN", "Department"),
new("Sucre", "CO-SUC", "Department"),
new("Tolima", "CO-TOL", "Department"),
new("Valle del Cauca", "CO-VAC", "Department"),
new("Vaupés", "CO-VAU", "Department"),
new("Vichada", "CO-VIC", "Department")
];
}
39 changes: 39 additions & 0 deletions src/World.Net/Countries/Comoros.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace World.Net.Countries;

internal sealed class Comoros : ICountry
{
//<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.Comoros;

//<inheritdoc/>
public string Name { get; } = "Comoros";

//<inheritdoc/>
public string OfficialName { get; } = "Union of the Comoros";

//<inheritdoc/>
public string NativeName => "Komori";

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

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

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

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

//<inheritdoc/>
public string CallingCode { get; } = "+269";

//<inheritdoc/>
public IEnumerable<State> States =>
[
new("Anjouan", "KM-A", "Autonomous Island"),
new("Grande Comore", "KM-G", "Autonomous Island"),
new("Mohéli", "KM-M", "Autonomous Island")
];
}
6 changes: 5 additions & 1 deletion src/World.Net/Helpers/CountryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
{ CountryIdentifier.Cambodia, new Cambodia() },
{ CountryIdentifier.Cameroon, new Cameroon() },
{ CountryIdentifier.Canada, new Canada() },
{ CountryIdentifier.CapeVerde, new CapeVerde() },
{ CountryIdentifier.CapeVerde, new CapeVerde() },
{ CountryIdentifier.ChristmasIsland, new ChristmasIsland() },
{ CountryIdentifier.CocosKeelingIslands, new CocosKeelingIslands() },
{ CountryIdentifier.Colombia, new Colombia() },
{ CountryIdentifier.Comoros, new Comoros() },

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