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/FranceTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace World.Net.UnitTests.Countries;
public sealed class FranceTest
{
private const string FRANCE_NAME = "France";
private const int FRANCE_STATE_COUNT = 116;
private const string FRANCE_OFFICIAL_NAME = "French Republic";
private const string FRANCE_NATIVE_NAME = "France";
private const string FRANCE_CAPITAL = "Paris";
private const int FRANCE_NUMERIC_CODE = 250;
private const string FRANCE_ISO2_CODE = "FR";
private static readonly string[] VALID_STATE_TYPES = { "metropolitan department", "European collectivity", "metropolitan region", "dependency", "metropolitan collectivity with special status", "overseas region", "overseas collectivity", "overseas territory", "overseas region", "metropolitan department", "metropolitan department", };
private const string FRANCE_ISO3_CODE = "FRA";
private readonly string[] FRANCE_CALLING_CODE = ["+33"];

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test for valid state type(s)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved


[Fact]
public void GetCountry_ReturnsCorrectInformation_ForFrance()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.France;

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

//Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(FRANCE_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(FRANCE_STATE_COUNT, country.States.Count());
Assert.Equal(FRANCE_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(FRANCE_NATIVE_NAME, country.NativeName);
Assert.Equal(FRANCE_CAPITAL, country.Capital);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(FRANCE_NUMERIC_CODE, country.NumericCode);
Assert.Equal(FRANCE_ISO2_CODE, country.ISO2Code);
Assert.Equal(FRANCE_ISO3_CODE, country.ISO3Code);
Assert.Equal(FRANCE_CALLING_CODE, country.CallingCode);
}
}
36 changes: 36 additions & 0 deletions src/World.Net.UnitTests/Countries/FrenchGuianaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace World.Net.UnitTests.Countries;
public sealed class FrenchGuianaTest
{
private const string FRENCH_GUIANA_NAME = "French Guiana";
private const string FRENCH_GUIANA_OFFICIAL_NAME = "Guyane française";
private const string FRENCH_GUIANA_NATIVE_NAME = "Guyane française";
private const string FRENCH_GUIANA_CAPITAL = "Cayenne";
private const int FRENCH_GUIANA_NUMERIC_CODE = 254;
private const string FRENCH_GUIANA_ISO2_CODE = "GF";
private const string FRENCH_GUIANA_ISO3_CODE = "GUF";
private readonly string[] FRENCH_GUIANA_CALLING_CODE = ["+594"];

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test for valid state type(s)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the country has no states


[Fact]
public void GetCountry_ReturnsCorrectInformation_ForFrench_Guiana()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.FrenchGuiana;

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

//Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(FRENCH_GUIANA_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Empty(country.States);
Assert.Equal(FRENCH_GUIANA_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(FRENCH_GUIANA_NATIVE_NAME, country.NativeName);
Assert.Equal(FRENCH_GUIANA_CAPITAL, country.Capital);
Assert.Equal(FRENCH_GUIANA_NUMERIC_CODE, country.NumericCode);
Assert.Equal(FRENCH_GUIANA_ISO2_CODE, country.ISO2Code);
Assert.Equal(FRENCH_GUIANA_ISO3_CODE, country.ISO3Code);
Assert.Equal(FRENCH_GUIANA_CALLING_CODE, country.CallingCode);
}
}
39 changes: 39 additions & 0 deletions src/World.Net.UnitTests/Countries/FrenchPolynesiaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace World.Net.UnitTests.Countries;
public sealed class FrenchPolynesiaTest
{
private const string FRENCH_POLYNESIA_NAME = "French Polynesia";
private const int FRENCH_POLYNESIA_STATE_COUNT = 5;
private const string FRENCH_POLYNESIA_OFFICIAL_NAME = "Polynésie française";
private const string FRENCH_POLYNESIA_NATIVE_NAME = "Polynésie française";
private const string FRENCH_POLYNESIA_CAPITAL = "Papeete";
private const int FRENCH_POLYNESIA_NUMERIC_CODE = 258;
private const string FRENCH_POLYNESIA_ISO2_CODE = "PF";
private const string FRENCH_POLYNESIA_ISO3_CODE = "PYF";
private static readonly string[] VALID_STATE_TYPES = { "division" };
private readonly string[] FRENCH_POLYNESIA_CALLING_CODE = ["+689"];

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test for valid state type(s)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved


[Fact]
public void GetCountry_ReturnsCorrectInformation_ForFrench_Polynesia()
{
// Arrange
CountryIdentifier existingCountryId = CountryIdentifier.FrenchPolynesia;

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

//Assert
Assert.Equal(existingCountryId, country.Id);
Assert.Equal(FRENCH_POLYNESIA_NAME, country.Name);
Assert.NotNull(country.States);
Assert.Equal(FRENCH_POLYNESIA_STATE_COUNT, country.States.Count());
Assert.Equal(FRENCH_POLYNESIA_OFFICIAL_NAME, country.OfficialName);
Assert.Equal(FRENCH_POLYNESIA_NATIVE_NAME, country.NativeName);
Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES));
Assert.Equal(FRENCH_POLYNESIA_CAPITAL, country.Capital);
Assert.Equal(FRENCH_POLYNESIA_NUMERIC_CODE, country.NumericCode);
Assert.Equal(FRENCH_POLYNESIA_ISO2_CODE, country.ISO2Code);
Assert.Equal(FRENCH_POLYNESIA_ISO3_CODE, country.ISO3Code);
Assert.Equal(FRENCH_POLYNESIA_CALLING_CODE, country.CallingCode);
}
}
151 changes: 151 additions & 0 deletions src/World.Net/Countries/France.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
namespace World.Net.Countries;
internal sealed class France : ICountry
{
///<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.France;

///<inheritdoc/>
public string Name => nameof(France);

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

///<inheritdoc/>
public string NativeName { get; } = "France";

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

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

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

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

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

///<inheritdoc/>
public IEnumerable<State> States { get; } =
[
new("Ain", "FR-01", "metropolitan department"),
new("Aisne", "FR-02", "metropolitan department"),
new("Allier", "FR-03", "metropolitan department"),
new("Alpes-de-Haute-Provence", "FR-04", "metropolitan department"),
new("Alpes-Maritimes", "FR-06", "metropolitan department"),
new("Alsace", "FR-6AE", "European collectivity"),
new("Ardèche", "FR-07", "metropolitan department"),
new("Ardennes", "FR-08", "metropolitan department"),
new("Ariège", "FR-09", "metropolitan department"),
new("Aube", "FR-10", "metropolitan department"),
new("Aude", "FR-11", "metropolitan department"),
new("Auvergne-Rhône-Alpes", "FR-ARA", "metropolitan region"),
new("Aveyron", "FR-12", "metropolitan department"),
new("Bas-Rhin", "FR-67", "metropolitan department"),
new("Bouches-du-Rhône", "FR-13", "metropolitan department"),
new("Bourgogne-Franche-Comté", "FR-BFC", "metropolitan region"),
new("Bretagne", "FR-BRE", "metropolitan region"),
new("Calvados", "FR-14", "metropolitan department"),
new("Cantal", "FR-15", "metropolitan department"),
new("Centre-Val de Loire", "FR-CVL", "metropolitan region"),
new("Charente", "FR-16", "metropolitan department"),
new("Charente-Maritime", "FR-17", "metropolitan department"),
new("Cher", "FR-18", "metropolitan department"),
new("Clipperton", "FR-CP", "dependency"),
new("Corrèze", "FR-19", "metropolitan department"),
new("Corse", "FR-20R", "metropolitan collectivity with special status"),
new("Corse-du-Sud", "FR-2A", "metropolitan department"),
new("Côte-d'Or", "FR-21", "metropolitan department"),
new("Côtes-d'Armor", "FR-22", "metropolitan department"),
new("Creuse", "FR-23", "metropolitan department"),
new("Deux-Sèvres", "FR-79", "metropolitan department"),
new("Dordogne", "FR-24", "metropolitan department"),
new("Doubs", "FR-25", "metropolitan department"),
new("Drôme", "FR-26", "metropolitan department"),
new("Essonne", "FR-91", "metropolitan department"),
new("Eure", "FR-27", "metropolitan department"),
new("Eure-et-Loir", "FR-28", "metropolitan department"),
new("Finistère", "FR-29", "metropolitan department"),
new("French Guiana", "FR-973", "overseas region"),
new("French Polynesia", "FR-PF", "overseas collectivity"),
new("French Southern and Antarctic Lands", "FR-TF", "overseas territory"),
new("Gard", "FR-30", "metropolitan department"),
new("Gers", "FR-32", "metropolitan department"),
new("Gironde", "FR-33", "metropolitan department"),
new("Grand-Est", "FR-GES", "metropolitan region"),
new("Guadeloupe", "FR-971", "overseas region"),
new("Haut-Rhin", "FR-68", "metropolitan department"),
new("Haute-Corse", "FR-2B", "metropolitan department"),
new("Haute-Garonne", "FR-31", "metropolitan department"),
new("Haute-Loire", "FR-43", "metropolitan department"),
new("Haute-Marne", "FR-52", "metropolitan department"),
new("Haute-Saône", "FR-70", "metropolitan department"),
new("Haute-Savoie", "FR-74", "metropolitan department"),
new("Haute-Vienne", "FR-87", "metropolitan department"),
new("Hautes-Alpes", "FR-05", "metropolitan department"),
new("Hautes-Pyrénées", "FR-65", "metropolitan department"),
new("Hauts-de-France", "FR-HDF", "metropolitan region"),
new("Hauts-de-Seine", "FR-92", "metropolitan department"),
new("Hérault", "FR-34", "metropolitan department"),
new("Île-de-France", "FR-IDF", "metropolitan region"),
new("Ille-et-Vilaine", "FR-35", "metropolitan department"),
new("Indre", "FR-36", "metropolitan department"),
new("Indre-et-Loire", "FR-37", "metropolitan department"),
new("Isère", "FR-38", "metropolitan department"),
new("Jura", "FR-39", "metropolitan department"),
new("La Réunion", "FR-974", "overseas region"),
new("Landes", "FR-40", "metropolitan department"),
new("Loir-et-Cher", "FR-41", "metropolitan department"),
new("Loire", "FR-42", "metropolitan department"),
new("Loire-Atlantique", "FR-44", "metropolitan department"),
new("Loiret", "FR-45", "metropolitan department"),
new("Lot", "FR-46", "metropolitan department"),
new("Lot-et-Garonne", "FR-47", "metropolitan department"),
new("Lozère", "FR-48", "metropolitan department"),
new("Maine-et-Loire", "FR-49", "metropolitan department"),
new("Manche", "FR-50", "metropolitan department"),
new("Marne", "FR-51", "metropolitan department"),
new("Martinique", "FR-972", "overseas region"),
new("Mayenne", "FR-53", "metropolitan department"),
new("Mayotte", "FR-976", "overseas region"),
new("Métropole de Lyon", "FR-69M", "metropolitan department"),
new("Meurthe-et-Moselle", "FR-54", "metropolitan department"),
new("Meuse", "FR-55", "metropolitan department"),
new("Morbihan", "FR-56", "metropolitan department"),
new("Moselle", "FR-57", "metropolitan department"),
new("Nièvre", "FR-58", "metropolitan department"),
new("Nord", "FR-59", "metropolitan department"),
new("Oise", "FR-60", "metropolitan department"),
new("Oléron", "FR-OL", "dependency"),
new("Orne", "FR-61", "metropolitan department"),
new("Paris", "FR-75", "metropolitan department"),
new("Pas-de-Calais", "FR-62", "metropolitan department"),
new("Puy-de-Dôme", "FR-63", "metropolitan department"),
new("Pyrénées-Atlantiques", "FR-64", "metropolitan department"),
new("Pyrénées-Orientales", "FR-66", "metropolitan department"),
new("Réunion", "FR-974", "overseas region"),
new("Rhône", "FR-69", "metropolitan department"),
new("Saône-et-Loire", "FR-71", "metropolitan department"),
new("Sarthe", "FR-72", "metropolitan department"),
new("Savoie", "FR-73", "metropolitan department"),
new("Seine-et-Marne", "FR-77", "metropolitan department"),
new("Seine-Maritime", "FR-76", "metropolitan department"),
new("Yvelines", "FR-78", "metropolitan department"),
new("Somme", "FR-80", "metropolitan department"),
new("Tarn", "FR-81", "metropolitan department"),
new("Tarn-et-Garonne", "FR-82", "metropolitan department"),
new("Territoire de Belfort", "FR-90", "metropolitan department"),
new("Val-de-Marne", "FR-94", "metropolitan department"),
new("Val-d'Oise", "FR-95", "metropolitan department"),
new("Var", "FR-83", "metropolitan department"),
new("Vaucluse", "FR-84", "metropolitan department"),
new("Vendée", "FR-85", "metropolitan department"),
new("Vienne", "FR-86", "metropolitan department"),
new("Vosges", "FR-88", "metropolitan department"),
new("Yonne", "FR-89", "metropolitan department"),
new("Yvelines", "FR-78", "metropolitan department")
];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we cross check this list again

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

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

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

//<inheritdoc/>
public string OfficialName { get; } = "Guyane française";

//<inheritdoc/>
public string NativeName => "Guyane française";

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

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

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

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

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

//<inheritdoc/>
public IEnumerable<State> States => [];
}
40 changes: 40 additions & 0 deletions src/World.Net/Countries/FrenchPolynesia.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace World.Net.Countries;
internal sealed class FrenchPolynesia : ICountry
{
//<inheritdoc/>
public CountryIdentifier Id => CountryIdentifier.FrenchPolynesia;

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

//<inheritdoc/>
public string OfficialName { get; } = "Polynésie française";

//<inheritdoc/>
public string NativeName => "Polynésie française";

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

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

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

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

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

//<inheritdoc/>
public IEnumerable<State> States =>
[
new("N'Austral Islands", "PF-01", "division"),
new("Leeward Islands", "PF-02", "division"),
new("Marquesas Islands", "PF-03", "division"),
new("Tuamotu-Gambier", "PF-04", "division"),
new("Windward Islands", "PF-05", "division"),
];
}
3 changes: 3 additions & 0 deletions src/World.Net/Helpers/CountryInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public static Dictionary<CountryIdentifier, ICountry> Initialize()
{ CountryIdentifier.Denmark, new Denmark() },
{ CountryIdentifier.Djibouti, new Djibouti() },
{ CountryIdentifier.Dominica, new Dominica() },
{ CountryIdentifier.France, new France() },
{ CountryIdentifier.FrenchGuiana, new FrenchGuiana() },
{ CountryIdentifier.FrenchPolynesia, new FrenchPolynesia() },

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