Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e57de56
add estonia
selfmadecode May 24, 2025
0439d65
resolve merge conflicts
selfmadecode May 24, 2025
84bc92c
initialize estonia
selfmadecode May 24, 2025
983c251
add Ethiopia details
selfmadecode May 24, 2025
42615bc
rename estonia test class
selfmadecode May 24, 2025
3ea2802
add ethiopia test class
selfmadecode May 24, 2025
511d7d2
add FalklandIslands details
selfmadecode May 24, 2025
ffe2b65
add FalklandIslands tests
selfmadecode May 24, 2025
1c7d0b9
add Eswatini
selfmadecode May 24, 2025
0b6237e
add Eswatini test class
selfmadecode May 24, 2025
48b0366
add el salvador
selfmadecode May 24, 2025
a6b7d9f
add equatorial
selfmadecode May 24, 2025
ee912f3
add eritrea
selfmadecode May 24, 2025
1882ff5
resolve merge conflict
selfmadecode May 24, 2025
fd2f505
update initializer
selfmadecode May 24, 2025
b04bd06
remove duplicate keys
selfmadecode May 24, 2025
6608815
Merge branch 'main' into feat/add-countries
selfmadecode Sep 10, 2025
3d9de0c
add Kazakhstan details
selfmadecode Sep 10, 2025
fb386cf
add unit tests for Kazakhstan
selfmadecode Sep 10, 2025
47bb5a3
update initializer
selfmadecode Sep 10, 2025
9acdd5a
Merge branch 'main' into feat/add-countries
selfmadecode Sep 11, 2025
ac0b1d4
update copilot prompt file
selfmadecode Sep 11, 2025
4e10df5
add kenya details
selfmadecode Sep 11, 2025
9807581
initialize kenya
selfmadecode Sep 11, 2025
3b8b3de
add kiribati details
selfmadecode Sep 11, 2025
979b905
initialize kiribati
selfmadecode Sep 11, 2025
fd6963b
add kosovo details
selfmadecode Sep 11, 2025
4b3e1e3
add unit test for kosovo
selfmadecode Sep 11, 2025
c64f018
add kuwait
selfmadecode Sep 11, 2025
19cf6c4
add Kyrgyzstan
selfmadecode Sep 11, 2025
290a1da
initialize states
selfmadecode Sep 11, 2025
c04ceba
resolve merge conflict
selfmadecode Sep 11, 2025
41a3bdc
update tests
selfmadecode Sep 11, 2025
e064106
update kuwait
selfmadecode Sep 11, 2025
b184d48
remove unused
selfmadecode Oct 4, 2025
eb96384
add loas
selfmadecode Oct 8, 2025
efab575
add loas
selfmadecode Oct 8, 2025
14b28b3
remove unused using
selfmadecode Oct 8, 2025
c43d80e
add full details for Laos
selfmadecode Oct 8, 2025
0eea0f0
initalize laos
selfmadecode Oct 8, 2025
e2b95da
add laos unit tests
selfmadecode Oct 8, 2025
b2f1961
remove unused using in laos test class
selfmadecode Oct 8, 2025
a111fa1
add latvia
selfmadecode Oct 9, 2025
3f87a57
initalize latvia
selfmadecode Oct 9, 2025
248db4f
add test base class
selfmadecode Oct 9, 2025
4d361ad
add latvia test case
selfmadecode Oct 9, 2025
aca1239
introduce test base class
selfmadecode Oct 9, 2025
169302f
refactor finland test
selfmadecode Oct 9, 2025
1c3ebf0
update finland test
selfmadecode Oct 9, 2025
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
41 changes: 41 additions & 0 deletions src/World.Net.UnitTests/AssertCountryTestBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace World.Net.UnitTests
{
public abstract class AssertCountryTestBase
{
protected static void AssertCorrectInformation(
ICountry country,
CountryIdentifier expectedId,
string expectedName,
string expectedOfficialName,
string expectedNativeName,
string expectedCapital,
int expectedNumericCode,
string expectedISO2Code,
string expectedISO3Code,
string[] expectedCallingCode,
(string Name, string IsoCode, string Type)[] expectedStates)
{
Assert.NotNull(country);
Assert.Equal(expectedId, country.Id);
Assert.Equal(expectedName, country.Name);
Assert.Equal(expectedOfficialName, country.OfficialName);
Assert.Equal(expectedNativeName, country.NativeName);
Assert.Equal(expectedCapital, country.Capital);
Assert.Equal(expectedNumericCode, country.NumericCode);
Assert.Equal(expectedISO2Code, country.ISO2Code);
Assert.Equal(expectedISO3Code, country.ISO3Code);
Assert.Equal(expectedCallingCode, country.CallingCode);
Assert.NotNull(country.States);

var states = country.States.ToArray();
Assert.Equal(expectedStates.Length, states.Length);

for (int i = 0; i < states.Length; i++)
{
Assert.Equal(expectedStates[i].Name, states[i].Name);
Assert.Equal(expectedStates[i].IsoCode, states[i].IsoCode);
Assert.Equal(expectedStates[i].Type, states[i].Type);
}
}
}
}
59 changes: 40 additions & 19 deletions src/World.Net.UnitTests/Countries/FinlandTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace World.Net.UnitTests.Countries;

