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
39 changes: 39 additions & 0 deletions src/World.Net.UnitTests/Countries/JamaicaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace World.Net.UnitTests.Countries;
public sealed class JamaicaTest
{
private const string JAMAICA_COUNTRY_NAME = "Jamaica";
private const string JAMAICA_NATIVE_NAME = "Jamaica";
private const string JAMAICA_CAPITAL = "Kingston";
private const string JAMAICA_OFFICIAL_NAME = "Jamaica";
private const string JAMAICA_ISO2_CODE = "JM";
private const string JAMAICA_ISO3_CODE = "JAM";
private const int JAMAICA_NUMERIC_CODE = 388;
private readonly string[] JAMAICA_CALLING_CODE = ["+1-876"];
private const int JAMAICA_STATE_COUNT = 14;
private static readonly string[] VALID_STATE_TYPES = { "Parish" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForJamaica()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Jamaica;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(JAMAICA_COUNTRY_NAME, country.Name);
Assert.Equal(JAMAICA_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(JAMAICA_NATIVE_NAME, country.NativeName);
Assert.Equal(JAMAICA_CAPITAL, country.Capital);
Assert.Equal(JAMAICA_NUMERIC_CODE, country.NumericCode);
Assert.Equal(JAMAICA_ISO2_CODE, country.ISO2Code);
Assert.Equal(JAMAICA_ISO3_CODE, country.ISO3Code);
Assert.Equal(JAMAICA_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Equal(JAMAICA_STATE_COUNT, country.States.Count());
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
39 changes: 39 additions & 0 deletions src/World.Net.UnitTests/Countries/JapanTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace World.Net.UnitTests.Countries;
public sealed class JapanTest
{
private const string JAPAN_COUNTRY_NAME = "Japan";
private const string JAPAN_NATIVE_NAME = "日本";
private const string JAPAN_CAPITAL = "Tokyo";
private const string JAPAN_OFFICIAL_NAME = "Japan";
private const string JAPAN_ISO2_CODE = "JP";
private const string JAPAN_ISO3_CODE = "JPN";
private const int JAPAN_NUMERIC_CODE = 392;
private readonly string[] JAPAN_CALLING_CODE = ["+81"];
private const int JAPAN_STATE_COUNT = 47;
private static readonly string[] VALID_STATE_TYPES = { "Prefecture" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForJapan()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Japan;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(JAPAN_COUNTRY_NAME, country.Name);
Assert.Equal(JAPAN_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(JAPAN_NATIVE_NAME, country.NativeName);
Assert.Equal(JAPAN_CAPITAL, country.Capital);
Assert.Equal(JAPAN_NUMERIC_CODE, country.NumericCode);
Assert.Equal(JAPAN_ISO2_CODE, country.ISO2Code);
Assert.Equal(JAPAN_ISO3_CODE, country.ISO3Code);
Assert.Equal(JAPAN_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Equal(JAPAN_STATE_COUNT, country.States.Count());
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
39 changes: 39 additions & 0 deletions src/World.Net.UnitTests/Countries/JerseyTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace World.Net.UnitTests.Countries;
public sealed class JerseyTest
{
private const string JERSEY_COUNTRY_NAME = "Jersey";
private const string JERSEY_NATIVE_NAME = "Jersey";
private const string JERSEY_CAPITAL = "Saint Helier";
private const string JERSEY_OFFICIAL_NAME = "Bailiwick of Jersey";
private const string JERSEY_ISO2_CODE = "JE";
private const string JERSEY_ISO3_CODE = "JEY";
private const int JERSEY_NUMERIC_CODE = 832;
private readonly string[] JERSEY_CALLING_CODE = ["+44"];
private const int JERSEY_STATE_COUNT = 12;
private static readonly string[] VALID_STATE_TYPES = { "parish" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForJersey()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Jersey;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(JERSEY_COUNTRY_NAME, country.Name);
Assert.Equal(JERSEY_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(JERSEY_NATIVE_NAME, country.NativeName);
Assert.Equal(JERSEY_CAPITAL, country.Capital);
Assert.Equal(JERSEY_NUMERIC_CODE, country.NumericCode);
Assert.Equal(JERSEY_ISO2_CODE, country.ISO2Code);
Assert.Equal(JERSEY_ISO3_CODE, country.ISO3Code);
Assert.Equal(JERSEY_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Equal(JERSEY_STATE_COUNT, country.States.Count());
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
39 changes: 39 additions & 0 deletions src/World.Net.UnitTests/Countries/JordanTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace World.Net.UnitTests.Countries;
public sealed class JordanTest
{
private const string JORDAN_COUNTRY_NAME = "Jordan";
private const string JORDAN_NATIVE_NAME = "الأردن";
private const string JORDAN_CAPITAL = "Amman";
private const string JORDAN_OFFICIAL_NAME = "Hashemite Kingdom of Jordan";
private const string JORDAN_ISO2_CODE = "JO";
private const string JORDAN_ISO3_CODE = "JOR";
private const int JORDAN_NUMERIC_CODE = 400;
private readonly string[] JORDAN_CALLING_CODE = ["+962"];
private const int JORDAN_STATE_COUNT = 12;
private static readonly string[] VALID_STATE_TYPES = { "governorate" };

[Fact]
public void GetCountry_ReturnsCorrectInformation_ForJordan()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.Jordan;

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

// Assert
Assert.NotNull(country);
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(JORDAN_COUNTRY_NAME, country.Name);
Assert.Equal(JORDAN_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(JORDAN_NATIVE_NAME, country.NativeName);
Assert.Equal(JORDAN_CAPITAL, country.Capital);
Assert.Equal(JORDAN_NUMERIC_CODE, country.NumericCode);
Assert.Equal(JORDAN_ISO2_CODE, country.ISO2Code);
Assert.Equal(JORDAN_ISO3_CODE, country.ISO3Code);
Assert.Equal(JORDAN_CALLING_CODE, country.CallingCode);
Assert.NotNull(country.States);
Assert.Equal(JORDAN_STATE_COUNT, country.States.Count());
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
}
}
48 changes: 48 additions & 0 deletions src/World.Net/Countries/Jamaica.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace World.Net.Countries;
internal sealed class Jamaica : ICountry
{
public CountryIdentifier Id => CountryIdentifier.Jamaica;

//<inheritdoc/>
public string Name { get; } = "Jamaica";

//<inheritdoc/>
public string OfficialName { get; } = "Jamaica";

//<inheritdoc/>
public string NativeName => "Jamaica";

//<inheritdoc/>
public string Capital { get; } = "Kingston";

//<inheritdoc/>
public int NumericCode { get; } = 388;

//<inheritdoc/>
public string ISO2Code { get; } = "JM";

//<inheritdoc/>
public string ISO3Code { get; } = "JAM";

//<inheritdoc/>
public string[] CallingCode { get; } = ["+1-876"];

//<inheritdoc/>
public IEnumerable<State> States =>
[
new("Clarendon", "JM-13", "Parish"),
new("Hanover", "JM-09", "Parish"),
new("Kingston", "JM-01", "Parish"),
new("Manchester", "JM-12", "Parish"),
new("Portland", "JM-04", "Parish"),
new("Saint Andrew", "JM-02", "Parish"),
new("Saint Ann", "JM-06", "Parish"),
new("Saint Catherine", "JM-14", "Parish"),
new("Saint Elizabeth", "JM-11", "Parish"),
new("Saint James", "JM-08", "Parish"),
new("Saint Mary", "JM-05", "Parish"),
new("Saint Thomas", "JM-03", "Parish"),
new("Trelawny", "JM-07", "Parish"),
new("Westmoreland", "JM-10", "Parish"),
];
}
82 changes: 82 additions & 0 deletions src/World.Net/Countries/Japan.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
namespace World.Net.Countries;
internal sealed class Japan : ICountry
{
public CountryIdentifier Id => CountryIdentifier.Japan;

//<inheritdoc/>
public string Name { get; } = "Japan";

//<inheritdoc/>
public string OfficialName { get; } = "Japan";

//<inheritdoc/>
public string NativeName => "日本";

//<inheritdoc/>
public string Capital { get; } = "Tokyo";

//<inheritdoc/>
public int NumericCode { get; } = 392;

//<inheritdoc/>
public string ISO2Code { get; } = "JP";

//<inheritdoc/>
public string ISO3Code { get; } = "JPN";

//<inheritdoc/>
public string[] CallingCode { get; } = ["+81"];

//<inheritdoc/>
public IEnumerable<State> States =>
[
new("Aichi", "JP-23", "Prefecture"),
new("Akita", "JP-05", "Prefecture"),
new("Aomori", "JP-02", "Prefecture"),
new("Chiba", "JP-12", "Prefecture"),
new("Ehime", "JP-38", "Prefecture"),
new("Fukui", "JP-18", "Prefecture"),
new("Fukuoka", "JP-40", "Prefecture"),
new("Fukushima", "JP-07", "Prefecture"),
new("Gifu", "JP-21", "Prefecture"),
new("Gunma", "JP-10", "Prefecture"),
new("Hiroshima", "JP-34", "Prefecture"),
new("Hokkaidō", "JP-01", "Prefecture"),
new("Hyōgo", "JP-28", "Prefecture"),
new("Ibaraki", "JP-08", "Prefecture"),
new("Ishikawa", "JP-17", "Prefecture"),
new("Iwate", "JP-03", "Prefecture"),
new("Kagawa", "JP-37", "Prefecture"),
new("Kagoshima", "JP-46", "Prefecture"),
new("Kanagawa", "JP-14", "Prefecture"),
new("Kōchi", "JP-39", "Prefecture"),
new("Kumamoto", "JP-43", "Prefecture"),
new("Kyōto", "JP-26", "Prefecture"),
new("Mie", "JP-24", "Prefecture"),
new("Miyagi", "JP-04", "Prefecture"),
new("Miyazaki", "JP-45", "Prefecture"),
new("Nagano", "JP-20", "Prefecture"),
new("Nagasaki", "JP-42", "Prefecture"),
new("Nara", "JP-29", "Prefecture"),
new("Niigata", "JP-15", "Prefecture"),
new("Ōita", "JP-44", "Prefecture"),
new("Okayama", "JP-33", "Prefecture"),
new("Okinawa", "JP-47", "Prefecture"),
new("Ōsaka", "JP-27", "Prefecture"),
new("Saga", "JP-41", "Prefecture"),
new("Saitama", "JP-11", "Prefecture"),
new("Shiga", "JP-25", "Prefecture"),
new("Shimane", "JP-32", "Prefecture"),
new("Shizuoka", "JP-22", "Prefecture"),
new("Tochigi", "JP-09", "Prefecture"),
new("Tokushima", "JP-36", "Prefecture"),
new("Tokyo", "JP-13", "Prefecture"),
new("Tottori", "JP-31", "Prefecture"),
new("Toyama", "JP-16", "Prefecture"),
new("Wakayama", "JP-30", "Prefecture"),
new("Yamagata", "JP-06", "Prefecture"),
new("Yamaguchi", "JP-35", "Prefecture"),
new("Yamanashi", "JP-19", "Prefecture"),

];
}
46 changes: 46 additions & 0 deletions src/World.Net/Countries/Jersey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace World.Net.Countries;
internal sealed class Jersey : ICountry
{
public CountryIdentifier Id => CountryIdentifier.Jersey;

//<inheritdoc/>
public string Name { get; } = "Jersey";

//<inheritdoc/>
public string OfficialName { get; } = "Bailiwick of Jersey";

//<inheritdoc/>
public string NativeName => "Jersey";

//<inheritdoc/>
public string Capital { get; } = "Saint Helier";

//<inheritdoc/>
public int NumericCode { get; } = 832;

//<inheritdoc/>
public string ISO2Code { get; } = "JE";

//<inheritdoc/>
public string ISO3Code { get; } = "JEY";

//<inheritdoc/>
public string[] CallingCode { get; } = ["+44"];

//<inheritdoc/>
public IEnumerable<State> States =>
[
new("Grouville", "JE-01", "parish"),
new("St Brelade", "JE-02", "parish"),
new("St Clement", "JE-03", "parish"),
new("St Helier", "JE-04", "parish"),
new("St John", "JE-05", "parish"),
new("St Lawrence", "JE-06", "parish"),
new("St Martin", "JE-07", "parish"),
new("St Mary", "JE-08", "parish"),
new("St Ouen", "JE-09", "parish"),
new("St Peter", "JE-10", "parish"),
new("St Saviour", "JE-11", "parish"),
new("Trinity", "JE-12", "parish"),
];
}
46 changes: 46 additions & 0 deletions src/World.Net/Countries/Jordan.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
namespace World.Net.Countries;
internal sealed class Jordan : ICountry
{
public CountryIdentifier Id => CountryIdentifier.Jordan;

//<inheritdoc/>
public string Name { get; } = "Jordan";

//<inheritdoc/>
public string OfficialName { get; } = "Hashemite Kingdom of Jordan";

//<inheritdoc/>
public string NativeName => "الأردن";

//<inheritdoc/>
public string Capital { get; } = "Amman";

//<inheritdoc/>
public int NumericCode { get; } = 400;

//<inheritdoc/>
public string ISO2Code { get; } = "JO";

//<inheritdoc/>
public string ISO3Code { get; } = "JOR";

//<inheritdoc/>
public string[] CallingCode { get; } = ["+962"];

//<inheritdoc/>
public IEnumerable<State> States =>
[
new("Ajloun", "JO-AJ", "governorate"),
new("Amman", "JO-AM", "governorate"),
new("Aqaba", "JO-AQ", "governorate"),
new("Balqa", "JO-BA", "governorate"),
new("Irbid", "JO-IR", "governorate"),
new("Jerash", "JO-JA", "governorate"),
new("Karak", "JO-KA", "governorate"),
new("Ma'an", "JO-MN", "governorate"),
new("Madaba", "JO-MD", "governorate"),
new("Mafraq", "JO-MA", "governorate"),
new("Tafilah", "JO-AT", "governorate"),
new("Zarqa", "JO-AZ", "governorate"),
];
}
4 changes: 4 additions & 0 deletions src/World.Net/Helpers/CountryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
{ CountryIdentifier.Ireland, new Ireland() },
{ CountryIdentifier.Israel, new Israel() },
{ CountryIdentifier.Italy, new Italy() },
{ CountryIdentifier.Jamaica, new Jamaica() },
{ CountryIdentifier.Japan, new Japan() },
{ CountryIdentifier.Jersey, new Jersey() },
{ CountryIdentifier.Jordan, new Jordan() }

// Future countries can be added here in the same format.
};
Expand Down