Skip to content
Merged
40 changes: 40 additions & 0 deletions src/World.Net.UnitTests/Countries/ElSalvadorTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace World.Net.UnitTests.Countries
{
public sealed class ElSalvadorTest
{
private const string ELSALVADOR_NAME = "ElSalvador";
private const int ELSALVADOR_STATE_COUNT = 14;
private const string ELSALVADOR_OFFICIAL_NAME = "Republic of El Salvador";
private const string ELSALVADOR_NATIVE_NAME = "República de El Salvador";
private const string ELSALVADOR_CAPITAL = "San Salvador";
private const int ELSALVADOR_NUMERIC_CODE = 222;
private const string ELSALVADOR_ISO2_CODE = "SV";
private const string ELSALVADOR_ISO3_CODE = "SLV";
private readonly string[] ELSALVADOR_CALLING_CODE = ["503"];
private static readonly string[] VALID_STATE_TYPES = { "Department" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForElSalvador()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.ElSalvador;

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

// Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(ELSALVADOR_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(ELSALVADOR_STATE_COUNT, country.States.Count());
Assert.Equal(ELSALVADOR_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(ELSALVADOR_NATIVE_NAME, country.NativeName);
Assert.Equal(ELSALVADOR_CAPITAL, country.Capital);
Assert.Equal(ELSALVADOR_NUMERIC_CODE, country.NumericCode);
Assert.Equal(ELSALVADOR_ISO2_CODE, country.ISO2Code);
Assert.Equal(ELSALVADOR_ISO3_CODE, country.ISO3Code);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(ELSALVADOR_CALLING_CODE, country.CallingCode);
}
}
}
41 changes: 41 additions & 0 deletions src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace World.Net.UnitTests.Countries
{
public class EquatorialGuineaTest
{
private const string EQUATORIALGUINEA_NAME = "EquatorialGuinea";
private const int EQUATORIALGUINEA_STATE_COUNT = 8;
private const string EQUATORIALGUINEA_OFFICIAL_NAME = "Republic of Equatorial Guinea";
private const string EQUATORIALGUINEA_NATIVE_NAME = "República de Guinea Ecuatorial";
private const string EQUATORIALGUINEA_CAPITAL = "Malabo";
private const int EQUATORIALGUINEA_NUMERIC_CODE = 226;
private const string EQUATORIALGUINEA_ISO2_CODE = "GQ";
private const string EQUATORIALGUINEA_ISO3_CODE = "GNQ";
private readonly string[] EQUATORIALGUINEA_CALLING_CODE = ["240"];
private static readonly string[] VALID_STATE_TYPES = { "Province" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForEquatorialGuinea()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.EquatorialGuinea;

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

// Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(EQUATORIALGUINEA_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(EQUATORIALGUINEA_STATE_COUNT, country.States.Count());
Assert.Equal(EQUATORIALGUINEA_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(EQUATORIALGUINEA_NATIVE_NAME, country.NativeName);
Assert.Equal(EQUATORIALGUINEA_CAPITAL, country.Capital);
Assert.Equal(EQUATORIALGUINEA_NUMERIC_CODE, country.NumericCode);
Assert.Equal(EQUATORIALGUINEA_ISO2_CODE, country.ISO2Code);
Assert.Equal(EQUATORIALGUINEA_ISO3_CODE, country.ISO3Code);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(EQUATORIALGUINEA_CALLING_CODE, country.CallingCode);
}

}
}
46 changes: 46 additions & 0 deletions src/World.Net.UnitTests/Countries/EritreaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace World.Net.UnitTests.Countries
{
public class EritreaTest
{
private const string ERITREA_NAME = "Eritrea";
private const int ERITREA_STATE_COUNT = 6;
private const string ERITREA_OFFICIAL_NAME = "State of Eritrea";
private const string ERITREA_NATIVE_NAME = "ሃገረ ኤርትራ";
private const string ERITREA_CAPITAL = "Asmara";
private const int ERITREA_NUMERIC_CODE = 232;
private const string ERITREA_ISO2_CODE = "ER";
private const string ERITREA_ISO3_CODE = "ERI";
private readonly string[] ERITREA_CALLING_CODE = ["291"];
private static readonly string[] VALID_STATE_TYPES = { "Region" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForEritrea()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Eritrea;

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

// Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(ERITREA_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(ERITREA_STATE_COUNT, country.States.Count());
Assert.Equal(ERITREA_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(ERITREA_NATIVE_NAME, country.NativeName);
Assert.Equal(ERITREA_CAPITAL, country.Capital);
Assert.Equal(ERITREA_NUMERIC_CODE, country.NumericCode);
Assert.Equal(ERITREA_ISO2_CODE, country.ISO2Code);
Assert.Equal(ERITREA_ISO3_CODE, country.ISO3Code);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(ERITREA_CALLING_CODE, country.CallingCode);
}
}
}
41 changes: 41 additions & 0 deletions src/World.Net/Countries/ElSalvador.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace World.Net.Countries
{
internal class ElSalvador : ICountry
{
public CountryIdentifier Id => CountryIdentifier.ElSalvador;

public string Name => nameof(ElSalvador);

public string OfficialName => "Republic of El Salvador";

public string NativeName => "República de El Salvador";

public string Capital => "San Salvador";

public int NumericCode => 222;

public string ISO2Code => "SV";

public string ISO3Code => "SLV";

public string[] CallingCode => ["503"];

public IEnumerable<State> States =>
[
new("Ahuachapán", "AH", "Department"),
new("Cabañas", "CA", "Department"),
new("Chalatenango", "CH", "Department"),
new("Cuscatlán", "CU", "Department"),
new("La Libertad", "LI", "Department"),
new("La Paz", "PA", "Department"),
new("La Unión", "UN", "Department"),
new("Morazán", "MO", "Department"),
new("San Miguel", "SM", "Department"),
new("San Salvador", "SS", "Department"),
new("San Vicente", "SV", "Department"),
new("Santa Ana", "SA", "Department"),
new("Sonsonate", "SO", "Department"),
new("Usulután", "US", "Department")
];
}
}
36 changes: 36 additions & 0 deletions src/World.Net/Countries/EquatorialGuinea.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace World.Net.Countries
{
internal sealed class EquatorialGuinea : ICountry
{
public CountryIdentifier Id => CountryIdentifier.EquatorialGuinea;

public string Name => nameof(EquatorialGuinea);

public string OfficialName => "Republic of Equatorial Guinea";

public string NativeName => "República de Guinea Ecuatorial";

public string Capital => "Malabo";

public int NumericCode => 226;

public string ISO2Code => "GQ";

public string ISO3Code => "GNQ";

public string[] CallingCode => new[] { "240" };

public IEnumerable<State> States =>
[
new("Annobón", "AN", "Province"),
new("Bioko Norte", "BN", "Province"),
new("Bioko Sur", "BS", "Province"),
new("Centro Sur", "CS", "Province"),
new("Djibloho", "DJ", "Province"),
new("Kié-Ntem", "KN", "Province"),
new("Litoral", "LI", "Province"),
new("Wele-Nzas", "WN", "Province")
];
}

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

public string Name => nameof(Eritrea);

public string OfficialName => "State of Eritrea";

public string NativeName => "ሃገረ ኤርትራ"; // Tigrinya: Hagere Ertra

public string Capital => "Asmara";

public int NumericCode => 232;

public string ISO2Code => "ER";

public string ISO3Code => "ERI";

public string[] CallingCode => ["291"];

public IEnumerable<State> States =>
[
new("Anseba", "AN", "Region"),
new("Debub", "DU", "Region"),
new("Debubawi Keyih Bahri", "DK", "Region"),
new("Gash-Barka", "GB", "Region"),
new("Maekel", "MA", "Region"),
new("Semenawi Keyih Bahri", "SK", "Region")
];
}

}
3 changes: 3 additions & 0 deletions src/World.Net/Helpers/CountryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
{ CountryIdentifier.TimorLeste, new TimorLeste() },
{ CountryIdentifier.Ecuador, new Ecuador() },
{ CountryIdentifier.Egypt, new Egypt() },
{ CountryIdentifier.ElSalvador, new ElSalvador() },
{ CountryIdentifier.EquatorialGuinea, new EquatorialGuinea() },
{ CountryIdentifier.Eritrea, new Eritrea() },
{ CountryIdentifier.Estonia, new Estonia() },
{ CountryIdentifier.Ethiopia, new Ethiopia() },
{ CountryIdentifier.Eswatini, new Eswatini() },
Expand Down