From e1d3266586d6f5f2b77888a0f57c54cbd48c2e12 Mon Sep 17 00:00:00 2001 From: deanology Date: Tue, 21 Jan 2025 23:05:01 +0100 Subject: [PATCH 01/15] AlandIsland country details --- src/World.Net/Countries/AlandIslands.cs | 53 ++++++++++++++++++++++ src/World.Net/Helpers/CountryIdentifier.cs | 7 +++ 2 files changed, 60 insertions(+) create mode 100644 src/World.Net/Countries/AlandIslands.cs diff --git a/src/World.Net/Countries/AlandIslands.cs b/src/World.Net/Countries/AlandIslands.cs new file mode 100644 index 0000000..17ada4e --- /dev/null +++ b/src/World.Net/Countries/AlandIslands.cs @@ -0,0 +1,53 @@ + +namespace World.Net.Countries; + +internal sealed class AlandIslands : ICountry +{ + /// + public int Id { get; } = CountryIdentifier.AlandIslands; + + /// + public string Name { get; } = nameof(AlandIslands); + + /// + public string OfficialName { get; } = "Åland Islands"; + + /// + public string NativeName { get; } = "Åland"; + + /// + public string Capital { get; } = "Mariehamn"; + + /// + public int NumericCode { get; } = 248; + + /// + public string ISO2Code { get; } = "AX"; + + /// + public string ISO3Code { get; } = "ALA"; + + /// + public string CallingCode { get; } = "+358"; + + /// + public IEnumerable States { get; } = + [ + new("Mariehamn", "", "Municipality"), + new("Jomala", "", "Municipality"), + new("Finström", "", "Municipality"), + new("Lemland", "", "Municipality"), + new("Saltvik", "", "Municipality"), + new("Hammarland", "", "Municipality"), + new("Sund", "", "Municipality"), + new("Eckerö", "", "Municipality"), + new("Föglö", "", "Municipality"), + new("Geta", "", "Municipality"), + new("Brändö", "", "Municipality"), + new("Vårdö", "", "Municipality"), + new("Lumparland", "", "Municipality"), + new("Kumlinge", "", "Municipality"), + new("Kökar", "", "Municipality"), + new("Sottunga", "", "Municipality"), + ]; +} diff --git a/src/World.Net/Helpers/CountryIdentifier.cs b/src/World.Net/Helpers/CountryIdentifier.cs index 8d6435e..f6ba286 100644 --- a/src/World.Net/Helpers/CountryIdentifier.cs +++ b/src/World.Net/Helpers/CountryIdentifier.cs @@ -15,4 +15,11 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Afghanistan in operations that require a country ID. /// public static readonly int AfghanistanId = 1; + /// + /// The unique identifier for Aland Islands. + /// + /// + /// Use this identifier to reference Aland Islands in operations that require a country ID. + /// + public static readonly int AlandIslands = 2; } From 6be6af2a3d99ce6743754b53a1cfa9a31719ccd5 Mon Sep 17 00:00:00 2001 From: deanology Date: Tue, 21 Jan 2025 23:36:07 +0100 Subject: [PATCH 02/15] added unit test to validate AlandIslands details --- .vs/world.net/v17/DocumentLayout.json | 166 ++++++++++++++++-- .../Countries/AlandIslandsTest.cs | 28 +++ src/World.Net/Helpers/CountryInitializer.cs | 3 +- 3 files changed, 179 insertions(+), 18 deletions(-) create mode 100644 src/World.Net.UnitTests/Countries/AlandIslandsTest.cs diff --git a/.vs/world.net/v17/DocumentLayout.json b/.vs/world.net/v17/DocumentLayout.json index 1a895f9..97e24cd 100644 --- a/.vs/world.net/v17/DocumentLayout.json +++ b/.vs/world.net/v17/DocumentLayout.json @@ -1,10 +1,42 @@ { "Version": 1, - "WorkspaceRootPath": "C:\\Users\\anyan\\source\\repos\\world.net\\", + "WorkspaceRootPath": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\", "Documents": [ { - "AbsoluteMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|c:\\users\\anyan\\source\\repos\\world.net\\src\\world.net\\class1.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", - "RelativeMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|solutionrelative:src\\world.net\\class1.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + "AbsoluteMoniker": "D:0:0:{FD584E36-2331-4DD7-9FAD-0567C5DDD25D}|src\\World.Net.UnitTests\\World.Net.UnitTests.csproj|c:\\users\\sword\\documents\\projects\\world.net\\src\\world.net.unittests\\countries\\alandislandstest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{FD584E36-2331-4DD7-9FAD-0567C5DDD25D}|src\\World.Net.UnitTests\\World.Net.UnitTests.csproj|solutionrelative:src\\world.net.unittests\\countries\\alandislandstest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{58CE3FC4-6578-4019-8EFB-45DD5BE785CB}|src\\World.Net.Console\\World.Net.Console.csproj|c:\\users\\sword\\documents\\projects\\world.net\\src\\world.net.console\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{58CE3FC4-6578-4019-8EFB-45DD5BE785CB}|src\\World.Net.Console\\World.Net.Console.csproj|solutionrelative:src\\world.net.console\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|c:\\users\\sword\\documents\\projects\\world.net\\src\\world.net\\countryprovider.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|solutionrelative:src\\world.net\\countryprovider.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{FD584E36-2331-4DD7-9FAD-0567C5DDD25D}|src\\World.Net.UnitTests\\World.Net.UnitTests.csproj|c:\\users\\sword\\documents\\projects\\world.net\\src\\world.net.unittests\\countryprovidertest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{FD584E36-2331-4DD7-9FAD-0567C5DDD25D}|src\\World.Net.UnitTests\\World.Net.UnitTests.csproj|solutionrelative:src\\world.net.unittests\\countryprovidertest.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|c:\\users\\sword\\documents\\projects\\world.net\\src\\world.net\\helpers\\countryidentifier.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|solutionrelative:src\\world.net\\helpers\\countryidentifier.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|c:\\users\\sword\\documents\\projects\\world.net\\src\\world.net\\helpers\\countryinitializer.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|solutionrelative:src\\world.net\\helpers\\countryinitializer.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|c:\\users\\sword\\documents\\projects\\world.net\\src\\world.net\\countries\\afghanistan.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|solutionrelative:src\\world.net\\countries\\afghanistan.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|c:\\users\\sword\\documents\\projects\\world.net\\src\\world.net\\exceptions\\countrynotfoundexception.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{2550BD61-4CFB-4B16-8413-961D6EECCFBE}|src\\World.Net\\World.Net.csproj|solutionrelative:src\\world.net\\exceptions\\countrynotfoundexception.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{59C370F1-6E5D-488B-B46B-2370B43A69AD}|Solution Items{59C370F1-6E5D-488B-B46B-2370B43A69AD}|C:\\Users\\SWORD\\Documents\\Projects\\world.net\\README.md||{EFC0BB08-EA7D-40C6-A696-C870411A895B}", + "RelativeMoniker": "D:0:0:{59C370F1-6E5D-488B-B46B-2370B43A69AD}|Solution Items{59C370F1-6E5D-488B-B46B-2370B43A69AD}|solutionrelative:README.md||{EFC0BB08-EA7D-40C6-A696-C870411A895B}" } ], "DocumentGroupContainers": [ @@ -14,15 +46,15 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 6, + "SelectedChildIndex": 5, "Children": [ { "$type": "Bookmark", - "Name": "ST:129:0:{75188d03-9892-4ae2-abf1-207126247ce5}" + "Name": "ST:0:0:{cce594b6-0c39-4442-ba28-10c64ac7e89f}" }, { "$type": "Bookmark", - "Name": "ST:128:0:{75188d03-9892-4ae2-abf1-207126247ce5}" + "Name": "ST:129:0:{75188d03-9892-4ae2-abf1-207126247ce5}" }, { "$type": "Bookmark", @@ -37,20 +69,120 @@ "Name": "ST:128:0:{13b12e3e-c1b4-4539-9371-4fe9a0d523fc}" }, { - "$type": "Bookmark", - "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}" + "$type": "Document", + "DocumentIndex": 0, + "Title": "AlandIslandsTest.cs", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net.UnitTests\\Countries\\AlandIslandsTest.cs", + "RelativeDocumentMoniker": "src\\World.Net.UnitTests\\Countries\\AlandIslandsTest.cs", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net.UnitTests\\Countries\\AlandIslandsTest.cs", + "RelativeToolTip": "src\\World.Net.UnitTests\\Countries\\AlandIslandsTest.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAABAAAAAWAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-01-21T22:21:22.611Z", + "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 0, - "Title": "Class1.cs", - "DocumentMoniker": "C:\\Users\\anyan\\source\\repos\\world.net\\src\\World.Net\\Class1.cs", - "RelativeDocumentMoniker": "src\\World.Net\\Class1.cs", - "ToolTip": "C:\\Users\\anyan\\source\\repos\\world.net\\src\\World.Net\\Class1.cs", - "RelativeToolTip": "src\\World.Net\\Class1.cs", - "ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", - "WhenOpened": "2025-01-13T22:30:51.287Z", + "DocumentIndex": 4, + "Title": "CountryIdentifier.cs", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\Helpers\\CountryIdentifier.cs", + "RelativeDocumentMoniker": "src\\World.Net\\Helpers\\CountryIdentifier.cs", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\Helpers\\CountryIdentifier.cs", + "RelativeToolTip": "src\\World.Net\\Helpers\\CountryIdentifier.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAABoAAAArAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-01-21T22:12:19.772Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 5, + "Title": "CountryInitializer.cs", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\Helpers\\CountryInitializer.cs", + "RelativeDocumentMoniker": "src\\World.Net\\Helpers\\CountryInitializer.cs", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\Helpers\\CountryInitializer.cs", + "RelativeToolTip": "src\\World.Net\\Helpers\\CountryInitializer.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-01-21T22:10:23.767Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 2, + "Title": "CountryProvider.cs", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\CountryProvider.cs", + "RelativeDocumentMoniker": "src\\World.Net\\CountryProvider.cs", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\CountryProvider.cs", + "RelativeToolTip": "src\\World.Net\\CountryProvider.cs", + "ViewState": "AgIAABoAAAAAAAAAAAAQwDAAAAAbAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-01-21T19:52:02.454Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 7, + "Title": "CountryNotFoundException.cs", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\Exceptions\\CountryNotFoundException.cs", + "RelativeDocumentMoniker": "src\\World.Net\\Exceptions\\CountryNotFoundException.cs", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\Exceptions\\CountryNotFoundException.cs", + "RelativeToolTip": "src\\World.Net\\Exceptions\\CountryNotFoundException.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-01-21T19:51:56.58Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "Program.cs", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net.Console\\Program.cs", + "RelativeDocumentMoniker": "src\\World.Net.Console\\Program.cs", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net.Console\\Program.cs", + "RelativeToolTip": "src\\World.Net.Console\\Program.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-01-19T14:54:17.251Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 6, + "Title": "Afghanistan.cs", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\Countries\\Afghanistan.cs", + "RelativeDocumentMoniker": "src\\World.Net\\Countries\\Afghanistan.cs", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net\\Countries\\Afghanistan.cs", + "RelativeToolTip": "src\\World.Net\\Countries\\Afghanistan.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAAAYAAAAEAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-01-19T14:47:55.722Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 3, + "Title": "CountryProviderTest.cs", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net.UnitTests\\CountryProviderTest.cs", + "RelativeDocumentMoniker": "src\\World.Net.UnitTests\\CountryProviderTest.cs", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\src\\World.Net.UnitTests\\CountryProviderTest.cs", + "RelativeToolTip": "src\\World.Net.UnitTests\\CountryProviderTest.cs", + "ViewState": "AgIAAAAAAAAAAAAAAAAAAA0AAAAFAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2025-01-19T14:46:24.029Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 8, + "Title": "README.md", + "DocumentMoniker": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\README.md", + "RelativeDocumentMoniker": "README.md", + "ToolTip": "C:\\Users\\SWORD\\Documents\\Projects\\world.net\\README.md", + "RelativeToolTip": "README.md", + "ViewState": "AgIAABUAAAAAAAAAAAAAABwAAABPAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001818|", + "WhenOpened": "2025-01-19T14:45:57.566Z", "EditorCaption": "" } ] diff --git a/src/World.Net.UnitTests/Countries/AlandIslandsTest.cs b/src/World.Net.UnitTests/Countries/AlandIslandsTest.cs new file mode 100644 index 0000000..213d26a --- /dev/null +++ b/src/World.Net.UnitTests/Countries/AlandIslandsTest.cs @@ -0,0 +1,28 @@ +using World.Net.Helpers; + +namespace World.Net.UnitTests.Countries; + +public sealed class AlandIslandsTest +{ + [Fact] + public void AlandIslands_HasExpectedInformation() + { + // Arrange + int existingCountryId = CountryIdentifier.AlandIslands; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(2, country.Id); + Assert.Equal("AlandIslands", 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); + } + +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index e0ecc00..d4ad293 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -6,7 +6,8 @@ public static Dictionary Initialize() { return new Dictionary { - { CountryIdentifier.AfghanistanId, new Afghanistan() } + { CountryIdentifier.AfghanistanId, new Afghanistan() }, + { CountryIdentifier.AlandIslands, new AlandIslands() } // Future countries can be added here in the same format. }; } From dd5af72a9f02906f85804f3c824eb54ff070f6e5 Mon Sep 17 00:00:00 2001 From: deanology Date: Sat, 25 Jan 2025 07:06:43 +0100 Subject: [PATCH 03/15] Added details for Algeria and Test --- .../Countries/AlandIslandsTest.cs | 4 +- .../Countries/AlgeriaTest.cs | 26 +++++ src/World.Net.UnitTests/GlobalUsing.cs | 1 + src/World.Net/Countries/Algeria.cs | 95 +++++++++++++++++++ src/World.Net/Helpers/CountryIdentifier.cs | 7 ++ src/World.Net/Helpers/CountryInitializer.cs | 3 +- 6 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 src/World.Net.UnitTests/Countries/AlgeriaTest.cs create mode 100644 src/World.Net.UnitTests/GlobalUsing.cs create mode 100644 src/World.Net/Countries/Algeria.cs diff --git a/src/World.Net.UnitTests/Countries/AlandIslandsTest.cs b/src/World.Net.UnitTests/Countries/AlandIslandsTest.cs index 213d26a..da28aa9 100644 --- a/src/World.Net.UnitTests/Countries/AlandIslandsTest.cs +++ b/src/World.Net.UnitTests/Countries/AlandIslandsTest.cs @@ -1,6 +1,4 @@ -using World.Net.Helpers; - -namespace World.Net.UnitTests.Countries; +namespace World.Net.UnitTests.Countries; public sealed class AlandIslandsTest { diff --git a/src/World.Net.UnitTests/Countries/AlgeriaTest.cs b/src/World.Net.UnitTests/Countries/AlgeriaTest.cs new file mode 100644 index 0000000..65df56b --- /dev/null +++ b/src/World.Net.UnitTests/Countries/AlgeriaTest.cs @@ -0,0 +1,26 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class AlgeriaTest +{ + [Fact] + public void Algeria_HasExpectedInformation() + { + // Arrange + int existingCountryId = CountryIdentifier.Algeria; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(4, country.Id); + Assert.Equal("Algeria", country.Name); + Assert.Equal("People's Democratic Republic of Algeria", country.OfficialName); + Assert.Equal("الجزائر", country.NativeName); + Assert.Equal("Algiers", country.Capital); + Assert.Equal(12, country.NumericCode); + Assert.Equal("DZ", country.ISO2Code); + Assert.Equal("DZA", country.ISO3Code); + Assert.Equal("+213", country.CallingCode); + } + +} diff --git a/src/World.Net.UnitTests/GlobalUsing.cs b/src/World.Net.UnitTests/GlobalUsing.cs new file mode 100644 index 0000000..9e312a9 --- /dev/null +++ b/src/World.Net.UnitTests/GlobalUsing.cs @@ -0,0 +1 @@ +global using World.Net.Helpers; \ No newline at end of file diff --git a/src/World.Net/Countries/Algeria.cs b/src/World.Net/Countries/Algeria.cs new file mode 100644 index 0000000..a97530a --- /dev/null +++ b/src/World.Net/Countries/Algeria.cs @@ -0,0 +1,95 @@ +// Copyright (c) Raphael Anyanwu. All rights reserved. +// Licensed under the MIT License. +namespace World.Net.Countries; + +internal sealed class Algeria : ICountry +{ + /// + public int Id => CountryIdentifier.Algeria; + + /// + public string Name => nameof(Algeria); + + /// + public string OfficialName { get; } = "People's Democratic Republic of Algeria"; + + /// + public string NativeName { get; } = "الجزائر"; + + /// + public string Capital { get; } = "Algiers"; + + /// + public int NumericCode { get; } = 012; + + /// + public string ISO2Code { get; } = "DZ"; + + /// + public string ISO3Code { get; } = "DZA"; + + /// + public string CallingCode { get; } = "+213"; + + /// + public IEnumerable States { get; } = + [ + new("Adrar", "DZ-01"), + new("Aïn Defla", "DZ-44"), + new("Aïn Témouchent", "DZ-46"), + new("Algiers", "DZ-16"), + new("Annaba", "DZ-23"), + new("Batna", "DZ-05"), + new("Béchar", "DZ-08"), + new("Béjaïa", "DZ-06"), + new("Béni Abbès", "DZ-52"), + new("Biskra", "DZ-07"), + new("Blida", "DZ-09"), + new("Bordj Badji Mokhtar", "DZ-50"), + new("Bordj Bou Arréridj", "DZ-34"), + new("Bouira", "DZ-10"), + new("Boumerdès", "DZ-35"), + new("Chlef", "DZ-02"), + new("Constantine", "DZ-25"), + new("Djanet", "DZ-56"), + new("Djelfa", "DZ-17"), + new("El Bayadh", "DZ-32"), + new("El Meniaa", "DZ-58"), + new("El M’Ghair", "DZ-57"), + new("El Oued", "DZ-39"), + new("El Tarf", "DZ-36"), + new("Ghardaïa", "DZ-47"), + new("Guelma", "DZ-24"), + new("Illizi", "DZ-33"), + new("In Guezzam", "DZ-54"), + new("In Salah", "DZ-53"), + new("Jijel", "DZ-18"), + new("Khenchela", "DZ-40"), + new("Laghouat", "DZ-03"), + new("Médéa", "DZ-26"), + new("Mascara", "DZ-29"), + new("Mila", "DZ-43"), + new("Mostaganem", "DZ-27"), + new("M’Sila", "DZ-28"), + new("Naâma", "DZ-45"), + new("Oran", "DZ-31"), + new("Ouargla", "DZ-30"), + new("Ouled Djellal", "DZ-51"), + new("Relizane", "DZ-48"), + new("Saïda", "DZ-20"), + new("Sétif", "DZ-19"), + new("Sidi Bel Abbès", "DZ-22"), + new("Skikda", "DZ-21"), + new("Souk Ahras", "DZ-41"), + new("Tamanghasset", "DZ-11"), + new("Tébessa", "DZ-12"), + new("Tiaret", "DZ-14"), + new("Tindouf", "DZ-37"), + new("Tipaza", "DZ-42"), + new("Tissemsilt", "DZ-38"), + new("Tizi Ouzou", "DZ-15"), + new("Tlemcen", "DZ-13"), + new("Timimoun", "DZ-49"), + new("Touggourt", "DZ-55") + ]; +} diff --git a/src/World.Net/Helpers/CountryIdentifier.cs b/src/World.Net/Helpers/CountryIdentifier.cs index bb49016..8376690 100644 --- a/src/World.Net/Helpers/CountryIdentifier.cs +++ b/src/World.Net/Helpers/CountryIdentifier.cs @@ -25,4 +25,11 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Aland Islands in operations that require a country ID. /// public static readonly int AlandIslands = 2; + /// + /// The unique identifier for Algeria. + /// + /// + /// Use this identifier to reference Algeria in operations that require a country ID. + /// + public static readonly int Algeria = 4; } diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index d4ad293..f3749f8 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -7,7 +7,8 @@ public static Dictionary Initialize() return new Dictionary { { CountryIdentifier.AfghanistanId, new Afghanistan() }, - { CountryIdentifier.AlandIslands, new AlandIslands() } + { CountryIdentifier.AlandIslands, new AlandIslands() }, + { CountryIdentifier.Algeria, new Algeria() } // Future countries can be added here in the same format. }; } From d308b1ad3c4351920672617c16e168b17f6307f2 Mon Sep 17 00:00:00 2001 From: deanology Date: Sat, 25 Jan 2025 15:08:44 +0100 Subject: [PATCH 04/15] Algeria and American Samao country details --- src/World.Net/Countries/AmericanSamoa.cs | 38 +++++++++++++++++++++ src/World.Net/Helpers/CountryIdentifier.cs | 7 ++++ src/World.Net/Helpers/CountryInitializer.cs | 3 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/World.Net/Countries/AmericanSamoa.cs diff --git a/src/World.Net/Countries/AmericanSamoa.cs b/src/World.Net/Countries/AmericanSamoa.cs new file mode 100644 index 0000000..d3e73ff --- /dev/null +++ b/src/World.Net/Countries/AmericanSamoa.cs @@ -0,0 +1,38 @@ +// Copyright (c) Raphael Anyanwu. All rights reserved. +// Licensed under the MIT License. +namespace World.Net.Countries; + +internal sealed class AmericanSamoa : ICountry +{ + /// + public int Id => CountryIdentifier.AmericanSamoa; + + /// + public string Name => "American Samoa"; + + /// + public string OfficialName { get; } = "American Samoa"; + + /// + public string NativeName { get; } = "American Samoa"; + + /// + public string Capital { get; } = "Pago Pago"; + + /// + public int NumericCode { get; } = 016; + + /// + public string ISO2Code { get; } = "AS"; + + /// + public string ISO3Code { get; } = "ASM"; + + /// + public string CallingCode { get; } = "+1"; + + /// + public IEnumerable States { get; } = + [ + ]; +} diff --git a/src/World.Net/Helpers/CountryIdentifier.cs b/src/World.Net/Helpers/CountryIdentifier.cs index 8376690..3af29e1 100644 --- a/src/World.Net/Helpers/CountryIdentifier.cs +++ b/src/World.Net/Helpers/CountryIdentifier.cs @@ -32,4 +32,11 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Algeria in operations that require a country ID. /// public static readonly int Algeria = 4; + /// + /// The unique identifier for American Samoa. + /// + /// + /// Use this identifier to reference American Samoa in operations that require a country ID. + /// + public static readonly int AmericanSamoa = 5; } diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index f3749f8..6e087fa 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -8,7 +8,8 @@ public static Dictionary Initialize() { { CountryIdentifier.AfghanistanId, new Afghanistan() }, { CountryIdentifier.AlandIslands, new AlandIslands() }, - { CountryIdentifier.Algeria, new Algeria() } + { CountryIdentifier.Algeria, new Algeria() }, + { CountryIdentifier.AmericanSamoa, new AmericanSamoa() }, // Future countries can be added here in the same format. }; } From 1962f2a9e47c3cb3ecaecdb17ef5130e9c854a82 Mon Sep 17 00:00:00 2001 From: deanology Date: Sat, 25 Jan 2025 15:29:17 +0100 Subject: [PATCH 05/15] resolved merge conflict --- src/World.Net/Helpers/CountryIdentifier.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/World.Net/Helpers/CountryIdentifier.cs b/src/World.Net/Helpers/CountryIdentifier.cs index 5a54563..d03f916 100644 --- a/src/World.Net/Helpers/CountryIdentifier.cs +++ b/src/World.Net/Helpers/CountryIdentifier.cs @@ -25,7 +25,6 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Aland Islands in operations that require a country ID. /// public static readonly int AlandIslands = 2; - /// /// The unique identifier for Albania. /// @@ -33,7 +32,6 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Albania in operations that require a country ID. /// public static readonly int Albania = 3; - /// /// The unique identifier for Algeria. /// @@ -48,7 +46,6 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference American Samoa in operations that require a country ID. /// public static readonly int AmericanSamoa = 5; - /// /// The unique identifier for Andorra. /// From c30bb4874e396267e4de1139d60df94e1165f9d6 Mon Sep 17 00:00:00 2001 From: deanology Date: Sat, 25 Jan 2025 21:41:50 +0100 Subject: [PATCH 06/15] Modified Algeria Unit test to the new approach --- .../Countries/AlgeriaTest.cs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/AlgeriaTest.cs b/src/World.Net.UnitTests/Countries/AlgeriaTest.cs index 65df56b..e8205d4 100644 --- a/src/World.Net.UnitTests/Countries/AlgeriaTest.cs +++ b/src/World.Net.UnitTests/Countries/AlgeriaTest.cs @@ -2,6 +2,14 @@ public sealed class AlgeriaTest { + private const string ALGERIA_NAME = "Algeria"; + private const string ALGERIA_OFFICIAL_NAME = "People's Democratic Republic of Algeria"; + private const string ALGERIA_NATIVE_NAME = "الجزائر"; + private const string ALGERIA_CAPITAL = "Algiers"; + private const int ALGERIA_NUMERIC_CODE = 012; + private const string ALGERIA_ISO2_CODE = "DZ"; + private const string ALGERIA_ISO3_CODE = "DZA"; + private const string ALGERIA_CALLING_CODE = "+213"; [Fact] public void Algeria_HasExpectedInformation() { @@ -12,15 +20,14 @@ public void Algeria_HasExpectedInformation() var country = CountryProvider.GetCountry(existingCountryId); //Assert - Assert.Equal(4, country.Id); - Assert.Equal("Algeria", country.Name); - Assert.Equal("People's Democratic Republic of Algeria", country.OfficialName); - Assert.Equal("الجزائر", country.NativeName); - Assert.Equal("Algiers", country.Capital); - Assert.Equal(12, country.NumericCode); - Assert.Equal("DZ", country.ISO2Code); - Assert.Equal("DZA", country.ISO3Code); - Assert.Equal("+213", country.CallingCode); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(ALGERIA_NAME, country.Name); + Assert.Equal(ALGERIA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(ALGERIA_NATIVE_NAME, country.NativeName); + Assert.Equal(ALGERIA_CAPITAL, country.Capital); + Assert.Equal(ALGERIA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(ALGERIA_ISO2_CODE, country.ISO2Code); + Assert.Equal(ALGERIA_ISO3_CODE, country.ISO3Code); + Assert.Equal(ALGERIA_CALLING_CODE, country.CallingCode); } - } From 36f06a708eb85ae5c06f45ce8bc1bff6e0fe59e3 Mon Sep 17 00:00:00 2001 From: deanology Date: Sat, 25 Jan 2025 23:27:43 +0100 Subject: [PATCH 07/15] Andorra country details --- .../Countries/AndorraTest.cs | 33 ++++++++++++++ src/World.Net/Countries/Andorra.cs | 45 +++++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 1 + 3 files changed, 79 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/AndorraTest.cs create mode 100644 src/World.Net/Countries/Andorra.cs diff --git a/src/World.Net.UnitTests/Countries/AndorraTest.cs b/src/World.Net.UnitTests/Countries/AndorraTest.cs new file mode 100644 index 0000000..aabca7c --- /dev/null +++ b/src/World.Net.UnitTests/Countries/AndorraTest.cs @@ -0,0 +1,33 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class AndorraTest +{ + private const string ANDORRA_NAME = "Andorra"; + private const string ANDORRA_OFFICIAL_NAME = "Principality of Andorra"; + private const string ANDORRA_NATIVE_NAME ="Andorra"; + private const string ANDORRA_CAPITAL = "Andorra la Vella"; + private const int ANDORRA_NUMERIC_CODE = 020; + private const string ANDORRA_ISO2_CODE = "AD"; + private const string ANDORRA_ISO3_CODE = "AND"; + private const string ANDORRA_CALLING_CODE = "+376"; + [Fact] + public void Andorra_HasExpectedInformation() + { + // Arrange + int existingCountryId = CountryIdentifier.Andorra; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(ANDORRA_NAME, country.Name); + Assert.Equal(ANDORRA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(ANDORRA_NATIVE_NAME, country.NativeName); + Assert.Equal(ANDORRA_CAPITAL, country.Capital); + Assert.Equal(ANDORRA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(ANDORRA_ISO2_CODE, country.ISO2Code); + Assert.Equal(ANDORRA_ISO3_CODE, country.ISO3Code); + Assert.Equal(ANDORRA_CALLING_CODE, country.CallingCode); + } +} diff --git a/src/World.Net/Countries/Andorra.cs b/src/World.Net/Countries/Andorra.cs new file mode 100644 index 0000000..4226322 --- /dev/null +++ b/src/World.Net/Countries/Andorra.cs @@ -0,0 +1,45 @@ +// Copyright (c) Raphael Anyanwu. All rights reserved. +// Licensed under the MIT License. +namespace World.Net.Countries; + +internal sealed class Andorra : ICountry +{ + /// + public int Id => CountryIdentifier.Andorra; + + /// + public string Name => nameof(Andorra); + + /// + public string OfficialName { get; } = "Principality of Andorra"; + + /// + public string NativeName { get; } = "Andorra"; + + /// + public string Capital { get; } = "Andorra la Vella"; + + /// + public int NumericCode { get; } = 020; + + /// + public string ISO2Code { get; } = "AD"; + + /// + public string ISO3Code { get; } = "AND"; + + /// + public string CallingCode { get; } = "+376"; + + /// + public IEnumerable States { get; } = + [ + new("Canillo", "AD-02", "Parish"), + new("Encamp", "AD-03", "Parish"), + new("Ordino", "AD-04", "Parish"), + new("La Massana", "AD-05", "Parish"), + new("Andorra la Vella", "AD-07", "Parish"), + new("Sant Julià de Lòria", "AD-06", "Parish"), + new("Escaldes-Engordany", "AD-08", "Parish"), + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 6e087fa..c8f3b46 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -10,6 +10,7 @@ public static Dictionary Initialize() { CountryIdentifier.AlandIslands, new AlandIslands() }, { CountryIdentifier.Algeria, new Algeria() }, { CountryIdentifier.AmericanSamoa, new AmericanSamoa() }, + { CountryIdentifier.Andorra, new Andorra() }, // Future countries can be added here in the same format. }; } From 60bea809ed3a065ea12cc942a14ea7a7038147f0 Mon Sep 17 00:00:00 2001 From: deanology Date: Mon, 27 Jan 2025 13:47:50 +0100 Subject: [PATCH 08/15] PR Comments addressed --- .../Countries/AlgeriaTest.cs | 6 +++ .../Countries/AmericanSamoa.cs | 37 +++++++++++++++++++ .../Countries/AndorraTest.cs | 6 +++ src/World.Net/Helpers/CountryIdentifier.cs | 5 +++ 4 files changed, 54 insertions(+) create mode 100644 src/World.Net.UnitTests/Countries/AmericanSamoa.cs diff --git a/src/World.Net.UnitTests/Countries/AlgeriaTest.cs b/src/World.Net.UnitTests/Countries/AlgeriaTest.cs index e8205d4..3cf3d09 100644 --- a/src/World.Net.UnitTests/Countries/AlgeriaTest.cs +++ b/src/World.Net.UnitTests/Countries/AlgeriaTest.cs @@ -10,6 +10,9 @@ public sealed class AlgeriaTest private const string ALGERIA_ISO2_CODE = "DZ"; private const string ALGERIA_ISO3_CODE = "DZA"; private const string ALGERIA_CALLING_CODE = "+213"; + private const int ALGERIA_PROVINCE_COUNT = 57; + private const string ALGERIA_STATE_TYPE = "Province"; + [Fact] public void Algeria_HasExpectedInformation() { @@ -29,5 +32,8 @@ public void Algeria_HasExpectedInformation() Assert.Equal(ALGERIA_ISO2_CODE, country.ISO2Code); Assert.Equal(ALGERIA_ISO3_CODE, country.ISO3Code); Assert.Equal(ALGERIA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(ALGERIA_PROVINCE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Equal(ALGERIA_STATE_TYPE, state.Type)); } } diff --git a/src/World.Net.UnitTests/Countries/AmericanSamoa.cs b/src/World.Net.UnitTests/Countries/AmericanSamoa.cs new file mode 100644 index 0000000..a594e08 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/AmericanSamoa.cs @@ -0,0 +1,37 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class AmericanSamoaTest +{ + private const string AmericanSamoa_NAME = "American Samoa"; + private const string AmericanSamoa_OFFICIAL_NAME = "American Samoa"; + private const string AmericanSamoa_NATIVE_NAME ="American Samoa"; + private const string AmericanSamoa_CAPITAL = "Pago Pago"; + private const int AmericanSamoa_NUMERIC_CODE = 016; + private const string AmericanSamoa_ISO2_CODE = "AS"; + private const string AmericanSamoa_ISO3_CODE = "ASM"; + private const string AmericanSamoa_CALLING_CODE = "+1"; + private const int AmericanSamoa_STATE_COUNT = 0; + + [Fact] + public void AmericanSamoa_HasExpectedInformation() + { + // Arrange + int existingCountryId = CountryIdentifier.AmericanSamoa; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(AmericanSamoa_NAME, country.Name); + Assert.Equal(AmericanSamoa_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(AmericanSamoa_NATIVE_NAME, country.NativeName); + Assert.Equal(AmericanSamoa_CAPITAL, country.Capital); + Assert.Equal(AmericanSamoa_NUMERIC_CODE, country.NumericCode); + Assert.Equal(AmericanSamoa_ISO2_CODE, country.ISO2Code); + Assert.Equal(AmericanSamoa_ISO3_CODE, country.ISO3Code); + Assert.Equal(AmericanSamoa_CALLING_CODE, country.CallingCode); + Assert.Empty(country.States); + Assert.Equal(AmericanSamoa_STATE_COUNT, country.States.Count()); + } +} diff --git a/src/World.Net.UnitTests/Countries/AndorraTest.cs b/src/World.Net.UnitTests/Countries/AndorraTest.cs index aabca7c..031ec38 100644 --- a/src/World.Net.UnitTests/Countries/AndorraTest.cs +++ b/src/World.Net.UnitTests/Countries/AndorraTest.cs @@ -10,6 +10,9 @@ public sealed class AndorraTest private const string ANDORRA_ISO2_CODE = "AD"; private const string ANDORRA_ISO3_CODE = "AND"; private const string ANDORRA_CALLING_CODE = "+376"; + private const int ANDORRA_PARISH_COUNT = 7; + private const string ANDORRA_STATE_TYPE = "Parish"; + [Fact] public void Andorra_HasExpectedInformation() { @@ -29,5 +32,8 @@ public void Andorra_HasExpectedInformation() Assert.Equal(ANDORRA_ISO2_CODE, country.ISO2Code); Assert.Equal(ANDORRA_ISO3_CODE, country.ISO3Code); Assert.Equal(ANDORRA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(ANDORRA_PARISH_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Equal(ANDORRA_STATE_TYPE, state.Type)); } } diff --git a/src/World.Net/Helpers/CountryIdentifier.cs b/src/World.Net/Helpers/CountryIdentifier.cs index d03f916..b0115fc 100644 --- a/src/World.Net/Helpers/CountryIdentifier.cs +++ b/src/World.Net/Helpers/CountryIdentifier.cs @@ -18,6 +18,7 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Afghanistan in operations that require a country ID. /// public static readonly int AfghanistanId = 1; + /// /// The unique identifier for Aland Islands. /// @@ -25,6 +26,7 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Aland Islands in operations that require a country ID. /// public static readonly int AlandIslands = 2; + /// /// The unique identifier for Albania. /// @@ -32,6 +34,7 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Albania in operations that require a country ID. /// public static readonly int Albania = 3; + /// /// The unique identifier for Algeria. /// @@ -39,6 +42,7 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference Algeria in operations that require a country ID. /// public static readonly int Algeria = 4; + /// /// The unique identifier for American Samoa. /// @@ -46,6 +50,7 @@ public sealed partial class CountryIdentifier /// Use this identifier to reference American Samoa in operations that require a country ID. /// public static readonly int AmericanSamoa = 5; + /// /// The unique identifier for Andorra. /// From 95ced880186b734fd1cc92feaafce531cec91f0c Mon Sep 17 00:00:00 2001 From: deanology Date: Mon, 27 Jan 2025 21:53:01 +0100 Subject: [PATCH 09/15] resolved merge conflict --- src/World.Net/Helpers/CountryInitializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 36fd4ce..f940674 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -8,10 +8,10 @@ public static Dictionary Initialize() { { CountryIdentifier.AfghanistanId, new Afghanistan() }, { CountryIdentifier.AlandIslands, new AlandIslands() }, + { CountryIdentifier.Albania, new Albania() }, { CountryIdentifier.Algeria, new Algeria() }, { CountryIdentifier.AmericanSamoa, new AmericanSamoa() }, { CountryIdentifier.Andorra, new Andorra() }, - { CountryIdentifier.Albania, new Albania() } // Future countries can be added here in the same format. }; } From 4b999651e536cb2d09908bb84cc23fea917820cb Mon Sep 17 00:00:00 2001 From: deanology Date: Tue, 28 Jan 2025 11:20:58 +0100 Subject: [PATCH 10/15] Removed unnecessary test case --- src/World.Net.UnitTests/Countries/AmericanSamoa.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/World.Net.UnitTests/Countries/AmericanSamoa.cs b/src/World.Net.UnitTests/Countries/AmericanSamoa.cs index a594e08..03a0822 100644 --- a/src/World.Net.UnitTests/Countries/AmericanSamoa.cs +++ b/src/World.Net.UnitTests/Countries/AmericanSamoa.cs @@ -32,6 +32,5 @@ public void AmericanSamoa_HasExpectedInformation() Assert.Equal(AmericanSamoa_ISO3_CODE, country.ISO3Code); Assert.Equal(AmericanSamoa_CALLING_CODE, country.CallingCode); Assert.Empty(country.States); - Assert.Equal(AmericanSamoa_STATE_COUNT, country.States.Count()); } } From e32c778fdc9b0eb091b569df0655842288b717e4 Mon Sep 17 00:00:00 2001 From: deanology Date: Fri, 31 Jan 2025 18:22:53 +0100 Subject: [PATCH 11/15] added details for Bangladesh, Barbados and Belarus --- .../Countries/ArgentinaTest.cs | 2 +- .../Countries/ArmeniaTest.cs | 2 +- .../Countries/BangladeshTest.cs | 39 +++++++++++++++ .../Countries/BarbadosTest.cs | 39 +++++++++++++++ .../Countries/BelarusTest.cs | 37 +++++++++++++++ src/World.Net/Countries/Bangladesh.cs | 44 +++++++++++++++++ src/World.Net/Countries/Barbados.cs | 47 +++++++++++++++++++ src/World.Net/Countries/Belarus.cs | 43 +++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 5 +- 9 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 src/World.Net.UnitTests/Countries/BangladeshTest.cs create mode 100644 src/World.Net.UnitTests/Countries/BarbadosTest.cs create mode 100644 src/World.Net.UnitTests/Countries/BelarusTest.cs create mode 100644 src/World.Net/Countries/Bangladesh.cs create mode 100644 src/World.Net/Countries/Barbados.cs create mode 100644 src/World.Net/Countries/Belarus.cs diff --git a/src/World.Net.UnitTests/Countries/ArgentinaTest.cs b/src/World.Net.UnitTests/Countries/ArgentinaTest.cs index ce01c1e..766a72d 100644 --- a/src/World.Net.UnitTests/Countries/ArgentinaTest.cs +++ b/src/World.Net.UnitTests/Countries/ArgentinaTest.cs @@ -1,6 +1,6 @@ namespace World.Net.UnitTests.Countries; -public sealed class ARGENTINATest +public sealed class ArgentinaTest { private const string ARGENTINA_NAME = "Argentina"; private const int ARGENTINA_STATE_COUNT = 24; diff --git a/src/World.Net.UnitTests/Countries/ArmeniaTest.cs b/src/World.Net.UnitTests/Countries/ArmeniaTest.cs index f9c7e8f..c5d2c8a 100644 --- a/src/World.Net.UnitTests/Countries/ArmeniaTest.cs +++ b/src/World.Net.UnitTests/Countries/ArmeniaTest.cs @@ -1,6 +1,6 @@ namespace World.Net.UnitTests.Countries; -public sealed class ARMENIATest +public sealed class ArmeniaTest { private const string ARMENIA_NAME = "Armenia"; private const int ARMENIA_STATE_COUNT = 11; diff --git a/src/World.Net.UnitTests/Countries/BangladeshTest.cs b/src/World.Net.UnitTests/Countries/BangladeshTest.cs new file mode 100644 index 0000000..63d0654 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/BangladeshTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class BangladeshTest +{ + private const string BANGLADESH_NAME = "Bangladesh"; + private const string BANGLADESH_OFFICIAL_NAME = "People's Republic of Bangladesh"; + private const string BANGLADESH_NATIVE_NAME = "Bangladesh"; + private const string BANGLADESH_CAPITAL = "Dhaka"; + private const int BANGLADESH_NUMERIC_CODE = 050; + private const string BANGLADESH_ISO2_CODE = "BD"; + private const string BANGLADESH_ISO3_CODE = "BGD"; + private const string BANGLADESH_CALLING_CODE = "+880"; + private const int BANGLADESH_DIVISION_COUNT = 8; + private const string BANGLADESH_STATE_TYPE = "Division"; + + [Fact] + public void Bangladesh_HasExpectedInformation() + { + // Arrange + int existingCountryId = CountryIdentifier.Bangladesh; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(BANGLADESH_NAME, country.Name); + Assert.Equal(BANGLADESH_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(BANGLADESH_NATIVE_NAME, country.NativeName); + Assert.Equal(BANGLADESH_CAPITAL, country.Capital); + Assert.Equal(BANGLADESH_NUMERIC_CODE, country.NumericCode); + Assert.Equal(BANGLADESH_ISO2_CODE, country.ISO2Code); + Assert.Equal(BANGLADESH_ISO3_CODE, country.ISO3Code); + Assert.Equal(BANGLADESH_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(BANGLADESH_DIVISION_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Equal(BANGLADESH_STATE_TYPE, state.Type)); + } +} diff --git a/src/World.Net.UnitTests/Countries/BarbadosTest.cs b/src/World.Net.UnitTests/Countries/BarbadosTest.cs new file mode 100644 index 0000000..9bfe976 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/BarbadosTest.cs @@ -0,0 +1,39 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class BarbadosTest +{ + private const string BARBADOS_NAME = "Barbados"; + private const string BARBADOS_OFFICIAL_NAME = "Barbados"; + private const string BARBADOS_NATIVE_NAME = "Barbados"; + private const string BARBADOS_CAPITAL = "Bridgetown"; + private const int BARBADOS_NUMERIC_CODE = 052; + private const string BARBADOS_ISO2_CODE = "BB"; + private const string BARBADOS_ISO3_CODE = "BRB"; + private const string BARBADOS_CALLING_CODE = "+1-246"; + private const int BARBADOS_PARISH_COUNT = 11; + private const string BARBADOS_STATE_TYPE = "Parish"; + + [Fact] + public void Barbados_HasExpectedInformation() + { + // Arrange + int existingCountryId = CountryIdentifier.Barbados; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(BARBADOS_NAME, country.Name); + Assert.Equal(BARBADOS_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(BARBADOS_NATIVE_NAME, country.NativeName); + Assert.Equal(BARBADOS_CAPITAL, country.Capital); + Assert.Equal(BARBADOS_NUMERIC_CODE, country.NumericCode); + Assert.Equal(BARBADOS_ISO2_CODE, country.ISO2Code); + Assert.Equal(BARBADOS_ISO3_CODE, country.ISO3Code); + Assert.Equal(BARBADOS_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(BARBADOS_PARISH_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Equal(BARBADOS_STATE_TYPE, state.Type)); + } +} diff --git a/src/World.Net.UnitTests/Countries/BelarusTest.cs b/src/World.Net.UnitTests/Countries/BelarusTest.cs new file mode 100644 index 0000000..458fd24 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/BelarusTest.cs @@ -0,0 +1,37 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class BelarusTest +{ + private const string BELARUS_NAME = "Belarus"; + private const string BELARUS_OFFICIAL_NAME = "Republic of Belarus"; + private const string BELARUS_NATIVE_NAME = "Беларусь"; + private const string BELARUS_CAPITAL = "Minsk"; + private const int BELARUS_NUMERIC_CODE = 112; + private const string BELARUS_ISO2_CODE = "BY"; + private const string BELARUS_ISO3_CODE = "BLR"; + private const string BELARUS_CALLING_CODE = "+375"; + private const int BELARUS_PARISH_COUNT = 7; + + [Fact] + public void Belarus_HasExpectedInformation() + { + // Arrange + int existingCountryId = CountryIdentifier.Belarus; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + //Assert + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(BELARUS_NAME, country.Name); + Assert.Equal(BELARUS_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(BELARUS_NATIVE_NAME, country.NativeName); + Assert.Equal(BELARUS_CAPITAL, country.Capital); + Assert.Equal(BELARUS_NUMERIC_CODE, country.NumericCode); + Assert.Equal(BELARUS_ISO2_CODE, country.ISO2Code); + Assert.Equal(BELARUS_ISO3_CODE, country.ISO3Code); + Assert.Equal(BELARUS_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(BELARUS_PARISH_COUNT, country.States.Count()); + } +} diff --git a/src/World.Net/Countries/Bangladesh.cs b/src/World.Net/Countries/Bangladesh.cs new file mode 100644 index 0000000..fdb984c --- /dev/null +++ b/src/World.Net/Countries/Bangladesh.cs @@ -0,0 +1,44 @@ +namespace World.Net.Countries; + +internal sealed class Bangladesh : ICountry +{ + /// + public int Id => CountryIdentifier.Bangladesh; + + /// + public string Name => nameof(Bangladesh); + + /// + public string OfficialName { get; } = "People's Republic of Bangladesh"; + + /// + public string NativeName { get; } = "Bangladesh"; + + /// + public string Capital { get; } = "Dhaka"; + + /// + public int NumericCode { get; } = 050; + + /// + public string ISO2Code { get; } = "BD"; + + /// + public string ISO3Code { get; } = "BGD"; + + /// + public string CallingCode { get; } = "+880"; + + /// + public IEnumerable States { get; } = + [ + new("Barisal", "BD-A", "Division"), + new("Chittagong", "BD-B", "Division"), + new("Dhaka", "BD-C", "Division"), + new("Khulna", "BD-D", "Division"), + new("Mymensingh", "BD-M", "Division"), + new("Rajshahi", "BD-E", "Division"), + new("Rangpur", "BD-F", "Division"), + new("Sylhet", "BD-G", "Division") + ]; +} diff --git a/src/World.Net/Countries/Barbados.cs b/src/World.Net/Countries/Barbados.cs new file mode 100644 index 0000000..4a082b3 --- /dev/null +++ b/src/World.Net/Countries/Barbados.cs @@ -0,0 +1,47 @@ +namespace World.Net.Countries; + +internal sealed class Barbados : ICountry +{ + /// + public int Id => CountryIdentifier.Barbados; + + /// + public string Name => nameof(Barbados); + + /// + public string OfficialName { get; } = "Barbados"; + + /// + public string NativeName { get; } = "Barbados"; + + /// + public string Capital { get; } = "Bridgetown"; + + /// + public int NumericCode { get; } = 052; + + /// + public string ISO2Code { get; } = "BB"; + + /// + public string ISO3Code { get; } = "BRB"; + + /// + public string CallingCode { get; } = "+1-246"; + + /// + public IEnumerable States { get; } = + [ + new("Christ Church", "BB-01", "Parish"), + new("Saint Andrew", "BB-02", "Parish"), + new("Saint George", "BB-03", "Parish"), + new("Saint James", "BB-04", "Parish"), + new("Saint John", "BB-05", "Parish"), + new("Saint Joseph", "BB-06", "Parish"), + new("Saint Lucy", "BB-07", "Parish"), + new("Saint Michael", "BB-08", "Parish"), + new("Saint Peter", "BB-09", "Parish"), + new("Saint Philip", "BB-10", "Parish"), + new("Saint Thomas", "BB-11", "Parish") + ]; +} diff --git a/src/World.Net/Countries/Belarus.cs b/src/World.Net/Countries/Belarus.cs new file mode 100644 index 0000000..5dee56d --- /dev/null +++ b/src/World.Net/Countries/Belarus.cs @@ -0,0 +1,43 @@ +namespace World.Net.Countries; + +internal sealed class Belarus : ICountry +{ + /// + public int Id => CountryIdentifier.Belarus; + + /// + public string Name => nameof(Belarus); + + /// + public string OfficialName { get; } = "Republic of Belarus"; + + /// + public string NativeName { get; } = "Беларусь"; + + /// + public string Capital { get; } = "Minsk"; + + /// + public int NumericCode { get; } = 112; + + /// + public string ISO2Code { get; } = "BY"; + + /// + public string ISO3Code { get; } = "BLR"; + + /// + public string CallingCode { get; } = "+375"; + + /// + public IEnumerable States { get; } = + [ + new("Brest", "BY-BR", "Region"), + new("Gomel", "BY-HO", "Region"), + new("Grodno", "BY-HR", "Region"), + new("Minsk", "BY-MI", "Region"), + new("Mogilev", "BY-MA", "Region"), + new("Vitebsk", "BY-VI", "Region"), + new("Minsk City", "BY-MN", "City") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 9f91c59..f6b949f 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -17,7 +17,10 @@ public static Dictionary Initialize() { CountryIdentifier.Argentina, new Argentina() }, { CountryIdentifier.Angola, new Angola() }, { CountryIdentifier.Anguilla, new Anguilla() }, - { CountryIdentifier.Antarctica, new Antarctica() } + { CountryIdentifier.Antarctica, new Antarctica() }, + { CountryIdentifier.Bangladesh, new Bangladesh() }, + { CountryIdentifier.Barbados, new Barbados() }, + { CountryIdentifier.Belarus, new Belarus() }, // Future countries can be added here in the same format. }; } From 93ae03d80f3032c3799faf74c7cf23d9e0f527f7 Mon Sep 17 00:00:00 2001 From: deanology Date: Tue, 4 Feb 2025 23:13:18 +0100 Subject: [PATCH 12/15] updated CountryInitializer.cs --- src/World.Net/Helpers/CountryInitializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index c2168b6..4810b30 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -23,7 +23,7 @@ public static Dictionary Initialize() { CountryIdentifier.Austria, new Austria() }, { CountryIdentifier.Azerbaijan, new Azerbaijan() }, { CountryIdentifier.Bahamas, new TheBahamas() }, - { CountryIdentifier.Bahrain, new Bahrain() } + { CountryIdentifier.Bahrain, new Bahrain() }, { CountryIdentifier.Bangladesh, new Bangladesh() }, { CountryIdentifier.Barbados, new Barbados() }, { CountryIdentifier.Belarus, new Belarus() }, From d00bf9b629a95631dfb3d4aad67779696032e5b0 Mon Sep 17 00:00:00 2001 From: deanology Date: Mon, 17 Feb 2025 22:28:34 +0100 Subject: [PATCH 13/15] Added country information for Burundi, Cambodia, Canada, Cameroon and CapeVerde --- ...{AmericanSamoa.cs => AmericanSamoaTest.cs} | 0 .../Countries/BurundiTest.cs | 40 ++++++++++++ .../Countries/CambodiaTest.cs | 40 ++++++++++++ .../Countries/CameroonTest.cs | 40 ++++++++++++ .../Countries/CanadaTest.cs | 40 ++++++++++++ .../Countries/CapeVerdeTest.cs | 40 ++++++++++++ src/World.Net/Countries/Burundi.cs | 54 ++++++++++++++++ src/World.Net/Countries/Cambodia.cs | 61 +++++++++++++++++++ src/World.Net/Countries/Cameroon.cs | 46 ++++++++++++++ src/World.Net/Countries/Canada.cs | 49 +++++++++++++++ src/World.Net/Countries/CapeVerde.cs | 58 ++++++++++++++++++ src/World.Net/Helpers/CountryInitializer.cs | 7 ++- 12 files changed, 474 insertions(+), 1 deletion(-) rename src/World.Net.UnitTests/Countries/{AmericanSamoa.cs => AmericanSamoaTest.cs} (100%) create mode 100644 src/World.Net.UnitTests/Countries/BurundiTest.cs create mode 100644 src/World.Net.UnitTests/Countries/CambodiaTest.cs create mode 100644 src/World.Net.UnitTests/Countries/CameroonTest.cs create mode 100644 src/World.Net.UnitTests/Countries/CanadaTest.cs create mode 100644 src/World.Net.UnitTests/Countries/CapeVerdeTest.cs create mode 100644 src/World.Net/Countries/Burundi.cs create mode 100644 src/World.Net/Countries/Cambodia.cs create mode 100644 src/World.Net/Countries/Cameroon.cs create mode 100644 src/World.Net/Countries/Canada.cs create mode 100644 src/World.Net/Countries/CapeVerde.cs diff --git a/src/World.Net.UnitTests/Countries/AmericanSamoa.cs b/src/World.Net.UnitTests/Countries/AmericanSamoaTest.cs similarity index 100% rename from src/World.Net.UnitTests/Countries/AmericanSamoa.cs rename to src/World.Net.UnitTests/Countries/AmericanSamoaTest.cs diff --git a/src/World.Net.UnitTests/Countries/BurundiTest.cs b/src/World.Net.UnitTests/Countries/BurundiTest.cs new file mode 100644 index 0000000..cbf4796 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/BurundiTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class BurundiTest +{ + private const string BURUNDI_COUNTRY_NAME = "Burundi"; + private const string BURUNDI_NATIVE_NAME = "Uburundi"; + private const string BURUNDI_CAPITAL = "Gitega"; + private const string BURUNDI_OFFICIAL_NAME = "Republic of Burundi"; + private const string BURUNDI_ISO2_CODE = "BI"; + private const string BURUNDI_ISO3_CODE = "BDI"; + private const int BURUNDI_NUMERIC_CODE = 108; + private const string BURUNDI_CALLING_CODE = "+257"; + private const int BURUNDI_STATE_COUNT = 18; + private static readonly string[] VALID_STATE_TYPES = { "Province" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForBurundi() + { + // Arrange + int existingCountryId = CountryIdentifier.Burundi; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(BURUNDI_COUNTRY_NAME, country.Name); + Assert.Equal(BURUNDI_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(BURUNDI_NATIVE_NAME, country.NativeName); + Assert.Equal(BURUNDI_CAPITAL, country.Capital); + Assert.Equal(BURUNDI_NUMERIC_CODE, country.NumericCode); + Assert.Equal(BURUNDI_ISO2_CODE, country.ISO2Code); + Assert.Equal(BURUNDI_ISO3_CODE, country.ISO3Code); + Assert.Equal(BURUNDI_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(BURUNDI_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} diff --git a/src/World.Net.UnitTests/Countries/CambodiaTest.cs b/src/World.Net.UnitTests/Countries/CambodiaTest.cs new file mode 100644 index 0000000..154c04f --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CambodiaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CambodiaTest +{ + private const string CAMBODIA_COUNTRY_NAME = "Cambodia"; + private const string CAMBODIA_NATIVE_NAME = "កម្ពុជា"; + private const string CAMBODIA_CAPITAL = "Phnom Penh"; + private const string CAMBODIA_OFFICIAL_NAME = "Kingdom of Cambodia"; + private const string CAMBODIA_ISO2_CODE = "KH"; + private const string CAMBODIA_ISO3_CODE = "KHM"; + private const int CAMBODIA_NUMERIC_CODE = 116; + private const string CAMBODIA_CALLING_CODE = "+855"; + private const int CAMBODIA_STATE_COUNT = 25; + private static readonly string[] VALID_STATE_TYPES = { "Province", "Municipality" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCambodia() + { + // Arrange + int existingCountryId = CountryIdentifier.Cambodia; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CAMBODIA_COUNTRY_NAME, country.Name); + Assert.Equal(CAMBODIA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CAMBODIA_NATIVE_NAME, country.NativeName); + Assert.Equal(CAMBODIA_CAPITAL, country.Capital); + Assert.Equal(CAMBODIA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CAMBODIA_ISO2_CODE, country.ISO2Code); + Assert.Equal(CAMBODIA_ISO3_CODE, country.ISO3Code); + Assert.Equal(CAMBODIA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CAMBODIA_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} \ No newline at end of file diff --git a/src/World.Net.UnitTests/Countries/CameroonTest.cs b/src/World.Net.UnitTests/Countries/CameroonTest.cs new file mode 100644 index 0000000..dbee37b --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CameroonTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CameroonTest +{ + private const string CAMEROON_COUNTRY_NAME = "Cameroon"; + private const string CAMEROON_NATIVE_NAME = "République du Cameroun"; + private const string CAMEROON_CAPITAL = "Yaoundé"; + private const string CAMEROON_OFFICIAL_NAME = "Republic of Cameroon"; + private const string CAMEROON_ISO2_CODE = "CM"; + private const string CAMEROON_ISO3_CODE = "CMR"; + private const int CAMEROON_NUMERIC_CODE = 120; + private const string CAMEROON_CALLING_CODE = "+237"; + private const int CAMEROON_STATE_COUNT = 10; + private static readonly string[] VALID_STATE_TYPES = { "Region" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCameroon() + { + // Arrange + int existingCountryId = CountryIdentifier.Cameroon; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CAMEROON_COUNTRY_NAME, country.Name); + Assert.Equal(CAMEROON_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CAMEROON_NATIVE_NAME, country.NativeName); + Assert.Equal(CAMEROON_CAPITAL, country.Capital); + Assert.Equal(CAMEROON_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CAMEROON_ISO2_CODE, country.ISO2Code); + Assert.Equal(CAMEROON_ISO3_CODE, country.ISO3Code); + Assert.Equal(CAMEROON_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CAMEROON_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} \ No newline at end of file diff --git a/src/World.Net.UnitTests/Countries/CanadaTest.cs b/src/World.Net.UnitTests/Countries/CanadaTest.cs new file mode 100644 index 0000000..ae109fc --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CanadaTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CanadaTest +{ + private const string CANADA_COUNTRY_NAME = "Canada"; + private const string CANADA_NATIVE_NAME = "Canada"; + private const string CANADA_CAPITAL = "Ottawa"; + private const string CANADA_OFFICIAL_NAME = "Canada"; + private const string CANADA_ISO2_CODE = "CA"; + private const string CANADA_ISO3_CODE = "CAN"; + private const int CANADA_NUMERIC_CODE = 124; + private const string CANADA_CALLING_CODE = "+1"; + private const int CANADA_STATE_COUNT = 13; + private static readonly string[] VALID_STATE_TYPES = { "Province", "Territory" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCanada() + { + // Arrange + int existingCountryId = CountryIdentifier.Canada; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CANADA_COUNTRY_NAME, country.Name); + Assert.Equal(CANADA_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CANADA_NATIVE_NAME, country.NativeName); + Assert.Equal(CANADA_CAPITAL, country.Capital); + Assert.Equal(CANADA_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CANADA_ISO2_CODE, country.ISO2Code); + Assert.Equal(CANADA_ISO3_CODE, country.ISO3Code); + Assert.Equal(CANADA_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CANADA_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} \ No newline at end of file diff --git a/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs b/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs new file mode 100644 index 0000000..bbdd417 --- /dev/null +++ b/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs @@ -0,0 +1,40 @@ +namespace World.Net.UnitTests.Countries; + +public sealed class CapeVerdeTest +{ + private const string CAPEVERDE_COUNTRY_NAME = "Cape Verde"; + private const string CAPEVERDE_NATIVE_NAME = "Cabo Verde"; + private const string CAPEVERDE_CAPITAL = "Praia"; + private const string CAPEVERDE_OFFICIAL_NAME = "Republic of Cabo Verde"; + private const string CAPEVERDE_ISO2_CODE = "CV"; + private const string CAPEVERDE_ISO3_CODE = "CPV"; + private const int CAPEVERDE_NUMERIC_CODE = 132; + private const string CAPEVERDE_CALLING_CODE = "+238"; + private const int CAPEVERDE_STATE_COUNT = 22; + private static readonly string[] VALID_STATE_TYPES = { "Municipality" }; + + [Fact] + public void GetCountry_ReturnsCorrectInformation_ForCapeVerde() + { + // Arrange + int existingCountryId = CountryIdentifier.CapeVerde; + + // Act + var country = CountryProvider.GetCountry(existingCountryId); + + // Assert + Assert.NotNull(country); + Assert.Equal(existingCountryId, country.Id); + Assert.Equal(CAPEVERDE_COUNTRY_NAME, country.Name); + Assert.Equal(CAPEVERDE_OFFICIAL_NAME, country.OfficialName); + Assert.Equal(CAPEVERDE_NATIVE_NAME, country.NativeName); + Assert.Equal(CAPEVERDE_CAPITAL, country.Capital); + Assert.Equal(CAPEVERDE_NUMERIC_CODE, country.NumericCode); + Assert.Equal(CAPEVERDE_ISO2_CODE, country.ISO2Code); + Assert.Equal(CAPEVERDE_ISO3_CODE, country.ISO3Code); + Assert.Equal(CAPEVERDE_CALLING_CODE, country.CallingCode); + Assert.NotNull(country.States); + Assert.Equal(CAPEVERDE_STATE_COUNT, country.States.Count()); + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); + } +} \ No newline at end of file diff --git a/src/World.Net/Countries/Burundi.cs b/src/World.Net/Countries/Burundi.cs new file mode 100644 index 0000000..cdc8107 --- /dev/null +++ b/src/World.Net/Countries/Burundi.cs @@ -0,0 +1,54 @@ +namespace World.Net.Countries; + +internal sealed class Burundi : ICountry +{ + // + public int Id => CountryIdentifier.Burundi; + + // + public string Name { get; } = "Burundi"; + + // + public string OfficialName { get; } = "Republic of Burundi"; + + // + public string NativeName => "Uburundi"; + + // + public string Capital { get; } = "Gitega"; + + // + public int NumericCode { get; } = 108; + + // + public string ISO2Code { get; } = "BI"; + + // + public string ISO3Code { get; } = "BDI"; + + // + public string CallingCode { get; } = "+257"; + + // + public IEnumerable States => + [ + new("Bubanza", "BB"), + new("Bujumbura Mairie", "BM"), + new("Bujumbura Rural", "BR"), + new("Bururi", "BU"), + new("Cankuzo", "CA"), + new("Cibitoke", "CI"), + new("Gitega", "GI"), + new("Karuzi", "KR"), + new("Kayanza", "KY"), + new("Kirundo", "KI"), + new("Makamba", "MA"), + new("Muramvya", "MU"), + new("Muyinga", "MY"), + new("Mwaro", "MW"), + new("Ngozi", "NG"), + new("Rumonge", "RM"), + new("Rutana", "RT"), + new("Ruyigi", "RY") + ]; +} diff --git a/src/World.Net/Countries/Cambodia.cs b/src/World.Net/Countries/Cambodia.cs new file mode 100644 index 0000000..31d348e --- /dev/null +++ b/src/World.Net/Countries/Cambodia.cs @@ -0,0 +1,61 @@ +namespace World.Net.Countries; + +internal sealed class Cambodia : ICountry +{ + // + public int Id => CountryIdentifier.Cambodia; + + // + public string Name { get; } = "Cambodia"; + + // + public string OfficialName { get; } = "Kingdom of Cambodia"; + + // + public string NativeName => "កម\u17d2ព\u17bbជ\u17b6"; + + // + public string Capital { get; } = "Phnom Penh"; + + // + public int NumericCode { get; } = 116; + + // + public string ISO2Code { get; } = "KH"; + + // + public string ISO3Code { get; } = "KHM"; + + // + public string CallingCode { get; } = "+855"; + + // + public IEnumerable States => + [ + new("Banteay Meanchey", "1"), + new("Battambang", "2"), + new("Kampong Cham", "3"), + new("Kampong Chhnang", "4"), + new("Kampong Speu", "5"), + new("Kampong Thom", "6"), + new("Kampot", "7"), + new("Kandal", "8"), + new("Koh Kong", "9"), + new("Kratié", "10"), + new("Mondulkiri", "11"), + new("Phnom Penh", "12", "Municipality"), + new("Preah Vihear", "13"), + new("Prey Veng", "14"), + new("Pursat", "15"), + new("Ratanakiri", "16"), + new("Siem Reap", "17"), + new("Preah Sihanouk", "18"), + new("Stung Treng", "19"), + new("Svay Rieng", "20"), + new("Takéo", "21"), + new("Oddar Meanchey", "22"), + new("Kep", "23"), + new("Pailin", "24"), + new("Tbong Khmum", "25") + ]; +} diff --git a/src/World.Net/Countries/Cameroon.cs b/src/World.Net/Countries/Cameroon.cs new file mode 100644 index 0000000..40b337f --- /dev/null +++ b/src/World.Net/Countries/Cameroon.cs @@ -0,0 +1,46 @@ +namespace World.Net.Countries; + +internal sealed class Cameroon : ICountry +{ + // + public int Id => CountryIdentifier.Cameroon; + + // + public string Name { get; } = "Cameroon"; + + // + public string OfficialName { get; } = "Republic of Cameroon"; + + // + public string NativeName => "République du Cameroun"; + + // + public string Capital { get; } = "Yaoundé"; + + // + public int NumericCode { get; } = 120; + + // + public string ISO2Code { get; } = "CM"; + + // + public string ISO3Code { get; } = "CMR"; + + // + public string CallingCode { get; } = "+237"; + + // + public IEnumerable States => + [ + new("Adamawa", "AD", "Region"), + new("Centre", "CE", "Region"), + new("East", "ES", "Region"), + new("Far North", "FN", "Region"), + new("Littoral", "LT", "Region"), + new("North", "NO", "Region"), + new("North West", "NW", "Region"), + new("West", "OU", "Region"), + new("South", "SU", "Region"), + new("South West", "SW", "Region") + ]; +} diff --git a/src/World.Net/Countries/Canada.cs b/src/World.Net/Countries/Canada.cs new file mode 100644 index 0000000..8995085 --- /dev/null +++ b/src/World.Net/Countries/Canada.cs @@ -0,0 +1,49 @@ +namespace World.Net.Countries; + +internal sealed class Canada : ICountry +{ + // + public int Id => CountryIdentifier.Canada; + + // + public string Name { get; } = "Canada"; + + // + public string OfficialName { get; } = "Canada"; + + // + public string NativeName => "Canada"; + + // + public string Capital { get; } = "Ottawa"; + + // + public int NumericCode { get; } = 124; + + // + public string ISO2Code { get; } = "CA"; + + // + public string ISO3Code { get; } = "CAN"; + + // + public string CallingCode { get; } = "+1"; + + // + public IEnumerable States => + [ + new("Alberta", "AB"), + new("British Columbia", "BC"), + new("Manitoba", "MB"), + new("New Brunswick", "NB"), + new("Newfoundland and Labrador", "NL"), + new("Northwest Territories", "NT", "Territory"), + new("Nova Scotia", "NS"), + new("Nunavut", "NU", "Territory"), + new("Ontario", "ON"), + new("Prince Edward Island", "PE"), + new("Quebec", "QC"), + new("Saskatchewan", "SK"), + new("Yukon", "YT", "Territory") + ]; +} diff --git a/src/World.Net/Countries/CapeVerde.cs b/src/World.Net/Countries/CapeVerde.cs new file mode 100644 index 0000000..b2ba4d3 --- /dev/null +++ b/src/World.Net/Countries/CapeVerde.cs @@ -0,0 +1,58 @@ +namespace World.Net.Countries; + +internal sealed class CapeVerde : ICountry +{ + // + public int Id => CountryIdentifier.CapeVerde; + + // + public string Name { get; } = "Cape Verde"; + + // + public string OfficialName { get; } = "Republic of Cabo Verde"; + + // + public string NativeName => "Cabo Verde"; + + // + public string Capital { get; } = "Praia"; + + // + public int NumericCode { get; } = 132; + + // + public string ISO2Code { get; } = "CV"; + + // + public string ISO3Code { get; } = "CPV"; + + // + public string CallingCode { get; } = "+238"; + + // + public IEnumerable States => + [ + new("Boa Vista", "BV", "Municipality"), + new("Brava", "BR", "Municipality"), + new("Calheta de São Miguel", "CS", "Municipality"), + new("Maio", "MA", "Municipality"), + new("Mosteiros", "MO", "Municipality"), + new("Paul", "PA", "Municipality"), + new("Porto Novo", "PN", "Municipality"), + new("Praia", "PR", "Municipality"), + new("Ribeira Brava", "RB", "Municipality"), + new("Ribeira Grande", "RG", "Municipality"), + new("Ribeira Grande de Santiago", "RS", "Municipality"), + new("Sal", "SA", "Municipality"), + new("Santa Catarina", "SC", "Municipality"), + new("Santa Catarina do Fogo", "SF", "Municipality"), + new("Santa Cruz", "SZ", "Municipality"), + new("São Domingos", "SD", "Municipality"), + new("São Filipe", "SF", "Municipality"), + new("São Lourenço dos Órgãos", "SL", "Municipality"), + new("São Salvador do Mundo", "SM", "Municipality"), + new("São Vicente", "SV", "Municipality"), + new("Tarrafal", "TA", "Municipality"), + new("Tarrafal de São Nicolau", "TS", "Municipality") + ]; +} diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index bb68b38..f55ffe8 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -36,7 +36,12 @@ public static Dictionary Initialize() { CountryIdentifier.BosniaAndHerzegovina, new BosniaAndHerzegovina() }, { CountryIdentifier.Botswana, new Botswana() }, { CountryIdentifier.BouvetIsland, new BouvetIsland() }, - + { CountryIdentifier.Burundi, new Burundi() }, + { CountryIdentifier.Cambodia, new Cambodia() }, + { CountryIdentifier.Cameroon, new Cameroon() }, + { CountryIdentifier.Canada, new Canada() }, + { CountryIdentifier.CapeVerde, new CapeVerde() } + // Future countries can be added here in the same format. }; } From 884128bcb80fb49d53aacfb0bf23d4fbc2c4d4a8 Mon Sep 17 00:00:00 2001 From: deanology Date: Tue, 18 Feb 2025 11:19:06 +0100 Subject: [PATCH 14/15] added line space to test files --- src/World.Net.UnitTests/Countries/CambodiaTest.cs | 2 +- src/World.Net.UnitTests/Countries/CameroonTest.cs | 2 +- src/World.Net.UnitTests/Countries/CanadaTest.cs | 2 +- src/World.Net.UnitTests/Countries/CapeVerdeTest.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/World.Net.UnitTests/Countries/CambodiaTest.cs b/src/World.Net.UnitTests/Countries/CambodiaTest.cs index 154c04f..473f462 100644 --- a/src/World.Net.UnitTests/Countries/CambodiaTest.cs +++ b/src/World.Net.UnitTests/Countries/CambodiaTest.cs @@ -37,4 +37,4 @@ public void GetCountry_ReturnsCorrectInformation_ForCambodia() Assert.Equal(CAMBODIA_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); } -} \ No newline at end of file +} diff --git a/src/World.Net.UnitTests/Countries/CameroonTest.cs b/src/World.Net.UnitTests/Countries/CameroonTest.cs index dbee37b..7c0c28a 100644 --- a/src/World.Net.UnitTests/Countries/CameroonTest.cs +++ b/src/World.Net.UnitTests/Countries/CameroonTest.cs @@ -37,4 +37,4 @@ public void GetCountry_ReturnsCorrectInformation_ForCameroon() Assert.Equal(CAMEROON_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); } -} \ No newline at end of file +} diff --git a/src/World.Net.UnitTests/Countries/CanadaTest.cs b/src/World.Net.UnitTests/Countries/CanadaTest.cs index ae109fc..a893897 100644 --- a/src/World.Net.UnitTests/Countries/CanadaTest.cs +++ b/src/World.Net.UnitTests/Countries/CanadaTest.cs @@ -37,4 +37,4 @@ public void GetCountry_ReturnsCorrectInformation_ForCanada() Assert.Equal(CANADA_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); } -} \ No newline at end of file +} diff --git a/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs b/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs index bbdd417..193349d 100644 --- a/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs +++ b/src/World.Net.UnitTests/Countries/CapeVerdeTest.cs @@ -37,4 +37,4 @@ public void GetCountry_ReturnsCorrectInformation_ForCapeVerde() Assert.Equal(CAPEVERDE_STATE_COUNT, country.States.Count()); Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); } -} \ No newline at end of file +} From 1c5abb00038a6c3652b175f78f710cc72fdf66cd Mon Sep 17 00:00:00 2001 From: Raphael Anyanwu <53215747+selfmadecode@users.noreply.github.com> Date: Sat, 22 Feb 2025 09:56:47 +0100 Subject: [PATCH 15/15] fix missing comma --- src/World.Net/Helpers/CountryInitializer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/World.Net/Helpers/CountryInitializer.cs b/src/World.Net/Helpers/CountryInitializer.cs index 98bdc17..59acda1 100644 --- a/src/World.Net/Helpers/CountryInitializer.cs +++ b/src/World.Net/Helpers/CountryInitializer.cs @@ -40,7 +40,7 @@ public static Dictionary Initialize() { CountryIdentifier.Cambodia, new Cambodia() }, { CountryIdentifier.Cameroon, new Cameroon() }, { CountryIdentifier.Canada, new Canada() }, - { CountryIdentifier.CapeVerde, new CapeVerde() } + { CountryIdentifier.CapeVerde, new CapeVerde() }, { CountryIdentifier.Bulgaria, new Bulgaria() }, { CountryIdentifier.BurkinaFaso, new BurkinaFaso() }, { CountryIdentifier.Brazil, new Brazil() },