public sealed class FinlandTest
public sealed class FinlandTest : AssertCountryTestBase
{
private const string FINLAND_COUNTRY_NAME = "Finland";
private const string FINLAND_NATIVE_NAME = "Suomen tasavalta / Republiken Finland";
Expand All @@ -10,32 +10,53 @@ public sealed class FinlandTest
private const string FINLAND_ISO3_CODE = "FIN";
private const int FINLAND_NUMERIC_CODE = 246;
private readonly string[] FINLAND_CALLING_CODE = ["+358"];
private const int FINLAND_STATE_COUNT = 21;
private static readonly string[] VALID_STATE_TYPES = { "Region" };
private const CountryIdentifier EXPECTEDID = CountryIdentifier.Finland;
private static readonly (string Name, string IsoCode, string Type)[] EXPECTED_STATES =
[
new("Åland", "FI-01", "Region"),
new("Central Finland", "FI-08", "Region"),
new("Central Ostrobothnia", "FI-07", "Region"),
new("Etelä-Karjala", "FI-02", "Region"),
new("Etelä-Pohjanmaa", "FI-03", "Region"),
new("Etelä-Savo", "FI-04", "Region"),
new("Kainuu", "FI-05", "Region"),
new("Kanta-Häme", "FI-06", "Region"),
new("Keski-Pohjanmaa", "FI-09", "Region"),
new("Keski-Suomi", "FI-10", "Region"),
new("Kymenlaakso", "FI-11", "Region"),
new("Lappi", "FI-12", "Region"),
new("Pirkanmaa", "FI-13", "Region"),
new("Pohjanmaa", "FI-14", "Region"),
new("Pohjois-Karjala", "FI-15", "Region"),
new("Pohjois-Pohjanmaa", "FI-16", "Region"),
new("Pohjois-Savo", "FI-17", "Region"),
new("Päijät-Häme", "FI-18", "Region"),
new("Satakunta", "FI-19", "Region"),
new("Uusimaa", "FI-20", "Region"),
new("Varsinais-Suomi", "FI-21", "Region")
];

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForFinland()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Finland;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(FINLAND_COUNTRY_NAME, country.Name);
Assert.Equal(FINLAND_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(FINLAND_NATIVE_NAME, country.NativeName);
Assert.Equal(FINLAND_CAPITAL, country.Capital);
Assert.Equal(FINLAND_NUMERIC_CODE, country.NumericCode);
Assert.Equal(FINLAND_ISO2_CODE, country.ISO2Code);
Assert.Equal(FINLAND_ISO3_CODE, country.ISO3Code);
Assert.Equal(FINLAND_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Equal(FINLAND_STATE_COUNT, country.States.Count());
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
AssertCorrectInformation(
country,
EXPECTEDID,
FINLAND_COUNTRY_NAME,
FINLAND_OFFICIAL_NAME,
FINLAND_NATIVE_NAME,
FINLAND_CAPITAL,
FINLAND_NUMERIC_CODE,
FINLAND_ISO2_CODE,
FINLAND_ISO3_CODE,
FINLAND_CALLING_CODE,
EXPECTED_STATES
);
}
}

54 changes: 54 additions & 0 deletions src/World.Net.UnitTests/Countries/KosovoTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using World.Net;
using World.Net.Countries;
using World.Net.Helpers;
using Xunit;

namespace World.Net.UnitTests.Countries
{
public class KosovoTest
{
private const CountryIdentifier ExpectedId = CountryIdentifier.Kosovo;
private const string ExpectedName = "Kosovo";
private const string ExpectedOfficialName = "Republic of Kosovo";
private const string ExpectedNativeName = "Republika e Kosov�s";
private const string ExpectedCapital = "Pristina";
private const int ExpectedNumericCode = 383;
private const string ExpectedISO2Code = "XK";
private const string ExpectedISO3Code = "XKX";
private static readonly string[] ExpectedCallingCode = ["+383"];
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
[
("Ferizaj", "XK-05", "District"),
("Gjakov�", "XK-06", "District"),
("Gjilan", "XK-07", "District"),
("Mitrovic�", "XK-03", "District"),
("Pej�", "XK-02", "District"),
("Prishtin�", "XK-01", "District"),
("Prizren", "XK-04", "District")
];

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForKosovo()
{
var country = CountryProvider.GetCountry(ExpectedId);
Assert.Equal(ExpectedId, country.Id);
Assert.Equal(ExpectedName, country.Name);
Assert.Equal(ExpectedOfficialName, country.OfficialName);
Assert.Equal(ExpectedNativeName, country.NativeName);
Assert.Equal(ExpectedCapital, country.Capital);
Assert.Equal(ExpectedNumericCode, country.NumericCode);
Assert.Equal(ExpectedISO2Code, country.ISO2Code);
Assert.Equal(ExpectedISO3Code, country.ISO3Code);
Assert.Equal(ExpectedCallingCode, country.CallingCode);

var states = country.States.ToArray();
Assert.Equal(ExpectedStates.Length, states.Length);
for (int i = 0; i < states.Length; i++)
{
Assert.Equal(ExpectedStates[i].Name, states[i].Name);
Assert.Equal(ExpectedStates[i].IsoCode, states[i].IsoCode);
Assert.Equal(ExpectedStates[i].Type, states[i].Type);
}
}
}
}
48 changes: 48 additions & 0 deletions src/World.Net.UnitTests/Countries/KuwaitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace World.Net.UnitTests.Countries
{
public class KuwaitTest
{
private const CountryIdentifier ExpectedId = CountryIdentifier.Kuwait;
private const string ExpectedName = "Kuwait";
private const string ExpectedOfficialName = "State of Kuwait";
private const string ExpectedNativeName = "دولة الكويت";
private const string ExpectedCapital = "Kuwait City";
private const int ExpectedNumericCode = 414;
private const string ExpectedISO2Code = "KW";
private const string ExpectedISO3Code = "KWT";
private static readonly string[] ExpectedCallingCode = ["+965"];
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
[
("Al Ahmadi", "KW-AH", "Governorate"),
("Al Farwaniyah", "KW-FA", "Governorate"),
("Al Asimah", "KW-KU", "Governorate"),
("Al Jahra", "KW-JA", "Governorate"),
("Hawalli", "KW-HA", "Governorate"),
("Mubarak Al-Kabeer", "KW-MU", "Governorate")
];

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForKuwait()
{
var country = CountryProvider.GetCountry(ExpectedId);
Assert.Equal(ExpectedId, country.Id);
Assert.Equal(ExpectedName, country.Name);
Assert.Equal(ExpectedOfficialName, country.OfficialName);
Assert.Equal(ExpectedNativeName, country.NativeName);
Assert.Equal(ExpectedCapital, country.Capital);
Assert.Equal(ExpectedNumericCode, country.NumericCode);
Assert.Equal(ExpectedISO2Code, country.ISO2Code);
Assert.Equal(ExpectedISO3Code, country.ISO3Code);
Assert.Equal(ExpectedCallingCode, country.CallingCode);

var states = country.States.ToArray();
Assert.Equal(ExpectedStates.Length, states.Length);
for (int i = 0; i < states.Length; i++)
{
Assert.Equal(ExpectedStates[i].Name, states[i].Name);
Assert.Equal(ExpectedStates[i].IsoCode, states[i].IsoCode);
Assert.Equal(ExpectedStates[i].Type, states[i].Type);
}
}
}
}
56 changes: 56 additions & 0 deletions src/World.Net.UnitTests/Countries/KyrgyzstanTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using World.Net;
using World.Net.Countries;
using World.Net.Helpers;
using Xunit;

namespace World.Net.UnitTests.Countries
{
public class KyrgyzstanTest
{
private const CountryIdentifier ExpectedId = CountryIdentifier.Kyrgyzstan;
private const string ExpectedName = "Kyrgyzstan";
private const string ExpectedOfficialName = "Kyrgyz Republic";
private const string ExpectedNativeName = "Киргизская Республика";
private const string ExpectedCapital = "Bishkek";
private const int ExpectedNumericCode = 417;
private const string ExpectedISO2Code = "KG";
private const string ExpectedISO3Code = "KGZ";
private static readonly string[] ExpectedCallingCode = ["+996"];
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
[
("Batken", "KG-B", "Region"),
("Chuy", "KG-C", "Region"),
("Jalal-Abad", "KG-J", "Region"),
("Naryn", "KG-N", "Region"),
("Osh", "KG-O", "Region"),
("Talas", "KG-T", "Region"),
("Issyk-Kul", "KG-Y", "Region"),
("Bishkek", "KG-GB", "City"),
("Osh City", "KG-GO", "City")
];

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForKyrgyzstan()
{
var country = CountryProvider.GetCountry(ExpectedId);
Assert.Equal(ExpectedId, country.Id);
Assert.Equal(ExpectedName, country.Name);
Assert.Equal(ExpectedOfficialName, country.OfficialName);
Assert.Equal(ExpectedNativeName, country.NativeName);
Assert.Equal(ExpectedCapital, country.Capital);
Assert.Equal(ExpectedNumericCode, country.NumericCode);
Assert.Equal(ExpectedISO2Code, country.ISO2Code);
Assert.Equal(ExpectedISO3Code, country.ISO3Code);
Assert.Equal(ExpectedCallingCode, country.CallingCode);

var states = country.States.ToArray();
Assert.Equal(ExpectedStates.Length, states.Length);
for (int i = 0; i < states.Length; i++)
{
Assert.Equal(ExpectedStates[i].Name, states[i].Name);
Assert.Equal(ExpectedStates[i].IsoCode, states[i].IsoCode);
Assert.Equal(ExpectedStates[i].Type, states[i].Type);
}
}
}
}
61 changes: 61 additions & 0 deletions src/World.Net.UnitTests/Countries/LaosTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
namespace World.Net.UnitTests.Countries
{
public class LaosTest
{
private const CountryIdentifier ExpectedId = CountryIdentifier.Laos;
private const string ExpectedName = "Laos";
private const string ExpectedOfficialName = "Lao People's Democratic Republic";
private const string ExpectedNativeName = "ສາທາລະນະລັດ ປະຊາຊົນລາວ";
private const string ExpectedCapital = "Vientiane";
private const int ExpectedNumericCode = 418;
private const string ExpectedISO2Code = "LA";
private const string ExpectedISO3Code = "LAO";
private static readonly string[] ExpectedCallingCode = ["+856"];
private static readonly (string Name, string IsoCode, string Type)[] ExpectedStates =
[
("Attapeu", "LA-AT", "Province"),
("Bokeo", "LA-BK", "Province"),
("Bolikhamxai", "LA-BL", "Province"),
("Champasak", "LA-CH", "Province"),
("Houaphan", "LA-HO", "Province"),
("Khammouan", "LA-KH", "Province"),
("Luang Namtha", "LA-LM", "Province"),
("Luang Prabang", "LA-LP", "Province"),
("Oudomxai", "LA-OU", "Province"),
("Phongsaly", "LA-PH", "Province"),
("Salavan", "LA-SL", "Province"),
("Savannakhét", "LA-SV", "Province"),
("Sekong", "LA-XE", "Province"),
("Vientiane Province", "LA-VI", "Province"),
("Vientiane Prefecture", "LA-VT", "Prefecture"),
("Xaignabouli", "LA-XA", "Province"),
("Xaisomboun", "LA-XN", "Province"),
("Xiangkhouang", "LA-XI", "Province")
];


[Fact]
public void GetCountry_ReturnsCorrectInformation_ForLaos()
{
var country = CountryProvider.GetCountry(ExpectedId);
Assert.Equal(ExpectedId, country.Id);
Assert.Equal(ExpectedName, country.Name);
Assert.Equal(ExpectedOfficialName, country.OfficialName);
Assert.Equal(ExpectedNativeName, country.NativeName);
Assert.Equal(ExpectedCapital, country.Capital);
Assert.Equal(ExpectedNumericCode, country.NumericCode);
Assert.Equal(ExpectedISO2Code, country.ISO2Code);
Assert.Equal(ExpectedISO3Code, country.ISO3Code);
Assert.Equal(ExpectedCallingCode, country.CallingCode);

var states = country.States.ToArray();
Assert.Equal(ExpectedStates.Length, states.Length);
for (int i = 0; i < states.Length; i++)
{
Assert.Equal(ExpectedStates[i].Name, states[i].Name);
Assert.Equal(ExpectedStates[i].IsoCode, states[i].IsoCode);
Assert.Equal(ExpectedStates[i].Type, states[i].Type);
}
}
}
}
Loading