Skip to content

Commit 733f6f0

Browse files
authored
Merge pull request #102 from selfmadecode/feat/add-countries
update test cases
2 parents 4e8b6d0 + 10bf9e5 commit 733f6f0

20 files changed

+767
-373
lines changed
Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,56 @@
11
namespace World.Net.UnitTests.Countries
22
{
3-
public sealed class ElSalvadorTest
3+
public sealed class ElSalvadorTest : AssertCountryTestBase
44
{
55
private const string ELSALVADOR_NAME = "ElSalvador";
6-
private const int ELSALVADOR_STATE_COUNT = 14;
76
private const string ELSALVADOR_OFFICIAL_NAME = "Republic of El Salvador";
87
private const string ELSALVADOR_NATIVE_NAME = "República de El Salvador";
98
private const string ELSALVADOR_CAPITAL = "San Salvador";
109
private const int ELSALVADOR_NUMERIC_CODE = 222;
1110
private const string ELSALVADOR_ISO2_CODE = "SV";
1211
private const string ELSALVADOR_ISO3_CODE = "SLV";
1312
private readonly string[] ELSALVADOR_CALLING_CODE = ["503"];
14-
private static readonly string[] VALID_STATE_TYPES = { "Department" };
13+
private static CountryIdentifier ExpectedId => CountryIdentifier.ElSalvador;
14+
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
15+
{
16+
new("Ahuachapán", "AH", "Department"),
17+
new("Cabañas", "CA", "Department"),
18+
new("Chalatenango", "CH", "Department"),
19+
new("Cuscatlán", "CU", "Department"),
20+
new("La Libertad", "LI", "Department"),
21+
new("La Paz", "PA", "Department"),
22+
new("La Unión", "UN", "Department"),
23+
new("Morazán", "MO", "Department"),
24+
new("San Miguel", "SM", "Department"),
25+
new("San Salvador", "SS", "Department"),
26+
new("San Vicente", "SV", "Department"),
27+
new("Santa Ana", "SA", "Department"),
28+
new("Sonsonate", "SO", "Department"),
29+
new("Usulután", "US", "Department")
30+
};
1531

1632
[Fact]
1733
public void GetCountry_ReturnsCorrectInformation_ForElSalvador()
1834
{
1935
// Arrange
20-
CountryIdentifier existingCountryId = CountryIdentifier.ElSalvador;
21-
2236
// Act
23-
var country = CountryProvider.GetCountry(existingCountryId);
37+
var country = CountryProvider.GetCountry(ExpectedId);
2438

2539
// Assert
26-
Assert.Equal(existingCountryId, country.Id);
27-
Assert.Equal(ELSALVADOR_NAME, country.Name);
28-
Assert.NotNull(country.States);
29-
Assert.Equal(ELSALVADOR_STATE_COUNT, country.States.Count());
30-
Assert.Equal(ELSALVADOR_OFFICIAL_NAME, country.OfficialName);
31-
Assert.Equal(ELSALVADOR_NATIVE_NAME, country.NativeName);
32-
Assert.Equal(ELSALVADOR_CAPITAL, country.Capital);
33-
Assert.Equal(ELSALVADOR_NUMERIC_CODE, country.NumericCode);
34-
Assert.Equal(ELSALVADOR_ISO2_CODE, country.ISO2Code);
35-
Assert.Equal(ELSALVADOR_ISO3_CODE, country.ISO3Code);
36-
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
37-
Assert.Equal(ELSALVADOR_CALLING_CODE, country.CallingCode);
40+
41+
AssertCorrectInformation(
42+
country,
43+
ExpectedId,
44+
ELSALVADOR_NAME,
45+
ELSALVADOR_OFFICIAL_NAME,
46+
ELSALVADOR_NATIVE_NAME,
47+
ELSALVADOR_CAPITAL,
48+
ELSALVADOR_NUMERIC_CODE,
49+
ELSALVADOR_ISO2_CODE,
50+
ELSALVADOR_ISO3_CODE,
51+
ELSALVADOR_CALLING_CODE,
52+
ExpectedStates
53+
);
3854
}
3955
}
4056
}

