From 5e8cbd2e46f3654be4bd434f76a01b4588752b78 Mon Sep 17 00:00:00 2001 From: Trevor Pilley Date: Wed, 30 Oct 2024 12:48:41 +0000 Subject: [PATCH] Closes #694 Add a flag for NATO members and parse options --- README.md | 6 ++- src/PhoneNumbers/CountryInfo.cs | 5 +++ src/PhoneNumbers/CountryInfo_Asia.cs | 1 + src/PhoneNumbers/CountryInfo_Europe.cs | 28 ++++++++++++ src/PhoneNumbers/CountryInfo_NorthAmerica.cs | 2 + src/PhoneNumbers/ParseOptionsExtensions.cs | 9 ++++ .../CountryInfo_Africa_Tests.cs | 5 +++ .../CountryInfo_Asia_Tests.cs | 4 ++ .../CountryInfo_Europe_Tests.cs | 45 +++++++++++++++++++ .../CountryInfo_NorthAmerica_Tests.cs | 22 +++++++++ .../CountryInfo_Oceania_Tests.cs | 4 ++ .../CountryInfo_SouthAmerica_Tests.cs | 2 + test/PhoneNumbers.Tests/ParseOptionsTests.cs | 13 +++++- 13 files changed, 143 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3e2c7aea8..683429749 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ phoneNumber.Country.Continent; // Europe phoneNumber.Country.HasNationalDestinationCodes; // true phoneNumber.Country.HasTrunkPrefix; // true phoneNumber.Country.IsEuropeanUnionMember; // false +phoneNumber.Country.IsNatoMember; // true phoneNumber.Country.Iso3166Code; // GB phoneNumber.Country.Name; // United Kingdom phoneNumber.Country.SharesCallingCode; // true @@ -140,8 +141,9 @@ ParseOptions.Default.AllowNorthAmericanCountries(); ParseOptions.Default.AllowOceanianCountries(); ParseOptions.Default.AllowSouthAmericanCountries(); -// Add all countries supported by the library who are members of the same union: -ParseOptions.Default.AllowEuropeanUnionCountries(); +// Add all countries supported by the library who are members of the same union/alliance: +ParseOptions.Default.AllowEuropeanUnionCountries(); // all 27 members +ParseOptions.Default.AllowNatoCountries(); // 31 of 32 members (Albania not supported yet) // Add all countries supported by the library using the same numbering plan: ParseOptions.Default.AllowNorthAmericanNumberingPlanCountries(); diff --git a/src/PhoneNumbers/CountryInfo.cs b/src/PhoneNumbers/CountryInfo.cs index 4b429e146..a9dbefaab 100644 --- a/src/PhoneNumbers/CountryInfo.cs +++ b/src/PhoneNumbers/CountryInfo.cs @@ -69,6 +69,11 @@ internal CountryInfo() /// public bool IsEuropeanUnionMember { get; init; } + /// + /// Gets a value indicating whether the country is a member of the North Atlantic Treaty Organisation. + /// + public bool IsNatoMember { get; init; } + /// /// Gets the ISO 3166 Alpha-2 code for the country. /// diff --git a/src/PhoneNumbers/CountryInfo_Asia.cs b/src/PhoneNumbers/CountryInfo_Asia.cs index eebac5a91..fd5f80652 100644 --- a/src/PhoneNumbers/CountryInfo_Asia.cs +++ b/src/PhoneNumbers/CountryInfo_Asia.cs @@ -49,6 +49,7 @@ public partial class CountryInfo CallingCode = "90", Continent = Asia, FormatProvider = TRPhoneNumberFormatProvider.Instance, + IsNatoMember = true, Iso3166Code = "TR", Name = "Turkey", NdcLengths = new ReadOnlyCollection([3, 0]), diff --git a/src/PhoneNumbers/CountryInfo_Europe.cs b/src/PhoneNumbers/CountryInfo_Europe.cs index 150508951..fe223b3e0 100644 --- a/src/PhoneNumbers/CountryInfo_Europe.cs +++ b/src/PhoneNumbers/CountryInfo_Europe.cs @@ -44,6 +44,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = BEPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "BE", Name = "Belgium", NdcLengths = new ReadOnlyCollection([3, 2, 1]), @@ -74,6 +75,7 @@ public partial class CountryInfo CallingCode = "359", Continent = Europe, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "BG", Name = "Bulgaria", NdcLengths = new ReadOnlyCollection([3, 2, 1]), @@ -90,6 +92,7 @@ public partial class CountryInfo CallingCode = "385", Continent = Europe, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "HR", Name = "Croatia", NdcLengths = new ReadOnlyCollection([5, 4, 3, 2, 1]), @@ -121,6 +124,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = CZPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "CZ", Name = "Czech Republic", NdcLengths = new ReadOnlyCollection([3, 2, 1]), @@ -135,6 +139,7 @@ public partial class CountryInfo CallingCode = "45", Continent = Europe, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "DK", Name = "Denmark", NsnLengths = new ReadOnlyCollection([8, 12]), @@ -149,6 +154,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = BasicPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "EE", Name = "Estonia", NdcLengths = new ReadOnlyCollection([4, 3, 2]), @@ -164,6 +170,7 @@ public partial class CountryInfo CallingCode = "358", Continent = Europe, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "FI", Name = "Finland", NdcLengths = new ReadOnlyCollection([4, 3, 2, 1]), @@ -180,6 +187,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = FRPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "FR", Name = "France", NsnLengths = new ReadOnlyCollection([9, 13]), @@ -196,6 +204,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = SimplePhoneNumberFormatProvider.Default, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "DE", Name = "Germany", NdcLengths = new ReadOnlyCollection([5, 4, 3, 2]), @@ -226,6 +235,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = GRPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "GR", Name = "Greece", NdcLengths = new ReadOnlyCollection([4, 3, 2]), @@ -258,6 +268,7 @@ public partial class CountryInfo CallingCode = "36", Continent = Europe, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "HU", Name = "Hungary", NdcLengths = new ReadOnlyCollection([2, 1]), @@ -272,6 +283,7 @@ public partial class CountryInfo { CallingCode = "354", Continent = Europe, + IsNatoMember = true, Iso3166Code = "IS", Name = "Iceland", NsnLengths = new ReadOnlyCollection([7, 9]), @@ -321,6 +333,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = SimplePhoneNumberFormatProvider.Default, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "IT", Name = "Italy", NdcLengths = new ReadOnlyCollection([5, 4, 3, 2]), @@ -368,6 +381,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = BasicPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "LV", Name = "Latvia", NsnLengths = new ReadOnlyCollection([8]), @@ -382,6 +396,7 @@ public partial class CountryInfo CallingCode = "370", Continent = Europe, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "LT", Name = "Lithuania", NdcLengths = new ReadOnlyCollection([3, 2, 1]), @@ -398,6 +413,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = LUPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "LU", Name = "Luxembourg", NsnLengths = new ReadOnlyCollection([4, 5, 6, 7, 8, 9, 10, 11, 12]), @@ -452,6 +468,7 @@ public partial class CountryInfo { CallingCode = "382", Continent = Europe, + IsNatoMember = true, Iso3166Code = "ME", Name = "Montenegro", NdcLengths = new ReadOnlyCollection([2]), @@ -468,6 +485,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = NLPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "NL", Name = "Netherlands", NdcLengths = new ReadOnlyCollection([3, 2]), @@ -483,6 +501,7 @@ public partial class CountryInfo AllowsLocalGeographicDialling = true, CallingCode = "389", Continent = Europe, + IsNatoMember = true, Iso3166Code = "MK", Name = "North Macedonia", NdcLengths = new ReadOnlyCollection([3, 2, 1]), @@ -498,6 +517,7 @@ public partial class CountryInfo CallingCode = "47", Continent = Europe, FormatProvider = NOPhoneNumberFormatProvider.Instance, + IsNatoMember = true, Iso3166Code = "NO", Name = "Norway", NsnLengths = new ReadOnlyCollection([8, 12]), @@ -512,6 +532,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = PLPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "PL", Name = "Poland", NdcLengths = new ReadOnlyCollection([2]), @@ -526,6 +547,7 @@ public partial class CountryInfo CallingCode = "351", Continent = Europe, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "PT", Name = "Portugal", NdcLengths = new ReadOnlyCollection([3]), @@ -541,6 +563,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = ROPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "RO", Name = "Romania", NdcLengths = new ReadOnlyCollection([3, 2]), @@ -584,6 +607,7 @@ public partial class CountryInfo CallingCode = "421", Continent = Europe, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "SK", Name = "Slovakia", NdcLengths = new ReadOnlyCollection([4, 3, 2, 1]), @@ -601,6 +625,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = SLPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "SL", Name = "Slovenia", NdcLengths = new ReadOnlyCollection([4, 3, 2, 1]), @@ -617,6 +642,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = ESPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "ES", Name = "Spain", NdcLengths = new ReadOnlyCollection([3, 2]), @@ -633,6 +659,7 @@ public partial class CountryInfo Continent = Europe, FormatProvider = SEPhoneNumberFormatProvider.Instance, IsEuropeanUnionMember = true, + IsNatoMember = true, Iso3166Code = "SE", Name = "Sweden", NdcLengths = new ReadOnlyCollection([3, 2, 1]), @@ -681,6 +708,7 @@ public partial class CountryInfo CallingCode = "44", Continent = Europe, FormatProvider = GBPhoneNumberFormatProvider.Instance, + IsNatoMember = true, Iso3166Code = "GB", Name = "United Kingdom", NdcLengths = new ReadOnlyCollection([5, 4, 3, 2]), diff --git a/src/PhoneNumbers/CountryInfo_NorthAmerica.cs b/src/PhoneNumbers/CountryInfo_NorthAmerica.cs index b04e27708..350295c57 100644 --- a/src/PhoneNumbers/CountryInfo_NorthAmerica.cs +++ b/src/PhoneNumbers/CountryInfo_NorthAmerica.cs @@ -114,6 +114,7 @@ public partial class CountryInfo CallingCode = NanpCallingCode, Continent = NorthAmerica, FormatProvider = NanpPhoneNumberFormatProvider.Instance, + IsNatoMember = true, Iso3166Code = "CA", Name = "Canada", NdcLengths = s_nanpNdcLengths, @@ -338,6 +339,7 @@ public partial class CountryInfo CallingCode = NanpCallingCode, Continent = NorthAmerica, FormatProvider = NanpPhoneNumberFormatProvider.Instance, + IsNatoMember = true, Iso3166Code = "US", Name = "United States", NdcLengths = s_nanpNdcLengths, diff --git a/src/PhoneNumbers/ParseOptionsExtensions.cs b/src/PhoneNumbers/ParseOptionsExtensions.cs index 6f94b9bb8..6780b19b9 100644 --- a/src/PhoneNumbers/ParseOptionsExtensions.cs +++ b/src/PhoneNumbers/ParseOptionsExtensions.cs @@ -41,6 +41,15 @@ public static ParseOptions AllowEuropeanCountries(this ParseOptions parseOptions public static ParseOptions AllowEuropeanUnionCountries(this ParseOptions parseOptions) => Allow(parseOptions, x => x.IsEuropeanUnionMember); + /// + /// Allows the instance to include all supported countries who are members of the North Atlantic Treaty Organisation. + /// + /// The instance to update. + /// Thrown if the specified is null. + /// The updated . + public static ParseOptions AllowNatoCountries(this ParseOptions parseOptions) => + Allow(parseOptions, x => x.IsNatoMember); + /// /// Allows the instance to include all supported countries in North America. /// diff --git a/test/PhoneNumbers.Tests/CountryInfo_Africa_Tests.cs b/test/PhoneNumbers.Tests/CountryInfo_Africa_Tests.cs index 348f9a376..073ba128e 100644 --- a/test/PhoneNumbers.Tests/CountryInfo_Africa_Tests.cs +++ b/test/PhoneNumbers.Tests/CountryInfo_Africa_Tests.cs @@ -16,6 +16,7 @@ public void CountryInfo_Egypt() Assert.Equal(CountryInfo.Africa, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("EG", countryInfo.Iso3166Code); Assert.Equal("Egypt", countryInfo.Name); Assert.Equal(new[] { 3, 2, 1 }, countryInfo.NdcLengths); @@ -36,6 +37,7 @@ public void CountryInfo_Kenya() Assert.Equal(CountryInfo.Africa, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("KE", countryInfo.Iso3166Code); Assert.Equal("Kenya", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -56,6 +58,7 @@ public void CountryInfo_Nigeria() Assert.Equal(CountryInfo.Africa, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("NG", countryInfo.Iso3166Code); Assert.Equal("Nigeria", countryInfo.Name); Assert.Equal(new[] { 4, 3 }, countryInfo.NdcLengths); @@ -76,6 +79,7 @@ public void CountryInfo_SouthAfrica() Assert.Equal(CountryInfo.Africa, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("ZA", countryInfo.Iso3166Code); Assert.Equal("South Africa", countryInfo.Name); Assert.Equal(new[] { 2 }, countryInfo.NdcLengths); @@ -96,6 +100,7 @@ public void CountryInfo_Tanzania() Assert.Equal(CountryInfo.Africa, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("TZ", countryInfo.Iso3166Code); Assert.Equal("Tanzania", countryInfo.Name); Assert.Equal(new[] { 5, 3, 2 }, countryInfo.NdcLengths); diff --git a/test/PhoneNumbers.Tests/CountryInfo_Asia_Tests.cs b/test/PhoneNumbers.Tests/CountryInfo_Asia_Tests.cs index 3013a66d6..4c888fbe4 100644 --- a/test/PhoneNumbers.Tests/CountryInfo_Asia_Tests.cs +++ b/test/PhoneNumbers.Tests/CountryInfo_Asia_Tests.cs @@ -16,6 +16,7 @@ public void CountryInfo_HongKong() Assert.Equal(CountryInfo.Asia, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("HK", countryInfo.Iso3166Code); Assert.Equal("Hong Kong", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -36,6 +37,7 @@ public void CountryInfo_Macau() Assert.Equal(CountryInfo.Asia, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("MO", countryInfo.Iso3166Code); Assert.Equal("Macau", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -56,6 +58,7 @@ public void CountryInfo_Singapore() Assert.Equal(CountryInfo.Asia, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("SG", countryInfo.Iso3166Code); Assert.Equal("Singapore", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -76,6 +79,7 @@ public void CountryInfo_Turkey() Assert.Equal(CountryInfo.Asia, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("TR", countryInfo.Iso3166Code); Assert.Equal("Turkey", countryInfo.Name); Assert.Equal(new[] { 3, 0 }, countryInfo.NdcLengths); diff --git a/test/PhoneNumbers.Tests/CountryInfo_Europe_Tests.cs b/test/PhoneNumbers.Tests/CountryInfo_Europe_Tests.cs index 5ff458650..bf24ea272 100644 --- a/test/PhoneNumbers.Tests/CountryInfo_Europe_Tests.cs +++ b/test/PhoneNumbers.Tests/CountryInfo_Europe_Tests.cs @@ -16,6 +16,7 @@ public void CountryInfo_Austria() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("AT", countryInfo.Iso3166Code); Assert.Equal("Austria", countryInfo.Name); Assert.Equal(new[] { 4, 3, 2, 1 }, countryInfo.NdcLengths); @@ -36,6 +37,7 @@ public void CountryInfo_Belarus() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("BY", countryInfo.Iso3166Code); Assert.Equal("Belarus", countryInfo.Name); Assert.Equal(new[] { 4, 3, 2 }, countryInfo.NdcLengths); @@ -56,6 +58,7 @@ public void CountryInfo_Belgium() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("BE", countryInfo.Iso3166Code); Assert.Equal("Belgium", countryInfo.Name); Assert.Equal(new[] { 3, 2, 1 }, countryInfo.NdcLengths); @@ -76,6 +79,7 @@ public void CountryInfo_BosniaAndHerzegovina() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("BA", countryInfo.Iso3166Code); Assert.Equal("Bosnia and Herzegovina", countryInfo.Name); Assert.Equal(new[] { 4, 3, 2 }, countryInfo.NdcLengths); @@ -96,6 +100,7 @@ public void CountryInfo_Bulgaria() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("BG", countryInfo.Iso3166Code); Assert.Equal("Bulgaria", countryInfo.Name); Assert.Equal(new[] { 3, 2, 1 }, countryInfo.NdcLengths); @@ -116,6 +121,7 @@ public void CountryInfo_Croatia() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("HR", countryInfo.Iso3166Code); Assert.Equal("Croatia", countryInfo.Name); Assert.Equal(new[] { 5, 4, 3, 2, 1 }, countryInfo.NdcLengths); @@ -136,6 +142,7 @@ public void CountryInfo_Cyprus() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("CY", countryInfo.Iso3166Code); Assert.Equal("Cyprus", countryInfo.Name); Assert.Equal(new[] { 2 }, countryInfo.NdcLengths); @@ -156,6 +163,7 @@ public void CountryInfo_CzechRepublic() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("CZ", countryInfo.Iso3166Code); Assert.Equal("Czech Republic", countryInfo.Name); Assert.Equal(new[] { 3, 2, 1 }, countryInfo.NdcLengths); @@ -176,6 +184,7 @@ public void CountryInfo_Denmark() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("DK", countryInfo.Iso3166Code); Assert.Equal("Denmark", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -196,6 +205,7 @@ public void CountryInfo_Estonia() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("EE", countryInfo.Iso3166Code); Assert.Equal("Estonia", countryInfo.Name); Assert.Equal(new[] { 4, 3, 2 }, countryInfo.NdcLengths); @@ -216,6 +226,7 @@ public void CountryInfo_Finland() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("FI", countryInfo.Iso3166Code); Assert.Equal("Finland", countryInfo.Name); Assert.Equal(new[] { 4, 3, 2, 1 }, countryInfo.NdcLengths); @@ -236,6 +247,7 @@ public void CountryInfo_France() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("FR", countryInfo.Iso3166Code); Assert.Equal("France", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -256,6 +268,7 @@ public void CountryInfo_Germany() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("DE", countryInfo.Iso3166Code); Assert.Equal("Germany", countryInfo.Name); Assert.Equal(new[] { 5, 4, 3, 2 }, countryInfo.NdcLengths); @@ -276,6 +289,7 @@ public void CountryInfo_Gibraltar() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("GI", countryInfo.Iso3166Code); Assert.Equal("Gibraltar", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -296,6 +310,7 @@ public void CountryInfo_Greece() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("GR", countryInfo.Iso3166Code); Assert.Equal("Greece", countryInfo.Name); Assert.Equal(new[] { 4, 3, 2 }, countryInfo.NdcLengths); @@ -316,6 +331,7 @@ public void CountryInfo_Guernsey() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("GG", countryInfo.Iso3166Code); Assert.Equal("Guernsey", countryInfo.Name); Assert.Equal(new[] { 4 }, countryInfo.NdcLengths); @@ -336,6 +352,7 @@ public void CountryInfo_Hungary() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("HU", countryInfo.Iso3166Code); Assert.Equal("Hungary", countryInfo.Name); Assert.Equal(new[] { 2, 1 }, countryInfo.NdcLengths); @@ -356,6 +373,7 @@ public void CountryInfo_Iceland() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("IS", countryInfo.Iso3166Code); Assert.Equal("Iceland", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -376,6 +394,7 @@ public void CountryInfo_Ireland() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("IE", countryInfo.Iso3166Code); Assert.Equal("Ireland", countryInfo.Name); Assert.Equal(new[] { 3, 2, 1 }, countryInfo.NdcLengths); @@ -396,6 +415,7 @@ public void CountryInfo_IsleOfMan() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("IM", countryInfo.Iso3166Code); Assert.Equal("Isle of Man", countryInfo.Name); Assert.Equal(new[] { 4 }, countryInfo.NdcLengths); @@ -416,6 +436,7 @@ public void CountryInfo_Italy() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("IT", countryInfo.Iso3166Code); Assert.Equal("Italy", countryInfo.Name); Assert.Equal(new[] { 5, 4, 3, 2 }, countryInfo.NdcLengths); @@ -436,6 +457,7 @@ public void CountryInfo_Jersey() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("JE", countryInfo.Iso3166Code); Assert.Equal("Jersey", countryInfo.Name); Assert.Equal(new[] { 4 }, countryInfo.NdcLengths); @@ -456,6 +478,7 @@ public void CountryInfo_Kosovo() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("XK", countryInfo.Iso3166Code); Assert.Equal("Kosovo", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -476,6 +499,7 @@ public void CountryInfo_Latvia() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("LV", countryInfo.Iso3166Code); Assert.Equal("Latvia", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -496,6 +520,7 @@ public void CountryInfo_Lithuania() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("LT", countryInfo.Iso3166Code); Assert.Equal("Lithuania", countryInfo.Name); Assert.Equal(new[] { 3 , 2, 1}, countryInfo.NdcLengths); @@ -516,6 +541,7 @@ public void CountryInfo_Luxembourg() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("LU", countryInfo.Iso3166Code); Assert.Equal("Luxembourg", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -536,6 +562,7 @@ public void CountryInfo_Malta() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("MT", countryInfo.Iso3166Code); Assert.Equal("Malta", countryInfo.Name); Assert.Equal(new[] { 2 }, countryInfo.NdcLengths); @@ -556,6 +583,7 @@ public void CountryInfo_Moldova() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("MD", countryInfo.Iso3166Code); Assert.Equal("Moldova", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -576,6 +604,7 @@ public void CountryInfo_Monaco() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("MC", countryInfo.Iso3166Code); Assert.Equal("Monaco", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -596,6 +625,7 @@ public void CountryInfo_Montenegro() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("ME", countryInfo.Iso3166Code); Assert.Equal("Montenegro", countryInfo.Name); Assert.Equal(new[] { 2 }, countryInfo.NdcLengths); @@ -616,6 +646,7 @@ public void CountryInfo_Netherlands() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("NL", countryInfo.Iso3166Code); Assert.Equal("Netherlands", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -636,6 +667,7 @@ public void CountryInfo_NorthMacedonia() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("MK", countryInfo.Iso3166Code); Assert.Equal("North Macedonia", countryInfo.Name); Assert.Equal(new[] { 3, 2, 1 }, countryInfo.NdcLengths); @@ -656,6 +688,7 @@ public void CountryInfo_Norway() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("NO", countryInfo.Iso3166Code); Assert.Equal("Norway", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -676,6 +709,7 @@ public void CountryInfo_Poland() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("PL", countryInfo.Iso3166Code); Assert.Equal("Poland", countryInfo.Name); Assert.Equal(new[] { 2 }, countryInfo.NdcLengths); @@ -696,6 +730,7 @@ public void CountryInfo_Portugal() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("PT", countryInfo.Iso3166Code); Assert.Equal("Portugal", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -716,6 +751,7 @@ public void CountryInfo_Romania() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("RO", countryInfo.Iso3166Code); Assert.Equal("Romania", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -736,6 +772,7 @@ public void CountryInfo_SanMarino() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("SM", countryInfo.Iso3166Code); Assert.Equal("San Marino", countryInfo.Name); Assert.Empty(countryInfo.NdcLengths); @@ -756,6 +793,7 @@ public void CountryInfo_Serbia() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("RS", countryInfo.Iso3166Code); Assert.Equal("Serbia", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -776,6 +814,7 @@ public void CountryInfo_Slovakia() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("SK", countryInfo.Iso3166Code); Assert.Equal("Slovakia", countryInfo.Name); Assert.Equal(new[] { 4, 3, 2, 1 }, countryInfo.NdcLengths); @@ -796,6 +835,7 @@ public void CountryInfo_Slovenia() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("SL", countryInfo.Iso3166Code); Assert.Equal("Slovenia", countryInfo.Name); Assert.Equal(new[] { 4, 3, 2, 1 }, countryInfo.NdcLengths); @@ -816,6 +856,7 @@ public void CountryInfo_Spain() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("ES", countryInfo.Iso3166Code); Assert.Equal("Spain", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -836,6 +877,7 @@ public void CountryInfo_Sweden() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.True(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("SE", countryInfo.Iso3166Code); Assert.Equal("Sweden", countryInfo.Name); Assert.Equal(new[] { 3, 2, 1 }, countryInfo.NdcLengths); @@ -856,6 +898,7 @@ public void CountryInfo_Switzerland() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("CH", countryInfo.Iso3166Code); Assert.Equal("Switzerland", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -876,6 +919,7 @@ public void CountryInfo_Ukraine() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("UA", countryInfo.Iso3166Code); Assert.Equal("Ukraine", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -896,6 +940,7 @@ public void CountryInfo_UnitedKingdom() Assert.Equal(CountryInfo.Europe, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("GB", countryInfo.Iso3166Code); Assert.Equal("United Kingdom", countryInfo.Name); Assert.Equal(new[] { 5, 4, 3, 2 }, countryInfo.NdcLengths); diff --git a/test/PhoneNumbers.Tests/CountryInfo_NorthAmerica_Tests.cs b/test/PhoneNumbers.Tests/CountryInfo_NorthAmerica_Tests.cs index 3a934fe76..aa8a026d2 100644 --- a/test/PhoneNumbers.Tests/CountryInfo_NorthAmerica_Tests.cs +++ b/test/PhoneNumbers.Tests/CountryInfo_NorthAmerica_Tests.cs @@ -16,6 +16,7 @@ public void CountryInfo_Anguilla() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("AI", countryInfo.Iso3166Code); Assert.Equal("Anguilla", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -36,6 +37,7 @@ public void CountryInfo_AntiguaAndBarbuda() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("AG", countryInfo.Iso3166Code); Assert.Equal("Antigua and Barbuda", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -56,6 +58,7 @@ public void CountryInfo_Bahamas() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("BS", countryInfo.Iso3166Code); Assert.Equal("Bahamas", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -76,6 +79,7 @@ public void CountryInfo_Barbados() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("BB", countryInfo.Iso3166Code); Assert.Equal("Barbados", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -96,6 +100,7 @@ public void CountryInfo_Bermuda() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("BM", countryInfo.Iso3166Code); Assert.Equal("Bermuda", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -116,6 +121,7 @@ public void CountryInfo_BritishVirginIslands() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("VG", countryInfo.Iso3166Code); Assert.Equal("British Virgin Islands", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -136,6 +142,7 @@ public void CountryInfo_Canada() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("CA", countryInfo.Iso3166Code); Assert.Equal("Canada", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -156,6 +163,7 @@ public void CountryInfo_CaymanIslands() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("KY", countryInfo.Iso3166Code); Assert.Equal("Cayman Islands", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -176,6 +184,7 @@ public void CountryInfo_Dominica() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("DM", countryInfo.Iso3166Code); Assert.Equal("Dominica", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -196,6 +205,7 @@ public void CountryInfo_Grenada() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("GD", countryInfo.Iso3166Code); Assert.Equal("Grenada", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -216,6 +226,7 @@ public void CountryInfo_Jamaica() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("JM", countryInfo.Iso3166Code); Assert.Equal("Jamaica", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -236,6 +247,7 @@ public void CountryInfo_Montserrat() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("MS", countryInfo.Iso3166Code); Assert.Equal("Montserrat", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -256,6 +268,7 @@ public void CountryInfo_NorthernMarianaIsland() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("MP", countryInfo.Iso3166Code); Assert.Equal("Northern Mariana Island", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -276,6 +289,7 @@ public void CountryInfo_PuertoRico() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("PR", countryInfo.Iso3166Code); Assert.Equal("Puerto Rico", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -296,6 +310,7 @@ public void CountryInfo_SaintKittsAndNevis() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("KN", countryInfo.Iso3166Code); Assert.Equal("Saint Kitts and Nevis", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -316,6 +331,7 @@ public void CountryInfo_SaintLucia() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("LC", countryInfo.Iso3166Code); Assert.Equal("Saint Lucia", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -336,6 +352,7 @@ public void CountryInfo_SaintVincentAndTheGrenadines() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("VC", countryInfo.Iso3166Code); Assert.Equal("Saint Vincent and the Grenadines", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -356,6 +373,7 @@ public void CountryInfo_SintMaarten() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("SX", countryInfo.Iso3166Code); Assert.Equal("Sint Maarten", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -376,6 +394,7 @@ public void CountryInfo_TrinidadAndTobago() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("TT", countryInfo.Iso3166Code); Assert.Equal("Trinidad and Tobago", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -396,6 +415,7 @@ public void CountryInfo_TurksAndCaicosIslands() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("TC", countryInfo.Iso3166Code); Assert.Equal("Turks and Caicos Islands", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -416,6 +436,7 @@ public void CountryInfo_UnitedStates() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.True(countryInfo.IsNatoMember); Assert.Equal("US", countryInfo.Iso3166Code); Assert.Equal("United States", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -436,6 +457,7 @@ public void CountryInfo_UnitedStatesVirginIslands() Assert.Equal(CountryInfo.NorthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("VI", countryInfo.Iso3166Code); Assert.Equal("United States Virgin Islands", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); diff --git a/test/PhoneNumbers.Tests/CountryInfo_Oceania_Tests.cs b/test/PhoneNumbers.Tests/CountryInfo_Oceania_Tests.cs index 89550223e..d7ec6e79d 100644 --- a/test/PhoneNumbers.Tests/CountryInfo_Oceania_Tests.cs +++ b/test/PhoneNumbers.Tests/CountryInfo_Oceania_Tests.cs @@ -16,6 +16,7 @@ public void CountryInfo_AmericanSamoa() Assert.Equal(CountryInfo.Oceania, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("AS", countryInfo.Iso3166Code); Assert.Equal("American Samoa", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -36,6 +37,7 @@ public void CountryInfo_Australia() Assert.Equal(CountryInfo.Oceania, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("AU", countryInfo.Iso3166Code); Assert.Equal("Australia", countryInfo.Name); Assert.Equal(new[] { 3, 2, 1 }, countryInfo.NdcLengths); @@ -56,6 +58,7 @@ public void CountryInfo_Guam() Assert.Equal(CountryInfo.Oceania, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("GU", countryInfo.Iso3166Code); Assert.Equal("Guam", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); @@ -76,6 +79,7 @@ public void CountryInfo_PapuaNewGuinea() Assert.Equal(CountryInfo.Oceania, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("PG", countryInfo.Iso3166Code); Assert.Equal("Papua New Guinea", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); diff --git a/test/PhoneNumbers.Tests/CountryInfo_SouthAmerica_Tests.cs b/test/PhoneNumbers.Tests/CountryInfo_SouthAmerica_Tests.cs index 6f4ac6616..1e4a11a84 100644 --- a/test/PhoneNumbers.Tests/CountryInfo_SouthAmerica_Tests.cs +++ b/test/PhoneNumbers.Tests/CountryInfo_SouthAmerica_Tests.cs @@ -16,6 +16,7 @@ public void CountryInfo_Brazil() Assert.Equal(CountryInfo.SouthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("BR", countryInfo.Iso3166Code); Assert.Equal("Brazil", countryInfo.Name); Assert.Equal(new[] { 3, 2 }, countryInfo.NdcLengths); @@ -36,6 +37,7 @@ public void CountryInfo_Colombia() Assert.Equal(CountryInfo.SouthAmerica, countryInfo.Continent); Assert.IsType(countryInfo.FormatProvider); Assert.False(countryInfo.IsEuropeanUnionMember); + Assert.False(countryInfo.IsNatoMember); Assert.Equal("CO", countryInfo.Iso3166Code); Assert.Equal("Colombia", countryInfo.Name); Assert.Equal(new[] { 3 }, countryInfo.NdcLengths); diff --git a/test/PhoneNumbers.Tests/ParseOptionsTests.cs b/test/PhoneNumbers.Tests/ParseOptionsTests.cs index 39800bda8..67b2d86b5 100644 --- a/test/PhoneNumbers.Tests/ParseOptionsTests.cs +++ b/test/PhoneNumbers.Tests/ParseOptionsTests.cs @@ -14,7 +14,7 @@ public void AddingCountryMultipleTimesOnlyOnceInList() Assert.Single(parseOptions.Countries); } - + [Fact] public void AllowAfricanCountries() { @@ -59,6 +59,17 @@ public void AllowEuropeanUnionCountries() Assert.All(parseOptions.Countries, x => Assert.True(x.IsEuropeanUnionMember)); } + [Fact] + public void AllowNatoCountries() + { + var parseOptions = new ParseOptions(); + parseOptions.Countries.Clear(); + parseOptions.AllowNatoCountries(); + + Assert.Equal(31, parseOptions.Countries.Count); + Assert.All(parseOptions.Countries, x => Assert.True(x.IsNatoMember)); + } + [Fact] public void AllowNorthAmericanCountries() {