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
52 changes: 34 additions & 18 deletions src/World.Net.UnitTests/Countries/ElSalvadorTest.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,56 @@
namespace World.Net.UnitTests.Countries
{
public sealed class ElSalvadorTest
public sealed class ElSalvadorTest : AssertCountryTestBase
{
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" };
private static CountryIdentifier ExpectedId => CountryIdentifier.ElSalvador;
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
{
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")
};

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

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

// 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);

AssertCorrectInformation(
country,
ExpectedId,
ELSALVADOR_NAME,
ELSALVADOR_OFFICIAL_NAME,
ELSALVADOR_NATIVE_NAME,
ELSALVADOR_CAPITAL,
ELSALVADOR_NUMERIC_CODE,
ELSALVADOR_ISO2_CODE,
ELSALVADOR_ISO3_CODE,
ELSALVADOR_CALLING_CODE,
ExpectedStates
);
}
}
}
45 changes: 27 additions & 18 deletions src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
namespace World.Net.UnitTests.Countries
{
public class EquatorialGuineaTest
public class EquatorialGuineaTest : AssertCountryTestBase
{
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" };
private static CountryIdentifier ExpectedId => CountryIdentifier.EquatorialGuinea;
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
{
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")
};

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

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

// 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);
AssertCorrectInformation(
country,
ExpectedId,
EQUATORIALGUINEA_NAME,
EQUATORIALGUINEA_OFFICIAL_NAME,
EQUATORIALGUINEA_NATIVE_NAME,
EQUATORIALGUINEA_CAPITAL,
EQUATORIALGUINEA_NUMERIC_CODE,
EQUATORIALGUINEA_ISO2_CODE,
EQUATORIALGUINEA_ISO3_CODE,
EQUATORIALGUINEA_CALLING_CODE,
ExpectedStates
);
}

}
Expand Down
41 changes: 25 additions & 16 deletions src/World.Net.UnitTests/Countries/EritreaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace World.Net.UnitTests.Countries
{
public class EritreaTest
public class EritreaTest : AssertCountryTestBase
{
private const string ERITREA_NAME = "Eritrea";
private const int ERITREA_STATE_COUNT = 6;
Expand All @@ -18,29 +18,38 @@ public class EritreaTest
private const string ERITREA_ISO3_CODE = "ERI";
private readonly string[] ERITREA_CALLING_CODE = ["291"];
private static readonly string[] VALID_STATE_TYPES = { "Region" };
private static CountryIdentifier ExpectedId => CountryIdentifier.Eritrea;
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
{
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")
};

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

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

// 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);
AssertCorrectInformation(
country,
ExpectedId,
ERITREA_NAME,
ERITREA_OFFICIAL_NAME,
ERITREA_NATIVE_NAME,
ERITREA_CAPITAL,
ERITREA_NUMERIC_CODE,
ERITREA_ISO2_CODE,
ERITREA_ISO3_CODE,
ERITREA_CALLING_CODE,
ExpectedStates
);
}
}
}
51 changes: 34 additions & 17 deletions src/World.Net.UnitTests/Countries/EstoniaTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace World.Net.UnitTests.Countries
{
public sealed class EstoniaTest
public sealed class EstoniaTest : AssertCountryTestBase
{
private const string ESTONIA_NAME = "Estonia";
private const int ESTONIA_STATE_COUNT = 15;
Expand All @@ -11,30 +11,47 @@ public sealed class EstoniaTest
private const string ESTONIA_ISO2_CODE = "EE";
private const string ESTONIA_ISO3_CODE = "EST";
private readonly string[] ESTONIA_CALLING_CODE = ["372"];
private static readonly string[] VALID_STATE_TYPES = { "County" };
private static CountryIdentifier ExpectedId => CountryIdentifier.Estonia;
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
{
new("Harju", "37", "County"),
new("Hiiu", "39", "County"),
new("Ida-Viru", "44", "County"),
new("Jõgeva", "49", "County"),
new("Järva", "51", "County"),
new("Lääne", "57", "County"),
new("Lääne-Viru", "59", "County"),
new("Põlva", "65", "County"),
new("Pärnu", "67", "County"),
new("Rapla", "70", "County"),
new("Saare", "74", "County"),
new("Tartu", "78", "County"),
new("Valga", "82", "County"),
new("Viljandi", "84", "County"),
new("Võru", "86", "County")
};

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForEstonia()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Estonia;

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

// Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(ESTONIA_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(ESTONIA_STATE_COUNT, country.States.Count());
Assert.Equal(ESTONIA_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(ESTONIA_NATIVE_NAME, country.NativeName);
Assert.Equal(ESTONIA_CAPITAL, country.Capital);
Assert.Equal(ESTONIA_NUMERIC_CODE, country.NumericCode);
Assert.Equal(ESTONIA_ISO2_CODE, country.ISO2Code);
Assert.Equal(ESTONIA_ISO3_CODE, country.ISO3Code);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(ESTONIA_CALLING_CODE, country.CallingCode);
AssertCorrectInformation(
country,
ExpectedId,
ESTONIA_NAME,
ESTONIA_OFFICIAL_NAME,
ESTONIA_NATIVE_NAME,
ESTONIA_CAPITAL,
ESTONIA_NUMERIC_CODE,
ESTONIA_ISO2_CODE,
ESTONIA_ISO3_CODE,
ESTONIA_CALLING_CODE,
ExpectedStates
);
}
}
}
40 changes: 23 additions & 17 deletions src/World.Net.UnitTests/Countries/EswatiniTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
namespace World.Net.UnitTests.Countries
{
public class EswatiniTest
public class EswatiniTest : AssertCountryTestBase
{
private static CountryIdentifier ExpectedId => CountryIdentifier.Eswatini;
private const string ESWATINI_NAME = "Eswatini";
private const int ESWATINI_STATE_COUNT = 4;
private const string ESWATINI_OFFICIAL_NAME = "Kingdom of Eswatini";
Expand All @@ -11,30 +12,35 @@ public class EswatiniTest
private const string ESWATINI_ISO2_CODE = "SZ";
private const string ESWATINI_ISO3_CODE = "SWZ";
private readonly string[] ESWATINI_CALLING_CODE = ["268"];
private static readonly string[] VALID_STATE_TYPES = { "Region" };
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
{
new("Hhohho", "HH", "Region"),
new("Lubombo", "LU", "Region"),
new("Manzini", "MA", "Region"),
new("Shiselweni", "SH", "Region")
};

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForEswatini()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Eswatini;

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

// Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(ESWATINI_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(ESWATINI_STATE_COUNT, country.States.Count());
Assert.Equal(ESWATINI_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(ESWATINI_NATIVE_NAME, country.NativeName);
Assert.Equal(ESWATINI_CAPITAL, country.Capital);
Assert.Equal(ESWATINI_NUMERIC_CODE, country.NumericCode);
Assert.Equal(ESWATINI_ISO2_CODE, country.ISO2Code);
Assert.Equal(ESWATINI_ISO3_CODE, country.ISO3Code);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(ESWATINI_CALLING_CODE, country.CallingCode);
AssertCorrectInformation(
country,
ExpectedId,
ESWATINI_NAME,
ESWATINI_OFFICIAL_NAME,
ESWATINI_NATIVE_NAME,
ESWATINI_CAPITAL,
ESWATINI_NUMERIC_CODE,
ESWATINI_ISO2_CODE,
ESWATINI_ISO3_CODE,
ESWATINI_CALLING_CODE,
ExpectedStates
);
}
}
}
Loading
Loading