Skip to content

Commit 84270a1

Browse files
authored
Merge pull request #80 from selfmadecode/feat/add-countries
update test cases
2 parents 7621577 + 1b7fac1 commit 84270a1

11 files changed

Lines changed: 456 additions & 74 deletions
Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using World.Net;
2-
using World.Net.Countries;
3-
using World.Net.Helpers;
4-
using Xunit;
5-
6-
namespace World.Net.UnitTests.Countries
1+
namespace World.Net.UnitTests.Countries
72
{
8-
public class KyrgyzstanTest
3+
public class KyrgyzstanTest : AssertCountryTestBase
94
{
105
private const CountryIdentifier ExpectedId = CountryIdentifier.Kyrgyzstan;
116
private const string ExpectedName = "Kyrgyzstan";
@@ -33,24 +28,20 @@ private static readonly (string Name, string IsoCode, string Type)[] ExpectedSta
3328
public void GetCountry_ReturnsCorrectInformation_ForKyrgyzstan()
3429
{
3530
var country = CountryProvider.GetCountry(ExpectedId);
36-
Assert.Equal(ExpectedId, country.Id);
37-
Assert.Equal(ExpectedName, country.Name);
38-
Assert.Equal(ExpectedOfficialName, country.OfficialName);
39-
Assert.Equal(ExpectedNativeName, country.NativeName);
40-
Assert.Equal(ExpectedCapital, country.Capital);
41-
Assert.Equal(ExpectedNumericCode, country.NumericCode);
42-
Assert.Equal(ExpectedISO2Code, country.ISO2Code);
43-
Assert.Equal(ExpectedISO3Code, country.ISO3Code);
44-
Assert.Equal(ExpectedCallingCode, country.CallingCode);
4531

46-
var states = country.States.ToArray();
47-
Assert.Equal(ExpectedStates.Length, states.Length);
48-
for (int i = 0; i < states.Length; i++)
49-
{
50-
Assert.Equal(ExpectedStates[i].Name, states[i].Name);
51-
Assert.Equal(ExpectedStates[i].IsoCode, states[i].IsoCode);
52-
Assert.Equal(ExpectedStates[i].Type, states[i].Type);
53-
}
32+
AssertCorrectInformation(
33+
country,
34+
ExpectedId,
35+
ExpectedName,
36+
ExpectedOfficialName,
37+
ExpectedNativeName,
38+
ExpectedCapital,
39+
ExpectedNumericCode,
40+
ExpectedISO2Code,
41+
ExpectedISO3Code,
42+
ExpectedCallingCode,
43+
ExpectedStates
44+
);
5445
}
5546
}
5647
}

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace World.Net.UnitTests.Countries
22
{
3-
public class LaosTest
3+
public class LaosTest : AssertCountryTestBase
44
{
55
private const CountryIdentifier ExpectedId = CountryIdentifier.Laos;
66
private const string ExpectedName = "Laos";
@@ -38,24 +38,20 @@ private static readonly (string Name, string IsoCode, string Type)[] ExpectedSta
3838
public void GetCountry_ReturnsCorrectInformation_ForLaos()
3939
{
4040
var country = CountryProvider.GetCountry(ExpectedId);
41-
Assert.Equal(ExpectedId, country.Id);
42-
Assert.Equal(ExpectedName, country.Name);
43-
Assert.Equal(ExpectedOfficialName, country.OfficialName);
44-
Assert.Equal(ExpectedNativeName, country.NativeName);
45-
Assert.Equal(ExpectedCapital, country.Capital);
46-
Assert.Equal(ExpectedNumericCode, country.NumericCode);
47-
Assert.Equal(ExpectedISO2Code, country.ISO2Code);
48-
Assert.Equal(ExpectedISO3Code, country.ISO3Code);
49-
Assert.Equal(ExpectedCallingCode, country.CallingCode);
5041

51-
var states = country.States.ToArray();
52-
Assert.Equal(ExpectedStates.Length, states.Length);
53-
for (int i = 0; i < states.Length; i++)
54-
{
55-
Assert.Equal(ExpectedStates[i].Name, states[i].Name);
56-
Assert.Equal(ExpectedStates[i].IsoCode, states[i].IsoCode);
57-
Assert.Equal(ExpectedStates[i].Type, states[i].Type);
58-
}
42+
AssertCorrectInformation(
43+
country,
44+
ExpectedId,
45+
ExpectedName,
46+
ExpectedOfficialName,
47+
ExpectedNativeName,
48+
ExpectedCapital,
49+
ExpectedNumericCode,
50+
ExpectedISO2Code,
51+
ExpectedISO3Code,
52+
ExpectedCallingCode,
53+
ExpectedStates
54+
);
5955
}
6056
}
6157
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private static readonly (string Name, string IsoCode, string Type)[] ExpectedSta
5353

5454

5555
[Fact]
56-
public void GetCountry_ReturnsCorrectInformation_ForLaos()
56+
public void GetCountry_ReturnsCorrectInformation_ForLatvia()
5757
{
5858
var country = CountryProvider.GetCountry(ExpectedId);
5959

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace World.Net.UnitTests.Countries
8+
{
9+
public class LibyaTest : AssertCountryTestBase
10+
{
11+
public static CountryIdentifier Id => CountryIdentifier.Libya;
12+
public string Name { get; } = "Libya";
13+
public string OfficialName { get; } = "State of Libya";
14+
public string NativeName { get; } = "دولة ليبيا";
15+
public string Capital { get; } = "Tripoli";
16+
public int NumericCode { get; } = 434;
17+
public string ISO2Code { get; } = "LY";
18+
public string ISO3Code { get; } = "LBY";
19+
public string[] CallingCode { get; } = ["+218"];
20+
private static readonly (string Name, string IsoCode, string Type)[] States =
21+
[
22+
new("Al Butnan", "LY-BU", "District"),
23+
new("Al Jabal al Akhdar", "LY-JA", "District"),
24+
new("Al Jabal al Gharbi", "LY-JG", "District"),
25+
new("Al Jafara", "LY-JI", "District"),
26+
new("Al Jufra", "LY-JU", "District"),
27+
new("Al Kufra", "LY-KF", "District"),
28+
new("Al Marj", "LY-MJ", "District"),
29+
new("Al Marqab", "LY-MB", "District"),
30+
new("Al Wahat", "LY-WA", "District"),
31+
new("Nalut", "LY-NL", "District"),
32+
new("Misrata", "LY-MI", "District"),
33+
new("Murzuq", "LY-MQ", "District"),
34+
new("Sabha", "LY-SB", "District"),
35+
new("Sirt", "LY-SR", "District"),
36+
new("Tripoli", "LY-TB", "District"),
37+
new("Wadi al Hayat", "LY-WD", "District"),
38+
new("Wadi ash Shati'", "LY-WS", "District"),
39+
new("Zawiya", "LY-ZA", "District")
40+
];
41+
42+
43+
[Fact]
44+
public void GetCountry_ReturnsCorrectInformation_ForLibya()
45+
{
46+
var country = CountryProvider.GetCountry(Id);
47+
48+
AssertCorrectInformation(
49+
country,
50+
Id,
51+
Name,
52+
OfficialName,
53+
NativeName,
54+
Capital,
55+
NumericCode,
56+
ISO2Code,
57+
ISO3Code,
58+
CallingCode,
59+
States
60+
);
61+
}
62+
}
63+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace World.Net.UnitTests.Countries
8+
{
9+
public sealed class LiechtensteinTest : AssertCountryTestBase
10+
{
11+
public static CountryIdentifier Id => CountryIdentifier.Liechtenstein;
12+
public string Name { get; } = "Liechtenstein";
13+
public string OfficialName { get; } = "Principality of Liechtenstein";
14+
public string NativeName { get; } = "Fürstentum Liechtenstein";
15+
public string Capital { get; } = "Vaduz";
16+
public int NumericCode { get; } = 438;
17+
public string ISO2Code { get; } = "LI";
18+
public string ISO3Code { get; } = "LIE";
19+
public string[] CallingCode { get; } = ["+423"];
20+
private static readonly (string Name, string IsoCode, string Type)[] States =
21+
[
22+
new("Balzers", "LI-01", "Municipality"),
23+
new("Eschen", "LI-02", "Municipality"),
24+
new("Gamprin", "LI-03", "Municipality"),
25+
new("Mauren", "LI-04", "Municipality"),
26+
new("Planken", "LI-05", "Municipality"),
27+
new("Ruggell", "LI-06", "Municipality"),
28+
new("Schaan", "LI-07", "Municipality"),
29+
new("Schellenberg", "LI-08", "Municipality"),
30+
new("Triesen", "LI-09", "Municipality"),
31+
new("Triesenberg", "LI-10", "Municipality"),
32+
new("Vaduz", "LI-11", "Municipality")
33+
];
34+
35+
36+
[Fact]
37+
public void GetCountry_ReturnsCorrectInformation_ForLiechtenstein()
38+
{
39+
var country = CountryProvider.GetCountry(Id);
40+
41+
AssertCorrectInformation(
42+
country,
43+
Id,
44+
Name,
45+
OfficialName,
46+
NativeName,
47+
Capital,
48+
NumericCode,
49+
ISO2Code,
50+
ISO3Code,
51+
CallingCode,
52+
States
53+
);
54+
}
55+
}
56+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace World.Net.UnitTests.Countries
8+
{
9+
public class LithuaniaTest : AssertCountryTestBase
10+
{
11+
public static CountryIdentifier Id => CountryIdentifier.Lithuania;
12+
public string Name { get; } = "Lithuania";
13+
public string OfficialName { get; } = "Republic of Lithuania";
14+
public string NativeName { get; } = "Lietuvos Respublika";
15+
public string Capital { get; } = "Vilnius";
16+
public int NumericCode { get; } = 440;
17+
public string ISO2Code { get; } = "LT";
18+
public string ISO3Code { get; } = "LTU";
19+
public string[] CallingCode { get; } = ["+370"];
20+
private static readonly (string Name, string IsoCode, string Type)[] States =
21+
[
22+
new("Alytus County", "LT-AL", "County"),
23+
new("Kaunas County", "LT-KU", "County"),
24+
new("Klaipėda County", "LT-KL", "County"),
25+
new("Marijampolė County", "LT-MR", "County"),
26+
new("Panevėžys County", "LT-PN", "County"),
27+
new("Šiauliai County", "LT-SA", "County"),
28+
new("Tauragė County", "LT-TA", "County"),
29+
new("Telšiai County", "LT-TE", "County"),
30+
new("Utena County", "LT-UT", "County"),
31+
new("Vilnius County", "LT-VL", "County")
32+
];
33+
34+
35+
[Fact]
36+
public void GetCountry_ReturnsCorrectInformation_ForLithuania()
37+
{
38+
var country = CountryProvider.GetCountry(Id);
39+
40+
AssertCorrectInformation(
41+
country,
42+
Id,
43+
Name,
44+
OfficialName,
45+
NativeName,
46+
Capital,
47+
NumericCode,
48+
ISO2Code,
49+
ISO3Code,
50+
CallingCode,
51+
States
52+
);
53+
}
54+
}
55+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace World.Net.UnitTests.Countries
8+
{
9+
public class LuxembourgTest : AssertCountryTestBase
10+
{
11+
public static CountryIdentifier Id => CountryIdentifier.Luxembourg;
12+
public string Name { get; } = "Luxembourg";
13+
public string OfficialName { get; } = "Grand Duchy of Luxembourg";
14+
public string NativeName { get; } = "Groussherzogtum Lëtzebuerg";
15+
public string Capital { get; } = "Luxembourg City";
16+
public int NumericCode { get; } = 442;
17+
public string ISO2Code { get; } = "LU";
18+
public string ISO3Code { get; } = "LUX";
19+
public string[] CallingCode { get; } = ["+352"];
20+
private static readonly (string Name, string IsoCode, string Type)[] States =
21+
[
22+
new("Capellen", "LU-CA", "Canton"),
23+
new("Clervaux", "LU-CL", "Canton"),
24+
new("Diekirch", "LU-DI", "Canton"),
25+
new("Echternach", "LU-EC", "Canton"),
26+
new("Esch-sur-Alzette", "LU-ES", "Canton"),
27+
new("Grevenmacher", "LU-GR", "Canton"),
28+
new("Luxembourg", "LU-LU", "Canton"),
29+
new("Mersch", "LU-ME", "Canton"),
30+
new("Redange", "LU-RD", "Canton"),
31+
new("Remich", "LU-RM", "Canton"),
32+
new("Vianden", "LU-VD", "Canton"),
33+
new("Wiltz", "LU-WI", "Canton")
34+
];
35+
36+
37+
[Fact]
38+
public void GetCountry_ReturnsCorrectInformation_ForLuxembourg()
39+
{
40+
var country = CountryProvider.GetCountry(Id);
41+
42+
AssertCorrectInformation(
43+
country,
44+
Id,
45+
Name,
46+
OfficialName,
47+
NativeName,
48+
Capital,
49+
NumericCode,
50+
ISO2Code,
51+
ISO3Code,
52+
CallingCode,
53+
States
54+
);
55+
}
56+
}
57+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace World.Net.UnitTests.Countries
8+
{
9+
public class MacauSARTest : AssertCountryTestBase
10+
{
11+
public static CountryIdentifier Id => CountryIdentifier.MacauSAR;
12+
public string Name { get; } = "Macau S.A.R.";
13+
public string OfficialName { get; } = "Macao Special Administrative Region of the People's Republic of China";
14+
public string NativeName { get; } = "中華人民共和國澳門特別行政區";
15+
public string Capital { get; } = "Macau";
16+
public int NumericCode { get; } = 446;
17+
public string ISO2Code { get; } = "MO";
18+
public string ISO3Code { get; } = "MAC";
19+
public string[] CallingCode { get; } = ["+853"];
20+
private static readonly (string Name, string IsoCode, string Type)[] States =
21+
[
22+
new("Macau Peninsula", "MO-PN", "Region"),
23+
new("Taipa", "MO-TA", "Region"),
24+
new("Coloane", "MO-CO", "Region"),
25+
new("Cotai", "MO-CT", "Region")
26+
];
27+
28+
29+
[Fact]
30+
public void GetCountry_ReturnsCorrectInformation_ForMacauSAR()
31+
{
32+
var country = CountryProvider.GetCountry(Id);
33+
34+
AssertCorrectInformation(
35+
country,
36+
Id,
37+
Name,
38+
OfficialName,
39+
NativeName,
40+
Capital,
41+
NumericCode,
42+
ISO2Code,
43+
ISO3Code,
44+
CallingCode,
45+
States
46+
);
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)