src/World.Net.UnitTests/Countries/EquatorialGuineaTest.cs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
11
namespace World.Net.UnitTests.Countries
22
{
3-
public class EquatorialGuineaTest
3+
public class EquatorialGuineaTest : AssertCountryTestBase
44
{
55
private const string EQUATORIALGUINEA_NAME = "EquatorialGuinea";
6-
private const int EQUATORIALGUINEA_STATE_COUNT = 8;
76
private const string EQUATORIALGUINEA_OFFICIAL_NAME = "Republic of Equatorial Guinea";
87
private const string EQUATORIALGUINEA_NATIVE_NAME = "República de Guinea Ecuatorial";
98
private const string EQUATORIALGUINEA_CAPITAL = "Malabo";
109
private const int EQUATORIALGUINEA_NUMERIC_CODE = 226;
1110
private const string EQUATORIALGUINEA_ISO2_CODE = "GQ";
1211
private const string EQUATORIALGUINEA_ISO3_CODE = "GNQ";
1312
private readonly string[] EQUATORIALGUINEA_CALLING_CODE = ["240"];
14-
private static readonly string[] VALID_STATE_TYPES = { "Province" };
13+
private static CountryIdentifier ExpectedId => CountryIdentifier.EquatorialGuinea;
14+
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
15+
{
16+
new("Annobón", "AN", "Province"),
17+
new("Bioko Norte", "BN", "Province"),
18+
new("Bioko Sur", "BS", "Province"),
19+
new("Centro Sur", "CS", "Province"),
20+
new("Djibloho", "DJ", "Province"),
21+
new("Kié-Ntem", "KN", "Province"),
22+
new("Litoral", "LI", "Province"),
23+
new("Wele-Nzas", "WN", "Province")
24+
};
1525

1626
[Fact]
1727
public void GetCountry_ReturnsCorrectInformation_ForEquatorialGuinea()
1828
{
1929
// Arrange
20-
CountryIdentifier existingCountryId = CountryIdentifier.EquatorialGuinea;
21-
2230
// Act
23-
var country = CountryProvider.GetCountry(existingCountryId);
31+
var country = CountryProvider.GetCountry(ExpectedId);
2432

2533
// Assert
26-
Assert.Equal(existingCountryId, country.Id);
27-
Assert.Equal(EQUATORIALGUINEA_NAME, country.Name);
28-
Assert.NotNull(country.States);
29-
Assert.Equal(EQUATORIALGUINEA_STATE_COUNT, country.States.Count());
30-
Assert.Equal(EQUATORIALGUINEA_OFFICIAL_NAME, country.OfficialName);
31-
Assert.Equal(EQUATORIALGUINEA_NATIVE_NAME, country.NativeName);
32-
Assert.Equal(EQUATORIALGUINEA_CAPITAL, country.Capital);
33-
Assert.Equal(EQUATORIALGUINEA_NUMERIC_CODE, country.NumericCode);
34-
Assert.Equal(EQUATORIALGUINEA_ISO2_CODE, country.ISO2Code);
35-
Assert.Equal(EQUATORIALGUINEA_ISO3_CODE, country.ISO3Code);
36-
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
37-
Assert.Equal(EQUATORIALGUINEA_CALLING_CODE, country.CallingCode);
34+
AssertCorrectInformation(
35+
country,
36+
ExpectedId,
37+
EQUATORIALGUINEA_NAME,
38+
EQUATORIALGUINEA_OFFICIAL_NAME,
39+
EQUATORIALGUINEA_NATIVE_NAME,
40+
EQUATORIALGUINEA_CAPITAL,
41+
EQUATORIALGUINEA_NUMERIC_CODE,
42+
EQUATORIALGUINEA_ISO2_CODE,
43+
EQUATORIALGUINEA_ISO3_CODE,
44+
EQUATORIALGUINEA_CALLING_CODE,
45+
ExpectedStates
46+
);
3847
}
3948

4049
}

src/World.Net.UnitTests/Countries/EritreaTest.cs

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace World.Net.UnitTests.Countries
88
{
9-
public class EritreaTest
9+
public class EritreaTest : AssertCountryTestBase
1010
{
1111
private const string ERITREA_NAME = "Eritrea";
1212
private const int ERITREA_STATE_COUNT = 6;
@@ -18,29 +18,38 @@ public class EritreaTest
1818
private const string ERITREA_ISO3_CODE = "ERI";
1919
private readonly string[] ERITREA_CALLING_CODE = ["291"];
2020
private static readonly string[] VALID_STATE_TYPES = { "Region" };
21+
private static CountryIdentifier ExpectedId => CountryIdentifier.Eritrea;
22+
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
23+
{
24+
new("Anseba", "AN", "Region"),
25+
new("Debub", "DU", "Region"),
26+
new("Debubawi Keyih Bahri", "DK", "Region"),
27+
new("Gash-Barka", "GB", "Region"),
28+
new("Maekel", "MA", "Region"),
29+
new("Semenawi Keyih Bahri", "SK", "Region")
30+
};
2131

2232
[Fact]
2333
public void GetCountry_ReturnsCorrectInformation_ForEritrea()
2434
{
2535
// Arrange
26-
CountryIdentifier existingCountryId = CountryIdentifier.Eritrea;
27-
2836
// Act
29-
var country = CountryProvider.GetCountry(existingCountryId);
37+
var country = CountryProvider.GetCountry(ExpectedId);
3038

3139
// Assert
32-
Assert.Equal(existingCountryId, country.Id);
33-
Assert.Equal(ERITREA_NAME, country.Name);
34-
Assert.NotNull(country.States);
35-
Assert.Equal(ERITREA_STATE_COUNT, country.States.Count());
36-
Assert.Equal(ERITREA_OFFICIAL_NAME, country.OfficialName);
37-
Assert.Equal(ERITREA_NATIVE_NAME, country.NativeName);
38-
Assert.Equal(ERITREA_CAPITAL, country.Capital);
39-
Assert.Equal(ERITREA_NUMERIC_CODE, country.NumericCode);
40-
Assert.Equal(ERITREA_ISO2_CODE, country.ISO2Code);
41-
Assert.Equal(ERITREA_ISO3_CODE, country.ISO3Code);
42-
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
43-
Assert.Equal(ERITREA_CALLING_CODE, country.CallingCode);
40+
AssertCorrectInformation(
41+
country,
42+
ExpectedId,
43+
ERITREA_NAME,
44+
ERITREA_OFFICIAL_NAME,
45+
ERITREA_NATIVE_NAME,
46+
ERITREA_CAPITAL,
47+
ERITREA_NUMERIC_CODE,
48+
ERITREA_ISO2_CODE,
49+
ERITREA_ISO3_CODE,
50+
ERITREA_CALLING_CODE,
51+
ExpectedStates
52+
);
4453
}
4554
}
4655
}
Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace World.Net.UnitTests.Countries
22
{
3-
public sealed class EstoniaTest
3+
public sealed class EstoniaTest : AssertCountryTestBase
44
{
55
private const string ESTONIA_NAME = "Estonia";
66
private const int ESTONIA_STATE_COUNT = 15;
@@ -11,30 +11,47 @@ public sealed class EstoniaTest
1111
private const string ESTONIA_ISO2_CODE = "EE";
1212
private const string ESTONIA_ISO3_CODE = "EST";
1313
private readonly string[] ESTONIA_CALLING_CODE = ["372"];
14-
private static readonly string[] VALID_STATE_TYPES = { "County" };
14+
private static CountryIdentifier ExpectedId => CountryIdentifier.Estonia;
15+
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
16+
{
17+
new("Harju", "37", "County"),
18+
new("Hiiu", "39", "County"),
19+
new("Ida-Viru", "44", "County"),
20+
new("Jõgeva", "49", "County"),
21+
new("Järva", "51", "County"),
22+
new("Lääne", "57", "County"),
23+
new("Lääne-Viru", "59", "County"),
24+
new("Põlva", "65", "County"),
25+
new("Pärnu", "67", "County"),
26+
new("Rapla", "70", "County"),
27+
new("Saare", "74", "County"),
28+
new("Tartu", "78", "County"),
29+
new("Valga", "82", "County"),
30+
new("Viljandi", "84", "County"),
31+
new("Võru", "86", "County")
32+
};
1533

1634
[Fact]
1735
public void GetCountry_ReturnsCorrectInformation_ForEstonia()
1836
{
1937
// Arrange
20-
CountryIdentifier existingCountryId = CountryIdentifier.Estonia;
21-
2238
// Act
23-
var country = CountryProvider.GetCountry(existingCountryId);
39+
var country = CountryProvider.GetCountry(ExpectedId);
2440

2541
// Assert
26-
Assert.Equal(existingCountryId, country.Id);
27-
Assert.Equal(ESTONIA_NAME, country.Name);
28-
Assert.NotNull(country.States);
29-
Assert.Equal(ESTONIA_STATE_COUNT, country.States.Count());
30-
Assert.Equal(ESTONIA_OFFICIAL_NAME, country.OfficialName);
31-
Assert.Equal(ESTONIA_NATIVE_NAME, country.NativeName);
32-
Assert.Equal(ESTONIA_CAPITAL, country.Capital);
33-
Assert.Equal(ESTONIA_NUMERIC_CODE, country.NumericCode);
34-
Assert.Equal(ESTONIA_ISO2_CODE, country.ISO2Code);
35-
Assert.Equal(ESTONIA_ISO3_CODE, country.ISO3Code);
36-
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
37-
Assert.Equal(ESTONIA_CALLING_CODE, country.CallingCode);
42+
AssertCorrectInformation(
43+
country,
44+
ExpectedId,
45+
ESTONIA_NAME,
46+
ESTONIA_OFFICIAL_NAME,
47+
ESTONIA_NATIVE_NAME,
48+
ESTONIA_CAPITAL,
49+
ESTONIA_NUMERIC_CODE,
50+
ESTONIA_ISO2_CODE,
51+
ESTONIA_ISO3_CODE,
52+
ESTONIA_CALLING_CODE,
53+
ExpectedStates
54+
);
3855
}
3956
}
4057
}
Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
namespace World.Net.UnitTests.Countries
22
{
3-
public class EswatiniTest
3+
public class EswatiniTest : AssertCountryTestBase
44
{
5+
private static CountryIdentifier ExpectedId => CountryIdentifier.Eswatini;
56
private const string ESWATINI_NAME = "Eswatini";
67
private const int ESWATINI_STATE_COUNT = 4;
78
private const string ESWATINI_OFFICIAL_NAME = "Kingdom of Eswatini";
@@ -11,30 +12,35 @@ public class EswatiniTest
1112
private const string ESWATINI_ISO2_CODE = "SZ";
1213
private const string ESWATINI_ISO3_CODE = "SWZ";
1314
private readonly string[] ESWATINI_CALLING_CODE = ["268"];
14-
private static readonly string[] VALID_STATE_TYPES = { "Region" };
15+
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
16+
{
17+
new("Hhohho", "HH", "Region"),
18+
new("Lubombo", "LU", "Region"),
19+
new("Manzini", "MA", "Region"),
20+
new("Shiselweni", "SH", "Region")
21+
};
1522

1623
[Fact]
1724
public void GetCountry_ReturnsCorrectInformation_ForEswatini()
1825
{
1926
// Arrange
20-
CountryIdentifier existingCountryId = CountryIdentifier.Eswatini;
21-
2227
// Act
23-
var country = CountryProvider.GetCountry(existingCountryId);
28+
var country = CountryProvider.GetCountry(ExpectedId);
2429

2530
// Assert
26-
Assert.Equal(existingCountryId, country.Id);
27-
Assert.Equal(ESWATINI_NAME, country.Name);
28-
Assert.NotNull(country.States);
29-
Assert.Equal(ESWATINI_STATE_COUNT, country.States.Count());
30-
Assert.Equal(ESWATINI_OFFICIAL_NAME, country.OfficialName);
31-
Assert.Equal(ESWATINI_NATIVE_NAME, country.NativeName);
32-
Assert.Equal(ESWATINI_CAPITAL, country.Capital);
33-
Assert.Equal(ESWATINI_NUMERIC_CODE, country.NumericCode);
34-
Assert.Equal(ESWATINI_ISO2_CODE, country.ISO2Code);
35-
Assert.Equal(ESWATINI_ISO3_CODE, country.ISO3Code);
36-
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
37-
Assert.Equal(ESWATINI_CALLING_CODE, country.CallingCode);
31+
AssertCorrectInformation(
32+
country,
33+
ExpectedId,
34+
ESWATINI_NAME,
35+
ESWATINI_OFFICIAL_NAME,
36+
ESWATINI_NATIVE_NAME,
37+
ESWATINI_CAPITAL,
38+
ESWATINI_NUMERIC_CODE,
39+
ESWATINI_ISO2_CODE,
40+
ESWATINI_ISO3_CODE,
41+
ESWATINI_CALLING_CODE,
42+
ExpectedStates
43+
);
3844
}
3945
}
4046
}

0 commit comments

Comments
 (0)