Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use named constants for test cases to enable us maintain the project easily #11

Merged
merged 8 commits into from
Jan 25, 2025
27 changes: 18 additions & 9 deletions src/World.Net.UnitTests/Countries/AlandIslandsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

public sealed class AlandIslandsTest
{
private const string ALAND_ISLANDS_NAME = "Aland Islands";
private const string ALAND_ISLANDS_OFFICIAL_NAME = "Åland Islands";
private const string ALAND_ISLANDS_NATIVE_NAME = "Åland";
private const string ALAND_ISLANDS_CAPITAL = "Mariehamn";
private const int ALAND_ISLANDS_NUMERIC_CODE = 248;
private const string ALAND_ISLANDS_ISO2_CODE = "AX";
private const string ALAND_ISLANDS_ISO3_CODE = "ALA";
private const string ALAND_ISLANDS_CALLING_CODE = "+358";

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForAlandIslands()
{
Expand All @@ -12,14 +21,14 @@ public void GetCountry_ReturnsCorrectInformation_ForAlandIslands()
var country = CountryProvider.GetCountry(existingCountryId);

//Assert
Assert.Equal(2, country.Id);
Assert.Equal("Aland Islands", country.Name);
Assert.Equal("Åland Islands", country.OfficialName);
Assert.Equal("Åland", country.NativeName);
Assert.Equal("Mariehamn", country.Capital);
Assert.Equal(248, country.NumericCode);
Assert.Equal("AX", country.ISO2Code);
Assert.Equal("ALA", country.ISO3Code);
Assert.Equal("+358", country.CallingCode);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(ALAND_ISLANDS_NAME, country.Name);
Assert.Equal(ALAND_ISLANDS_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(ALAND_ISLANDS_NATIVE_NAME, country.NativeName);
Assert.Equal(ALAND_ISLANDS_CAPITAL, country.Capital);
Assert.Equal(ALAND_ISLANDS_NUMERIC_CODE, country.NumericCode);
Assert.Equal(ALAND_ISLANDS_ISO2_CODE, country.ISO2Code);
Assert.Equal(ALAND_ISLANDS_ISO3_CODE, country.ISO3Code);
Assert.Equal(ALAND_ISLANDS_CALLING_CODE, country.CallingCode);
}
}
27 changes: 18 additions & 9 deletions src/World.Net.UnitTests/CountryProviderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ namespace World.Net.UnitTests;

public sealed class CountryProviderTest
{
private const string AFGHANISTAN_ISO2_CODE = "AF";
private const string AFGHANISTAN_ISO3_CODE = "AFG";
private const string AFGHANISTAN_CAPITAL = "Kabul";
private const int AFGHANISTAN_NUMERIC_CODE = 004;
private const string AFGHANISTAN_CALLING_CODE = "+93";
private const int AFGHANISTAN_STATE_COUNT = 34;
private const string AFGHANISTAN_NAME = "Afghanistan";
private const string AFGHANISTAN_NATIVE_NAME = "افغانستان";
private const string AFGHANISTAN_OFFICIAL_NAME = "Islamic Republic of Afghanistan";
[Fact]
public void GetAllCountries_ShouldReturn_NonEmptyAndNonNullCollection()
{
Expand All @@ -26,16 +35,16 @@ public void GetCountry_ShouldReturn_Country_WhenCountryExists()
Assert.NotNull(country);
Assert.NotEmpty(country.Name);
Assert.NotEmpty(country.States);
Assert.Equal("AF", country.ISO2Code);
Assert.Equal("AFG", country.ISO3Code);
Assert.Equal("Kabul", country.Capital);
Assert.Equal(004, country.NumericCode);
Assert.Equal("+93", country.CallingCode);
Assert.Equal(34, country.States.Count());
Assert.Equal("Afghanistan", country.Name);
Assert.Equal(AFGHANISTAN_ISO2_CODE, country.ISO2Code);
Assert.Equal(AFGHANISTAN_ISO3_CODE, country.ISO3Code);
Assert.Equal(AFGHANISTAN_CAPITAL, country.Capital);
Assert.Equal(AFGHANISTAN_NUMERIC_CODE, country.NumericCode);
Assert.Equal(AFGHANISTAN_CALLING_CODE, country.CallingCode);
Assert.Equal(AFGHANISTAN_STATE_COUNT, country.States.Count());
Assert.Equal(AFGHANISTAN_NAME, country.Name);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal("افغانستان", country.NativeName);
Assert.Equal("Islamic Republic of Afghanistan", country.OfficialName);
Assert.Equal(AFGHANISTAN_NATIVE_NAME, country.NativeName);
Assert.Equal(AFGHANISTAN_OFFICIAL_NAME, country.OfficialName);
}

[Fact]
Expand Down
3 changes: 3 additions & 0 deletions src/World.Net/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

namespace World.Net;

/// <summary>
/// Represents a state, province, or region with relevant details such as its name, ISO code, and type.
/// </summary>
public class State
{
/// <summary>
Expand Down
Loading