diff --git a/NuGet.md b/NuGet.md index d79fa3e0e..4ebe6cdb3 100644 --- a/NuGet.md +++ b/NuGet.md @@ -27,6 +27,7 @@ phoneNumber.ToString("E.164"); // +441142726444 (E.164 format) phoneNumber.ToString("E.123"); // +44 114 272 6444 (E.123 international format) phoneNumber.ToString("N"); // (0114) 272 6444 (E.123 national notation format) phoneNumber.ToString("RFC3966"); // tel:+44-114-272-644 (RFC3966 format) +phoneNumber.ToString("U"); // 01142726444 (national notation without formatting) ``` Builds for: diff --git a/README.md b/README.md index 683429749..7c4d9acc2 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ phoneNumber.ToString("E.164"); // +441142726444 (E.164 phoneNumber.ToString("E.123"); // +44 114 272 6444 (E.123 international format) phoneNumber.ToString("N"); // (0114) 272 6444 (E.123 national notation format) phoneNumber.ToString("RFC3966"); // tel:+44-114-272-644 (RFC3966 format) +phoneNumber.ToString("U"); // 01142726444 (the national notation without any formatting) ``` ### ParseOptions diff --git a/src/PhoneNumbers/CountryInfo.cs b/src/PhoneNumbers/CountryInfo.cs index a9dbefaab..7dc368c77 100644 --- a/src/PhoneNumbers/CountryInfo.cs +++ b/src/PhoneNumbers/CountryInfo.cs @@ -27,6 +27,7 @@ public sealed partial class CountryInfo E164PhoneNumberFormatter.Instance, E123PhoneNumberFormatter.Instance, NationalPhoneNumberFormatter.Instance, + NationalUnformattedPhoneNumberFormatter.Instance, Rfc3966PhoneNumberFormatter.Instance, ]); diff --git a/src/PhoneNumbers/Formatters/NationalUnformattedPhoneNumberFormatter.cs b/src/PhoneNumbers/Formatters/NationalUnformattedPhoneNumberFormatter.cs new file mode 100644 index 000000000..67b631157 --- /dev/null +++ b/src/PhoneNumbers/Formatters/NationalUnformattedPhoneNumberFormatter.cs @@ -0,0 +1,26 @@ +namespace PhoneNumbers.Formatters; + +/// +/// A which returns the phone number in national notation without any formatting. +/// +internal sealed class NationalUnformattedPhoneNumberFormatter : PhoneNumberFormatter +{ + /// + /// Initialises a new instance of the class. + /// + private NationalUnformattedPhoneNumberFormatter() + : base("U") + { + } + + /// + /// Gets the instance. + /// + internal static PhoneNumberFormatter Instance { get; } = new NationalUnformattedPhoneNumberFormatter(); + + /// + internal override string Format(PhoneNumber phoneNumber) => + phoneNumber.Country.HasTrunkPrefix + ? $"{phoneNumber.Country.TrunkPrefix}{phoneNumber.NationalSignificantNumber}" + : phoneNumber.NationalSignificantNumber; +} diff --git a/test/PhoneNumbers.Tests/CountryInfoTests.cs b/test/PhoneNumbers.Tests/CountryInfoTests.cs index 038af1532..6afff8618 100644 --- a/test/PhoneNumbers.Tests/CountryInfoTests.cs +++ b/test/PhoneNumbers.Tests/CountryInfoTests.cs @@ -19,6 +19,10 @@ public void GetFormatter_N_Returns_NationalPhoneNumberFormatter() => [Fact] public void GetFormatter_RFC3966_Returns_Rfc3966PhoneNumberFormatter() => Assert.IsType(CountryInfo.GetFormatter("RFC3966")); + + [Fact] + public void GetFormatter_U_Returns_NationalUnformattedPhoneNumberFormatter() => + Assert.IsType(CountryInfo.GetFormatter("U")); [Fact] public void GetFormatter_Throws_For_Invalid_Format() => diff --git a/test/PhoneNumbers.Tests/Formatters/NationalUnformattedPhoneNumberFormatterTests.cs b/test/PhoneNumbers.Tests/Formatters/NationalUnformattedPhoneNumberFormatterTests.cs new file mode 100644 index 000000000..3071ce9a2 --- /dev/null +++ b/test/PhoneNumbers.Tests/Formatters/NationalUnformattedPhoneNumberFormatterTests.cs @@ -0,0 +1,28 @@ +using PhoneNumbers.Formatters; + +namespace PhoneNumbers.Tests.Formatters; + +/// +/// Contains unit tests for the class. +/// +public class NationalUnformattedPhoneNumberFormatterTests +{ + [Fact] + public void CanFormat_Returns_False_For_Not_U() => + Assert.False(NationalUnformattedPhoneNumberFormatter.Instance.CanFormat("E.164")); + + [Fact] + public void CanFormat_Returns_False_For_Null() => + Assert.False(NationalUnformattedPhoneNumberFormatter.Instance.CanFormat(null)); + + [Fact] + public void CanFormat_Returns_True_For_U() => + Assert.True(NationalUnformattedPhoneNumberFormatter.Instance.CanFormat("U")); + + [Fact] + public void Instance() + { + Assert.NotNull(NationalUnformattedPhoneNumberFormatter.Instance); + Assert.Same(NationalUnformattedPhoneNumberFormatter.Instance, NationalUnformattedPhoneNumberFormatter.Instance); + } +} diff --git a/test/PhoneNumbers.Tests/PhoneNumber_ToString_Africa_Tests.cs b/test/PhoneNumbers.Tests/PhoneNumber_ToString_Africa_Tests.cs index f82883b6d..fc9b2bfa2 100644 --- a/test/PhoneNumbers.Tests/PhoneNumber_ToString_Africa_Tests.cs +++ b/test/PhoneNumbers.Tests/PhoneNumber_ToString_Africa_Tests.cs @@ -6,6 +6,7 @@ public class PhoneNumber_ToString_Africa_Tests [InlineData("+20235344239", "E.123", "+20 2 3534 4239")] [InlineData("+20235344239", "N", "02 3534 4239")] [InlineData("+20235344239", "RFC3966", "tel:+20-2-3534-4239")] + [InlineData("+20235344239", "U", "0235344239")] public void Egypt_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -16,6 +17,8 @@ public void Egypt_Numbers(string input, string format, string expected) => [InlineData("+254703042000", "N", "0703 042000")] [InlineData("+25420424200", "RFC3966", "tel:+254-20-424200")] [InlineData("+254703042000", "RFC3966", "tel:+254-703-042000")] + [InlineData("+25420424200", "U", "020424200")] + [InlineData("+254703042000", "U", "0703042000")] public void Kenya_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -23,6 +26,7 @@ public void Kenya_Numbers(string input, string format, string expected) => [InlineData("+2342094617000", "E.123", "+234 209 461 7000")] [InlineData("+2342094617000", "N", "(0209) 461 7000")] [InlineData("+2342094617000", "RFC3966", "tel:+234-209-461-7000")] + [InlineData("+2342094617000", "U", "02094617000")] public void Nigeria_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -30,6 +34,7 @@ public void Nigeria_Numbers(string input, string format, string expected) => [InlineData("+27215616800", "E.123", "+27 21 561 6800")] [InlineData("+27215616800", "N", "021 561 6800")] [InlineData("+27215616800", "RFC3966", "tel:+27-21-561-6800")] + [InlineData("+27215616800", "U", "0215616800")] public void SouthAfrica_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -37,6 +42,7 @@ public void SouthAfrica_Numbers(string input, string format, string expected) => [InlineData("+255222199760", "E.123", "+255 22 219 9760")] [InlineData("+255222199760", "N", "022 219 9760")] [InlineData("+255222199760", "RFC3966", "tel:+255-22-219-9760")] + [InlineData("+255222199760", "U", "0222199760")] public void Tanzania_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); } diff --git a/test/PhoneNumbers.Tests/PhoneNumber_ToString_Asia_Tests.cs b/test/PhoneNumbers.Tests/PhoneNumber_ToString_Asia_Tests.cs index 19d872dc0..894b4f0e2 100644 --- a/test/PhoneNumbers.Tests/PhoneNumber_ToString_Asia_Tests.cs +++ b/test/PhoneNumbers.Tests/PhoneNumber_ToString_Asia_Tests.cs @@ -6,6 +6,7 @@ public class PhoneNumber_ToString_Asia_Tests [InlineData("+85229616333", "E.123", "+852 2961 6333")] [InlineData("+85229616333", "N", "2961 6333")] [InlineData("+85229616333", "RFC3966", "tel:+852-2961-6333")] + [InlineData("+85229616333", "U", "29616333")] public void HongKong_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -13,6 +14,7 @@ public void HongKong_Numbers(string input, string format, string expected) => [InlineData("+85328000000", "E.123", "+853 2800 0000")] [InlineData("+85328000000", "N", "2800 0000")] [InlineData("+85328000000", "RFC3966", "tel:+853-2800-0000")] + [InlineData("+85328000000", "U", "28000000")] public void Macau_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -20,6 +22,7 @@ public void Macau_Numbers(string input, string format, string expected) => [InlineData("+6563773800", "E.123", "+65 6377 3800")] [InlineData("+6563773800", "N", "6377 3800")] [InlineData("+6563773800", "RFC3966", "tel:+65-6377-3800")] + [InlineData("+6563773800", "U", "63773800")] public void Singapore_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -30,6 +33,8 @@ public void Singapore_Numbers(string input, string format, string expected) => [InlineData("+903122947200", "N", "(0312) 294 72 00")] [InlineData("+904441234", "RFC3966", "tel:+90-444-12-34")] [InlineData("+903122947200", "RFC3966", "tel:+90-312-294-72-00")] + [InlineData("+904441234", "U", "04441234")] + [InlineData("+903122947200", "U", "03122947200")] public void Turkey_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); } diff --git a/test/PhoneNumbers.Tests/PhoneNumber_ToString_Europe_Tests.cs b/test/PhoneNumbers.Tests/PhoneNumber_ToString_Europe_Tests.cs index ace498a80..8e1b46422 100644 --- a/test/PhoneNumbers.Tests/PhoneNumber_ToString_Europe_Tests.cs +++ b/test/PhoneNumbers.Tests/PhoneNumber_ToString_Europe_Tests.cs @@ -6,6 +6,7 @@ public class PhoneNumber_ToString_Europe_Tests [InlineData("+375172171185", "E.123", "+375 17 2171185")] [InlineData("+375172171185", "N", "817 2171185")] [InlineData("+375172171185", "RFC3966", "tel:+375-17-2171185")] + [InlineData("+375172171185", "U", "8172171185")] public void Belarus_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -19,6 +20,9 @@ public void Belarus_Numbers(string input, string format, string expected) => [InlineData("+3222268888", "RFC3966", "tel:+32-2-226-88-88")] [InlineData("+3250444646", "RFC3966", "tel:+32-50-44-46-46")] [InlineData("+32455678123", "RFC3966", "tel:+32-455-67-81-23")] + [InlineData("+3222268888", "U", "022268888")] + [InlineData("+3250444646", "U", "050444646")] + [InlineData("+32455678123", "U", "0455678123")] public void Belgium_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -26,6 +30,7 @@ public void Belgium_Numbers(string input, string format, string expected) => [InlineData("+38733250600", "E.123", "+387 33 250 600")] [InlineData("+38733250600", "N", "033 250 600")] [InlineData("+38733250600", "RFC3966", "tel:+387-33-250-600")] + [InlineData("+38733250600", "U", "033250600")] public void BosniaAndHerzegovina_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -33,6 +38,7 @@ public void BosniaAndHerzegovina_Numbers(string input, string format, string exp [InlineData("+35929492760", "E.123", "+359 2 949 2760")] [InlineData("+35929492760", "N", "(02) 949 2760")] [InlineData("+35929492760", "RFC3966", "tel:+359-2-949-2760")] + [InlineData("+35929492760", "U", "029492760")] public void Bulgaria_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -40,6 +46,7 @@ public void Bulgaria_Numbers(string input, string format, string expected) => [InlineData("+38517007007", "E.123", "+385 1 700 7007")] [InlineData("+38517007007", "N", "(01) 700 7007")] [InlineData("+38517007007", "RFC3966", "tel:+385-1-700-7007")] + [InlineData("+38517007007", "U", "017007007")] public void Croatia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -47,6 +54,7 @@ public void Croatia_Numbers(string input, string format, string expected) => [InlineData("+35722693000", "E.123", "+357 2269 3000")] [InlineData("+35722693000", "N", "2269 3000")] [InlineData("+35722693000", "RFC3966", "tel:+357-2269-3000")] + [InlineData("+35722693000", "U", "22693000")] public void Cyprus_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -63,6 +71,10 @@ public void Cyprus_Numbers(string input, string format, string expected) => [InlineData("+420224004111", "RFC3966", "tel:+420-224-004-111")] // 1 digit NDC still formatted 3-3-3 [InlineData("+420351786544", "RFC3966", "tel:+420-351-786-544")] // 2 digit NDC still formatted 3-3-3 [InlineData("+420910687654", "RFC3966", "tel:+420-910-687-654")] // 3 digit NDC still formatted 3-3-3 + [InlineData("+4209831452", "U", "9831452")] + [InlineData("+420224004111", "U", "224004111")] + [InlineData("+420910687654", "U", "910687654")] + [InlineData("+420351786544", "U", "351786544")] public void CzechRepublic_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -70,6 +82,7 @@ public void CzechRepublic_Numbers(string input, string format, string expected) [InlineData("+4533926700", "E.123", "+45 3392 6700")] [InlineData("+4533926700", "N", "3392 6700")] [InlineData("+4533926700", "RFC3966", "tel:+45-3392-6700")] + [InlineData("+4533926700", "U", "33926700")] public void Denmark_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -77,6 +90,7 @@ public void Denmark_Numbers(string input, string format, string expected) => [InlineData("+3726672072", "E.123", "+372 6672072")] [InlineData("+3726672072", "N", "6672072")] [InlineData("+3726672072", "RFC3966", "tel:+372-6672072")] + [InlineData("+3726672072", "U", "6672072")] public void Estonia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -87,6 +101,8 @@ public void Estonia_Numbers(string input, string format, string expected) => [InlineData("+358931013300", "N", "(09) 3101 3300")] // Geographic [InlineData("+358295390361", "RFC3966", "tel:+358-29-539-0361")] // Non Geographic [InlineData("+358931013300", "RFC3966", "tel:+358-9-3101-3300")] // Geographic + [InlineData("+358295390361", "U", "0295390361")] // Non Geographic + [InlineData("+358931013300", "U", "0931013300")] // Geographic public void Finland_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -97,6 +113,8 @@ public void Finland_Numbers(string input, string format, string expected) => [InlineData("+337000000000000", "N", "07 00 00 00 00 00 00")] [InlineData("+33140477283", "RFC3966", "tel:+33-1-40-47-72-83")] [InlineData("+337000000000000", "RFC3966", "tel:+33-7-00-00-00-00-00-00")] + [InlineData("+33140477283", "U", "0140477283")] + [InlineData("+337000000000000", "U", "07000000000000")] public void France_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -104,6 +122,7 @@ public void France_Numbers(string input, string format, string expected) => [InlineData("+49228141177", "E.123", "+49 228 141177")] [InlineData("+49228141177", "N", "(0228) 141177")] [InlineData("+49228141177", "RFC3966", "tel:+49-228-141177")] + [InlineData("+49228141177", "U", "0228141177")] public void Germany_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -111,6 +130,7 @@ public void Germany_Numbers(string input, string format, string expected) => [InlineData("+35020074636", "E.123", "+350 20074636")] [InlineData("+35020074636", "N", "20074636")] [InlineData("+35020074636", "RFC3966", "tel:+350-20074636")] + [InlineData("+35020074636", "U", "20074636")] public void Gibraltar_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -124,6 +144,9 @@ public void Gibraltar_Numbers(string input, string format, string expected) => [InlineData("+302106151000", "RFC3966", "tel:+30-210-6151000")] [InlineData("+302513500100", "RFC3966", "tel:+30-2513-500100")] [InlineData("+302695361300", "RFC3966", "tel:+30-26953-61300")] + [InlineData("+302106151000", "U", "2106151000")] + [InlineData("+302513500100", "U", "2513500100")] + [InlineData("+302695361300", "U", "2695361300")] public void Greece_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -131,6 +154,7 @@ public void Greece_Numbers(string input, string format, string expected) => [InlineData("+441481717000", "E.123", "+44 1481 717000")] [InlineData("+441481717000", "N", "(01481) 717000")] [InlineData("+441481717000", "RFC3966", "tel:+44-1481-717000")] + [InlineData("+441481717000", "U", "01481717000")] public void Guernsey_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -144,6 +168,9 @@ public void Guernsey_Numbers(string input, string format, string expected) => [InlineData("+3614680666", "RFC3966", "tel:+36-1-468-0666")] [InlineData("+3625145310", "RFC3966", "tel:+36-25-145-310")] [InlineData("+36207834240", "RFC3966", "tel:+36-20-783-4240")] + [InlineData("+3614680666", "U", "0614680666")] + [InlineData("+3625145310", "U", "0625145310")] + [InlineData("+36207834240", "U", "06207834240")] public void Hungary_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -151,6 +178,7 @@ public void Hungary_Numbers(string input, string format, string expected) => [InlineData("+3545101500", "E.123", "+354 510 1500")] [InlineData("+3545101500", "N", "510 1500")] [InlineData("+3545101500", "RFC3966", "tel:+354-510-1500")] + [InlineData("+3545101500", "U", "5101500")] public void Iceland_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -164,6 +192,9 @@ public void Iceland_Numbers(string input, string format, string expected) => [InlineData("+35318049600", "RFC3966", "tel:+353-1-804-9600")] [InlineData("+35361247656", "RFC3966", "tel:+353-61-247-656")] [InlineData("+35340223488", "RFC3966", "tel:+353-402-23488")] + [InlineData("+35318049600", "U", "018049600")] + [InlineData("+35361247656", "U", "061247656")] + [InlineData("+35340223488", "U", "040223488")] public void Ireland_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -171,6 +202,7 @@ public void Ireland_Numbers(string input, string format, string expected) => [InlineData("+441624696300", "E.123", "+44 1624 696300")] [InlineData("+441624696300", "N", "(01624) 696300")] [InlineData("+441624696300", "RFC3966", "tel:+44-1624-696300")] + [InlineData("+441624696300", "U", "01624696300")] public void IsleOfMan_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -185,6 +217,9 @@ public void IsleOfMan_Numbers(string input, string format, string expected) => [InlineData("+390549882555", "RFC3966", "tel:+39-0549-882555")] // San Marino Landline via Italian NDC [InlineData("+390577292222", "RFC3966", "tel:+39-0577-292222")] // Geo [InlineData("+393492525255", "RFC3966", "tel:+39-34-92525255")] // Mobile + [InlineData("+390549882555", "U", "0549882555")] // San Marino Landline via Italian NDC + [InlineData("+390577292222", "U", "0577292222")] // Geo + [InlineData("+393492525255", "U", "3492525255")] // Mobile public void Italy_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -192,6 +227,7 @@ public void Italy_Numbers(string input, string format, string expected) => [InlineData("+441534716800", "E.123", "+44 1534 716800")] [InlineData("+441534716800", "N", "(01534) 716800")] [InlineData("+441534716800", "RFC3966", "tel:+44-1534-716800")] + [InlineData("+441534716800", "U", "01534716800")] public void Jersey_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -205,6 +241,9 @@ public void Jersey_Numbers(string input, string format, string expected) => [InlineData("+38338212345", "RFC3966", "tel:+383-38-212-345")] [InlineData("+38339020482", "RFC3966", "tel:+383-390-20482")] [InlineData("+38343295870", "RFC3966", "tel:+383-43-295-870")] + [InlineData("+38338212345", "U", "038212345")] + [InlineData("+38339020482", "U", "039020482")] + [InlineData("+38343295870", "U", "043295870")] public void Kosovo_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -212,6 +251,7 @@ public void Kosovo_Numbers(string input, string format, string expected) => [InlineData("+37167028398", "E.123", "+371 67028398")] [InlineData("+37167028398", "N", "67028398")] [InlineData("+37167028398", "RFC3966", "tel:+371-67028398")] + [InlineData("+37167028398", "U", "67028398")] public void Latvia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -219,6 +259,7 @@ public void Latvia_Numbers(string input, string format, string expected) => [InlineData("+37052105664", "E.123", "+370 5 210 5664")] [InlineData("+37052105664", "N", "(85) 210 5664")] [InlineData("+37052105664", "RFC3966", "tel:+370-5-210-5664")] + [InlineData("+37052105664", "U", "852105664")] public void Lithuania_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -235,6 +276,10 @@ public void Lithuania_Numbers(string input, string format, string expected) => [InlineData("+35228228228", "RFC3966", "tel:+352-28-228-228")] [InlineData("+35290500000", "RFC3966", "tel:+352-9050-0000")] [InlineData("+352691000000", "RFC3966", "tel:+352-691-000-000")] + [InlineData("+352493579", "U", "493579")] + [InlineData("+35228228228", "U", "28228228")] + [InlineData("+35290500000", "U", "90500000")] + [InlineData("+352691000000", "U", "691000000")] public void Luxembourg_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -245,6 +290,8 @@ public void Luxembourg_Numbers(string input, string format, string expected) => [InlineData("+3564254321234", "N", "42 5432 1234")] [InlineData("+35621336840", "RFC3966", "tel:+356-2133-6840")] [InlineData("+3564254321234", "RFC3966", "tel:+356-42-5432-1234")] + [InlineData("+35621336840", "U", "21336840")] + [InlineData("+3564254321234", "U", "4254321234")] public void Malta_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -252,6 +299,7 @@ public void Malta_Numbers(string input, string format, string expected) => [InlineData("+37322251317", "E.123", "+373 22 251 317")] [InlineData("+37322251317", "N", "022 251 317")] [InlineData("+37322251317", "RFC3966", "tel:+373-22-251-317")] + [InlineData("+37322251317", "U", "022251317")] public void Moldova_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -262,6 +310,8 @@ public void Moldova_Numbers(string input, string format, string expected) => [InlineData("+377298765235459", "N", "298765235459")] [InlineData("+37798988800", "RFC3966", "tel:+377-98-98-88-00")] [InlineData("+377298765235459", "RFC3966", "tel:+377-298765235459")] + [InlineData("+37798988800", "U", "98988800")] + [InlineData("+377298765235459", "U", "298765235459")] public void Monaco_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -269,6 +319,7 @@ public void Monaco_Numbers(string input, string format, string expected) => [InlineData("+38220406700", "E.123", "+382 20 406 700")] [InlineData("+38220406700", "N", "020 406 700")] [InlineData("+38220406700", "RFC3966", "tel:+382-20-406-700")] + [InlineData("+38220406700", "U", "020406700")] public void Montenegro_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -276,6 +327,7 @@ public void Montenegro_Numbers(string input, string format, string expected) => [InlineData("+31702140214", "E.123", "+31 7 02 14 02 14")] [InlineData("+31702140214", "N", "07 02 14 02 14")] [InlineData("+31702140214", "RFC3966", "tel:+31-7-02-14-02-14")] + [InlineData("+31702140214", "U", "0702140214")] public void Netherlands_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -286,6 +338,8 @@ public void Netherlands_Numbers(string input, string format, string expected) => [InlineData("+38970221213", "N", "070 221 213")] [InlineData("+38923289200", "RFC3966", "tel:+389-2-328-9200")] [InlineData("+38970221213", "RFC3966", "tel:+389-70-221-213")] + [InlineData("+38923289200", "U", "023289200")] + [InlineData("+38970221213", "U", "070221213")] public void NorthMacedonia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -299,6 +353,9 @@ public void NorthMacedonia_Numbers(string input, string format, string expected) [InlineData("+4722824600", "RFC3966", "tel:+47-22-82-46-00")] [InlineData("+4780824600", "RFC3966", "tel:+47-808-24-600")] [InlineData("+47581223344556", "RFC3966", "tel:+47-58-12-23-34-45-56")] + [InlineData("+4722824600", "U", "22824600")] + [InlineData("+4780824600", "U", "80824600")] + [InlineData("+47581223344556", "U", "581223344556")] public void Norway_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -309,6 +366,8 @@ public void Norway_Numbers(string input, string format, string expected) => [InlineData("+48458787987", "N", "458-787-987")] [InlineData("+48222455856", "RFC3966", "tel:+48-22-245-58-56")] [InlineData("+48458787987", "RFC3966", "tel:+48-458-787-987")] + [InlineData("+48222455856", "U", "222455856")] + [InlineData("+48458787987", "U", "458787987")] public void Poland_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -316,6 +375,7 @@ public void Poland_Numbers(string input, string format, string expected) => [InlineData("+351217211000", "E.123", "+351 217 211 000")] [InlineData("+351217211000", "N", "217 211 000")] [InlineData("+351217211000", "RFC3966", "tel:+351-217-211-000")] + [InlineData("+351217211000", "U", "217211000")] public void Portugal_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -326,6 +386,8 @@ public void Portugal_Numbers(string input, string format, string expected) => [InlineData("+40213320771", "N", "021 332 07 71")] [InlineData("+40213320771", "RFC3966", "tel:+40-21-332-07-71")] [InlineData("+40372845414", "RFC3966", "tel:+40-372-845-414")] + [InlineData("+40372845414", "U", "0372845414")] + [InlineData("+40213320771", "U", "0213320771")] public void Romania_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -343,6 +405,10 @@ public void Romania_Numbers(string input, string format, string expected) => [InlineData("+37866661212", "RFC3966", "tel:+378-66-661212")] // Mobile [InlineData("+378882555", "RFC3966", "tel:+378-882555")] // Landline without Italian NDC [InlineData("+3780549882555", "RFC3966", "tel:+378-0549-882555")] // Landline with Italian NDC + [InlineData("+37858001110", "U", "58001110")] // IP Telephony + [InlineData("+37866661212", "U", "66661212")] // Mobile + [InlineData("+378882555", "U", "882555")] // Landline without Italian NDC + [InlineData("+3780549882555", "U", "0549882555")] // Landline with Italian NDC public void SanMarino_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -350,6 +416,7 @@ public void SanMarino_Numbers(string input, string format, string expected) => [InlineData("+381112026828", "E.123", "+381 11 202 6828")] [InlineData("+381112026828", "N", "(011) 202 6828")] [InlineData("+381112026828", "RFC3966", "tel:+381-11-202-6828")] + [InlineData("+381112026828", "U", "0112026828")] public void Serbia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -363,6 +430,9 @@ public void Serbia_Numbers(string input, string format, string expected) => [InlineData("+421257881101", "RFC3966", "tel:+421-2-5788-1101")] [InlineData("+421415005178", "RFC3966", "tel:+421-41-500-5178")] [InlineData("+421949554223", "RFC3966", "tel:+421-949-554-223")] + [InlineData("+421257881101", "U", "0257881101")] + [InlineData("+421415005178", "U", "0415005178")] + [InlineData("+421949554223", "U", "0949554223")] public void Slovakia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -376,6 +446,9 @@ public void Slovakia_Numbers(string input, string format, string expected) => [InlineData("+38615836300", "RFC3966", "tel:+386-1-583-63-00")] [InlineData("+38630123654", "RFC3966", "tel:+386-30-123-654")] [InlineData("+38665012365", "RFC3966", "tel:+386-650-12-365")] + [InlineData("+38615836300", "U", "015836300")] + [InlineData("+38630123654", "U", "030123654")] + [InlineData("+38665012365", "U", "065012365")] public void Slovenia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -386,6 +459,8 @@ public void Slovenia_Numbers(string input, string format, string expected) => [InlineData("+34902189900", "N", "902 189 900")] // 3-3-3 where the NDC is 3 digits [InlineData("+34912582852", "RFC3966", "tel:+34-91-258-28-52")] // 2-3-2-2 where the NDC is 2 digits (applicable for Madrid & Barcelona) [InlineData("+34902189900", "RFC3966", "tel:+34-902-189-900")] // 3-3-3 where the NDC is 3 digits + [InlineData("+34912582852", "U", "912582852")] + [InlineData("+34902189900", "U", "902189900")] public void Spain_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -417,6 +492,15 @@ public void Spain_Numbers(string input, string format, string expected) => [InlineData("+46906785500", "RFC3966", "tel:+46-90-678-55-00")] [InlineData("+4664067855", "RFC3966", "tel:+46-640-678-55")] [InlineData("+46640678550", "RFC3966", "tel:+46-640-67-85-50")] + [InlineData("+468678550", "U", "08678550")] + [InlineData("+4686785500", "U", "086785500")] + [InlineData("+46867855001", "U", "0867855001")] + [InlineData("+46777855001", "U", "0777855001")] + [InlineData("+469067855", "U", "09067855")] + [InlineData("+4690678550", "U", "090678550")] + [InlineData("+46906785500", "U", "0906785500")] + [InlineData("+4664067855", "U", "064067855")] + [InlineData("+46640678550", "U", "0640678550")] public void Sweden_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -427,6 +511,8 @@ public void Sweden_Numbers(string input, string format, string expected) => [InlineData("+41840545987", "N", "0840 545 987")] // 3-3-3 where the NDC is 3 digits [InlineData("+41584605511", "RFC3966", "tel:+41-58-460-55-11")] // 2-3-2-2 where the NDC is 2 digits [InlineData("+41840545987", "RFC3966", "tel:+41-840-545-987")] // 3-3-3 where the NDC is 3 digits + [InlineData("+41584605511", "U", "0584605511")] + [InlineData("+41840545987", "U", "0840545987")] public void Switzerland_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -437,6 +523,8 @@ public void Switzerland_Numbers(string input, string format, string expected) => [InlineData("+380891233456", "N", "0891 233 456")] [InlineData("+380442819196", "RFC3966", "tel:+380-44-281-91-96")] [InlineData("+380891233456", "RFC3966", "tel:+380-891-233-456")] + [InlineData("+380442819196", "U", "0442819196")] + [InlineData("+380891233456", "U", "0891233456")] public void Ukraine_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -463,6 +551,14 @@ public void Ukraine_Numbers(string input, string format, string expected) => [InlineData("+441642012234", "RFC3966", "tel:+44-1642-012234")] [InlineData("+447106010234", "RFC3966", "tel:+44-7106-010234")] [InlineData("+441946722130", "RFC3966", "tel:+44-19467-22130")] + [InlineData("+442079813000", "U", "02079813000")] + [InlineData("+448001111", "U", "08001111")] + [InlineData("+441142726444", "U", "01142726444")] + [InlineData("+443001100123", "U", "03001100123")] + [InlineData("+441642012234", "U", "01642012234")] + [InlineData("+441733234567", "U", "01733234567")] + [InlineData("+447106010234", "U", "07106010234")] + [InlineData("+441946722130", "U", "01946722130")] public void UnitedKingdom_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); } diff --git a/test/PhoneNumbers.Tests/PhoneNumber_ToString_NorthAmerica_Tests.cs b/test/PhoneNumbers.Tests/PhoneNumber_ToString_NorthAmerica_Tests.cs index 28824ae29..d9f52e6c1 100644 --- a/test/PhoneNumbers.Tests/PhoneNumber_ToString_NorthAmerica_Tests.cs +++ b/test/PhoneNumbers.Tests/PhoneNumber_ToString_NorthAmerica_Tests.cs @@ -6,6 +6,7 @@ public class PhoneNumber_ToString_NorthAmerica_Tests [InlineData("+12644972442", "E.123", "+1 264-497-2442")] [InlineData("+12644972442", "N", "(264) 497-2442")] [InlineData("+12644972442", "RFC3966", "tel:+1-264-497-2442")] + [InlineData("+12644972442", "U", "2644972442")] public void Anguilla_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -13,6 +14,7 @@ public void Anguilla_Numbers(string input, string format, string expected) => [InlineData("+12684804405", "E.123", "+1 268-480-4405")] [InlineData("+12684804405", "N", "(268) 480-4405")] [InlineData("+12684804405", "RFC3966", "tel:+1-268-480-4405")] + [InlineData("+12684804405", "U", "2684804405")] public void AntiguaAndBarbuda_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -20,6 +22,7 @@ public void AntiguaAndBarbuda_Numbers(string input, string format, string expect [InlineData("+12423930234", "E.123", "+1 242-393-0234")] [InlineData("+12423930234", "N", "(242) 393-0234")] [InlineData("+12423930234", "RFC3966", "tel:+1-242-393-0234")] + [InlineData("+12423930234", "U", "2423930234")] public void Bahamas_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -27,6 +30,7 @@ public void Bahamas_Numbers(string input, string format, string expected) => [InlineData("+12465352573", "E.123", "+1 246-535-2573")] [InlineData("+12465352573", "N", "(246) 535-2573")] [InlineData("+12465352573", "RFC3966", "tel:+1-246-535-2573")] + [InlineData("+12465352573", "U", "2465352573")] public void Barbados_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -34,6 +38,7 @@ public void Barbados_Numbers(string input, string format, string expected) => [InlineData("+14414056000", "E.123", "+1 441-405-6000")] [InlineData("+14414056000", "N", "(441) 405-6000")] [InlineData("+14414056000", "RFC3966", "tel:+1-441-405-6000")] + [InlineData("+14414056000", "U", "4414056000")] public void Bermuda_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -41,6 +46,7 @@ public void Bermuda_Numbers(string input, string format, string expected) => [InlineData("+12844946786", "E.123", "+1 284-494-6786")] [InlineData("+12844946786", "N", "(284) 494-6786")] [InlineData("+12844946786", "RFC3966", "tel:+1-284-494-6786")] + [InlineData("+12844946786", "U", "2844946786")] public void BritishVirginIslands_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -48,6 +54,7 @@ public void BritishVirginIslands_Numbers(string input, string format, string exp [InlineData("+16137020016", "E.123", "+1 613-702-0016")] [InlineData("+16137020016", "N", "(613) 702-0016")] [InlineData("+16137020016", "RFC3966", "tel:+1-613-702-0016")] + [InlineData("+16137020016", "U", "6137020016")] public void Canada_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -55,6 +62,7 @@ public void Canada_Numbers(string input, string format, string expected) => [InlineData("+13459464282", "E.123", "+1 345-946-4282")] [InlineData("+13459464282", "N", "(345) 946-4282")] [InlineData("+13459464282", "RFC3966", "tel:+1-345-946-4282")] + [InlineData("+13459464282", "U", "3459464282")] public void CaymanIslands_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -62,6 +70,7 @@ public void CaymanIslands_Numbers(string input, string format, string expected) [InlineData("+17677011252", "E.123", "+1 767-701-1252")] [InlineData("+17677011252", "N", "(767) 701-1252")] [InlineData("+17677011252", "RFC3966", "tel:+1-767-701-1252")] + [InlineData("+17677011252", "U", "7677011252")] public void Dominica_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -69,6 +78,7 @@ public void Dominica_Numbers(string input, string format, string expected) => [InlineData("+14734081342", "E.123", "+1 473-408-1342")] [InlineData("+14734081342", "N", "(473) 408-1342")] [InlineData("+14734081342", "RFC3966", "tel:+1-473-408-1342")] + [InlineData("+14734081342", "U", "4734081342")] public void Grenada_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -76,6 +86,7 @@ public void Grenada_Numbers(string input, string format, string expected) => [InlineData("+18769686053", "E.123", "+1 876-968-6053")] [InlineData("+18769686053", "N", "(876) 968-6053")] [InlineData("+18769686053", "RFC3966", "tel:+1-876-968-6053")] + [InlineData("+18769686053", "U", "8769686053")] public void Jamaica_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -83,6 +94,7 @@ public void Jamaica_Numbers(string input, string format, string expected) => [InlineData("+16644913789", "E.123", "+1 664-491-3789")] [InlineData("+16644913789", "N", "(664) 491-3789")] [InlineData("+16644913789", "RFC3966", "tel:+1-664-491-3789")] + [InlineData("+16644913789", "U", "6644913789")] public void Montserrat_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -90,6 +102,7 @@ public void Montserrat_Numbers(string input, string format, string expected) => [InlineData("+16702202200", "E.123", "+1 670-220-2200")] [InlineData("+16702202200", "N", "(670) 220-2200")] [InlineData("+16702202200", "RFC3966", "tel:+1-670-220-2200")] + [InlineData("+16702202200", "U", "6702202200")] public void NorthernMarianaIsland_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -97,6 +110,7 @@ public void NorthernMarianaIsland_Numbers(string input, string format, string ex [InlineData("+17877222977", "E.123", "+1 787-722-2977")] [InlineData("+17877222977", "N", "(787) 722-2977")] [InlineData("+17877222977", "RFC3966", "tel:+1-787-722-2977")] + [InlineData("+17877222977", "U", "7877222977")] public void PuertoRico_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -104,6 +118,7 @@ public void PuertoRico_Numbers(string input, string format, string expected) => [InlineData("+18692291432", "E.123", "+1 869-229-1432")] [InlineData("+18692291432", "N", "(869) 229-1432")] [InlineData("+18692291432", "RFC3966", "tel:+1-869-229-1432")] + [InlineData("+18692291432", "U", "8692291432")] public void SaintKittsAndNevis_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -111,6 +126,7 @@ public void SaintKittsAndNevis_Numbers(string input, string format, string expec [InlineData("+17584581701", "E.123", "+1 758-458-1701")] [InlineData("+17584581701", "N", "(758) 458-1701")] [InlineData("+17584581701", "RFC3966", "tel:+1-758-458-1701")] + [InlineData("+17584581701", "U", "7584581701")] public void SaintLucia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -118,6 +134,7 @@ public void SaintLucia_Numbers(string input, string format, string expected) => [InlineData("+17842664245", "E.123", "+1 784-266-4245")] [InlineData("+17842664245", "N", "(784) 266-4245")] [InlineData("+17842664245", "RFC3966", "tel:+1-784-266-4245")] + [InlineData("+17842664245", "U", "7842664245")] public void SaintVincentAndTheGrenadines_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -125,6 +142,7 @@ public void SaintVincentAndTheGrenadines_Numbers(string input, string format, st [InlineData("+17215425557", "E.123", "+1 721-542-5557")] [InlineData("+17215425557", "N", "(721) 542-5557")] [InlineData("+17215425557", "RFC3966", "tel:+1-721-542-5557")] + [InlineData("+17215425557", "U", "7215425557")] public void SintMaarten_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -132,6 +150,7 @@ public void SintMaarten_Numbers(string input, string format, string expected) => [InlineData("+18686758288", "E.123", "+1 868-675-8288")] [InlineData("+18686758288", "N", "(868) 675-8288")] [InlineData("+18686758288", "RFC3966", "tel:+1-868-675-8288")] + [InlineData("+18686758288", "U", "8686758288")] public void TrinidadAndTobago_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -139,6 +158,7 @@ public void TrinidadAndTobago_Numbers(string input, string format, string expect [InlineData("+16499461900", "E.123", "+1 649-946-1900")] [InlineData("+16499461900", "N", "(649) 946-1900")] [InlineData("+16499461900", "RFC3966", "tel:+1-649-946-1900")] + [InlineData("+16499461900", "U", "6499461900")] public void TurksAndCaicosIslands_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -146,6 +166,7 @@ public void TurksAndCaicosIslands_Numbers(string input, string format, string ex [InlineData("+13407731404", "E.123", "+1 340-773-1404")] [InlineData("+13407731404", "N", "(340) 773-1404")] [InlineData("+13407731404", "RFC3966", "tel:+1-340-773-1404")] + [InlineData("+13407731404", "U", "3407731404")] public void UnitedStatesVirginIslands_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -153,6 +174,7 @@ public void UnitedStatesVirginIslands_Numbers(string input, string format, strin [InlineData("+12124841200", "E.123", "+1 212-484-1200")] [InlineData("+12124841200", "N", "(212) 484-1200")] [InlineData("+12124841200", "RFC3966", "tel:+1-212-484-1200")] + [InlineData("+12124841200", "U", "2124841200")] public void UnitedStates_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); } diff --git a/test/PhoneNumbers.Tests/PhoneNumber_ToString_Oceania_Tests.cs b/test/PhoneNumbers.Tests/PhoneNumber_ToString_Oceania_Tests.cs index 639793765..0853cd44d 100644 --- a/test/PhoneNumbers.Tests/PhoneNumber_ToString_Oceania_Tests.cs +++ b/test/PhoneNumbers.Tests/PhoneNumber_ToString_Oceania_Tests.cs @@ -6,6 +6,7 @@ public class PhoneNumber_ToString_Oceania_Tests [InlineData("+16846339805", "E.123", "+1 684-633-9805")] [InlineData("+16846339805", "N", "(684) 633-9805")] [InlineData("+16846339805", "RFC3966", "tel:+1-684-633-9805")] + [InlineData("+16846339805", "U", "6846339805")] public void AmericanSamoa_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -22,6 +23,10 @@ public void AmericanSamoa_Numbers(string input, string format, string expected) [InlineData("+61399636800", "RFC3966", "tel:+61-3-9963-6800")] [InlineData("+61436986301", "RFC3966", "tel:+61-436-986-301")] [InlineData("+611800900090", "RFC3966", "tel:+61-1800-900-090")] + [InlineData("+61131234", "U", "0131234")] + [InlineData("+61399636800", "U", "0399636800")] + [InlineData("+61436986301", "U", "0436986301")] + //[InlineData("+611800900090", "U", "1800900090")] // TODO: Cater for this somehow... public void Australia_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -29,6 +34,7 @@ public void Australia_Numbers(string input, string format, string expected) => [InlineData("+16716323365", "E.123", "+1 671-632-3365")] [InlineData("+16716323365", "N", "(671) 632-3365")] [InlineData("+16716323365", "RFC3966", "tel:+1-671-632-3365")] + [InlineData("+16716323365", "U", "6716323365")] public void Guam_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); @@ -36,6 +42,7 @@ public void Guam_Numbers(string input, string format, string expected) => [InlineData("+6753033201", "E.123", "+675 303 3201")] [InlineData("+6753033201", "N", "303 3201")] [InlineData("+6753033201", "RFC3966", "tel:+675-303-3201")] + [InlineData("+6753033201", "U", "3033201")] public void PapuaNewGuinea_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format)); } diff --git a/test/PhoneNumbers.Tests/PhoneNumber_ToString_SouthAmerica_Tests.cs b/test/PhoneNumbers.Tests/PhoneNumber_ToString_SouthAmerica_Tests.cs index 35dbcf952..a092be54c 100644 --- a/test/PhoneNumbers.Tests/PhoneNumber_ToString_SouthAmerica_Tests.cs +++ b/test/PhoneNumbers.Tests/PhoneNumber_ToString_SouthAmerica_Tests.cs @@ -9,6 +9,8 @@ public class PhoneNumber_ToString_SouthAmerica_Tests [InlineData("+5541732649808", "N", "(041) 73264-9808")] [InlineData("+556123122026", "RFC3966", "tel:+55-61-2312-2026")] [InlineData("+5541732649808", "RFC3966", "tel:+55-41-73264-9808")] + [InlineData("+556123122026", "U", "06123122026")] + [InlineData("+5541732649808", "U", "041732649808")] public void Brazil_Numbers(string input, string format, string expected) => Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format));