-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
342 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# References: | ||
# - https://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000DA0002PDFE.pdf | ||
# - https://www.ekip.me/media/documents/general/1656937726_Plan%20numeracije%20CG.pdf | ||
G|20|Podgorica, Tuzi, Danilovgrad, Kolašin|000000-999999| | ||
G|30|Bar, Ulcinj|000000-999999| | ||
G|31|Herceg Novi|000000-999999| | ||
G|32|Kotor, Tivat|000000-999999| | ||
G|33|Budva|000000-999999| | ||
G|40|Nikšić, Šavnik, Plužine|000000-999999| | ||
G|41|Cetinje|000000-999999| | ||
G|50|Bijelo Polje, Mojkovac|000000-999999| | ||
G|51|Berane, Andrijevica, Rožaje, Plav, Petnjica, Gusinje|000000-999999| | ||
G|52|Pljevlja, Žabljak|000000-999999| | ||
M|60,68||00-9999999999| | ||
M|63,66-67,69||00-9999999999| | ||
N|70,77-78||000000-999999| | ||
N|71||0000000000-9999999999|M | ||
N|80||000000-999999|F | ||
N|83||000000-999999|S | ||
N|94-95||000000-999999|R |
101 changes: 101 additions & 0 deletions
101
test/PhoneNumbers.Data.Tests/Parsers/DefaultPhoneNumberParserTests_ME_GeographicNumber.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
namespace PhoneNumbers.Tests.Parsers; | ||
|
||
/// <summary> | ||
/// Contains unit tests for the <see cref="DefaultPhoneNumberParser"/> class for Montenegro <see cref="PhoneNumber"/>s. | ||
/// </summary> | ||
public class DefaultPhoneNumberParserTests_ME_GeographicNumber | ||
{ | ||
private static readonly PhoneNumberParser s_parser = DefaultPhoneNumberParser.Create(CountryInfo.Montenegro); | ||
|
||
[Theory] | ||
[InlineData("020000000", "20", "000000", "Podgorica, Tuzi, Danilovgrad, Kolašin")] | ||
[InlineData("020999999", "20", "999999", "Podgorica, Tuzi, Danilovgrad, Kolašin")] | ||
public void Parse_Known_GeographicPhoneNumber_2X_NationalDestinationCode(string value, string NationalDestinationCode, string subscriberNumber, string geographicArea) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<GeographicPhoneNumber>(phoneNumber); | ||
|
||
var geographicPhoneNumber = (GeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, geographicPhoneNumber.Country); | ||
Assert.Equal(geographicArea, geographicPhoneNumber.GeographicArea); | ||
Assert.Equal(NationalDestinationCode, geographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, geographicPhoneNumber.SubscriberNumber); | ||
} | ||
|
||
[Theory] | ||
[InlineData("030000000", "30", "000000", "Bar, Ulcinj")] | ||
[InlineData("030999999", "30", "999999", "Bar, Ulcinj")] | ||
[InlineData("031000000", "31", "000000", "Herceg Novi")] | ||
[InlineData("031999999", "31", "999999", "Herceg Novi")] | ||
[InlineData("032000000", "32", "000000", "Kotor, Tivat")] | ||
[InlineData("032999999", "32", "999999", "Kotor, Tivat")] | ||
[InlineData("033000000", "33", "000000", "Budva")] | ||
[InlineData("033999999", "33", "999999", "Budva")] | ||
public void Parse_Known_GeographicPhoneNumber_3X_NationalDestinationCode(string value, string NationalDestinationCode, string subscriberNumber, string geographicArea) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<GeographicPhoneNumber>(phoneNumber); | ||
|
||
var geographicPhoneNumber = (GeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, geographicPhoneNumber.Country); | ||
Assert.Equal(geographicArea, geographicPhoneNumber.GeographicArea); | ||
Assert.Equal(NationalDestinationCode, geographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, geographicPhoneNumber.SubscriberNumber); | ||
} | ||
|
||
[Theory] | ||
[InlineData("040000000", "40", "000000", "Nikšić, Šavnik, Plužine")] | ||
[InlineData("040999999", "40", "999999", "Nikšić, Šavnik, Plužine")] | ||
[InlineData("041000000", "41", "000000", "Cetinje")] | ||
[InlineData("041999999", "41", "999999", "Cetinje")] | ||
public void Parse_Known_GeographicPhoneNumber_4X_NationalDestinationCode(string value, string NationalDestinationCode, string subscriberNumber, string geographicArea) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<GeographicPhoneNumber>(phoneNumber); | ||
|
||
var geographicPhoneNumber = (GeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, geographicPhoneNumber.Country); | ||
Assert.Equal(geographicArea, geographicPhoneNumber.GeographicArea); | ||
Assert.Equal(NationalDestinationCode, geographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, geographicPhoneNumber.SubscriberNumber); | ||
} | ||
|
||
[Theory] | ||
[InlineData("050000000", "50", "000000", "Bijelo Polje, Mojkovac")] | ||
[InlineData("050999999", "50", "999999", "Bijelo Polje, Mojkovac")] | ||
[InlineData("051000000", "51", "000000", "Berane, Andrijevica, Rožaje, Plav, Petnjica, Gusinje")] | ||
[InlineData("051999999", "51", "999999", "Berane, Andrijevica, Rožaje, Plav, Petnjica, Gusinje")] | ||
[InlineData("052000000", "52", "000000", "Pljevlja, Žabljak")] | ||
[InlineData("052999999", "52", "999999", "Pljevlja, Žabljak")] | ||
public void Parse_Known_GeographicPhoneNumber_5X_NationalDestinationCode(string value, string NationalDestinationCode, string subscriberNumber, string geographicArea) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<GeographicPhoneNumber>(phoneNumber); | ||
|
||
var geographicPhoneNumber = (GeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, geographicPhoneNumber.Country); | ||
Assert.Equal(geographicArea, geographicPhoneNumber.GeographicArea); | ||
Assert.Equal(NationalDestinationCode, geographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, geographicPhoneNumber.SubscriberNumber); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
test/PhoneNumbers.Data.Tests/Parsers/DefaultPhoneNumberParserTests_ME_MobilePhoneNumber.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace PhoneNumbers.Tests.Parsers; | ||
|
||
/// <summary> | ||
/// Contains unit tests for the <see cref="DefaultPhoneNumberParser"/> class for Montenegro <see cref="PhoneNumber"/>s. | ||
/// </summary> | ||
public class DefaultPhoneNumberParserTests_ME_MobilePhoneNumber | ||
{ | ||
private static readonly PhoneNumberParser s_parser = DefaultPhoneNumberParser.Create(CountryInfo.Montenegro); | ||
|
||
[Theory] | ||
[InlineData("06000", "60", "00")] | ||
[InlineData("0609999999999", "60", "9999999999")] | ||
[InlineData("06300", "63", "00")] | ||
[InlineData("0639999999999", "63", "9999999999")] | ||
[InlineData("06600", "66", "00")] | ||
[InlineData("0669999999999", "66", "9999999999")] | ||
[InlineData("06700", "67", "00")] | ||
[InlineData("0679999999999", "67", "9999999999")] | ||
[InlineData("06800", "68", "00")] | ||
[InlineData("0689999999999", "68", "9999999999")] | ||
[InlineData("06900", "69", "00")] | ||
[InlineData("0699999999999", "69", "9999999999")] | ||
public void Parse_Known_MobilePhoneNumber(string value, string NationalDestinationCode, string subscriberNumber) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<MobilePhoneNumber>(phoneNumber); | ||
|
||
var mobilePhoneNumber = (MobilePhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, mobilePhoneNumber.Country); | ||
Assert.False(mobilePhoneNumber.IsPager); | ||
Assert.False(mobilePhoneNumber.IsVirtual); | ||
Assert.Equal(NationalDestinationCode, mobilePhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, mobilePhoneNumber.SubscriberNumber); | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
...neNumbers.Data.Tests/Parsers/DefaultPhoneNumberParserTests_ME_NonGeographicPhoneNumber.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
namespace PhoneNumbers.Tests.Parsers; | ||
|
||
/// <summary> | ||
/// Contains unit tests for the <see cref="DefaultPhoneNumberParser"/> class for Montenegro <see cref="PhoneNumber"/>s. | ||
/// </summary> | ||
public class DefaultPhoneNumberParserTests_ME_NonGeographicPhoneNumber | ||
{ | ||
private static readonly PhoneNumberParser s_parser = DefaultPhoneNumberParser.Create(CountryInfo.Montenegro); | ||
|
||
[Theory] | ||
[InlineData("070000000", "70", "000000")] | ||
[InlineData("070999999", "70", "999999")] | ||
[InlineData("077000000", "77", "000000")] | ||
[InlineData("077999999", "77", "999999")] | ||
[InlineData("078000000", "78", "000000")] | ||
[InlineData("078999999", "78", "999999")] | ||
public void Parse_Known_NonGeographicPhoneNumber_7X_NationalDestinationCode(string value, string NationalDestinationCode, string subscriberNumber) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<NonGeographicPhoneNumber>(phoneNumber); | ||
|
||
var nonGeographicPhoneNumber = (NonGeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, nonGeographicPhoneNumber.Country); | ||
Assert.False(nonGeographicPhoneNumber.IsFreephone); | ||
Assert.False(nonGeographicPhoneNumber.IsMachineToMachine); | ||
Assert.False(nonGeographicPhoneNumber.IsPremiumRate); | ||
Assert.False(nonGeographicPhoneNumber.IsSharedCost); | ||
Assert.Equal(NationalDestinationCode, nonGeographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, nonGeographicPhoneNumber.SubscriberNumber); | ||
} | ||
|
||
[Theory] | ||
[InlineData("080000000", "80", "000000")] | ||
[InlineData("080999999", "80", "999999")] | ||
public void Parse_Known_NonGeographicPhoneNumber_Freephone(string value, string NationalDestinationCode, string subscriberNumber) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<NonGeographicPhoneNumber>(phoneNumber); | ||
|
||
var nonGeographicPhoneNumber = (NonGeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, nonGeographicPhoneNumber.Country); | ||
Assert.True(nonGeographicPhoneNumber.IsFreephone); | ||
Assert.False(nonGeographicPhoneNumber.IsMachineToMachine); | ||
Assert.False(nonGeographicPhoneNumber.IsPremiumRate); | ||
Assert.False(nonGeographicPhoneNumber.IsSharedCost); | ||
Assert.Equal(NationalDestinationCode, nonGeographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, nonGeographicPhoneNumber.SubscriberNumber); | ||
} | ||
|
||
[Theory] | ||
[InlineData("0710000000000", "71", "0000000000")] | ||
[InlineData("0719999999999", "71", "9999999999")] | ||
public void Parse_Known_NonGeographicPhoneNumber_MachineToMachine(string value, string NationalDestinationCode, string subscriberNumber) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<NonGeographicPhoneNumber>(phoneNumber); | ||
|
||
var nonGeographicPhoneNumber = (NonGeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, nonGeographicPhoneNumber.Country); | ||
Assert.False(nonGeographicPhoneNumber.IsFreephone); | ||
Assert.True(nonGeographicPhoneNumber.IsMachineToMachine); | ||
Assert.False(nonGeographicPhoneNumber.IsPremiumRate); | ||
Assert.False(nonGeographicPhoneNumber.IsSharedCost); | ||
Assert.Equal(NationalDestinationCode, nonGeographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, nonGeographicPhoneNumber.SubscriberNumber); | ||
} | ||
|
||
[Theory] | ||
[InlineData("094000000", "94", "000000")] | ||
[InlineData("094999999", "94", "999999")] | ||
[InlineData("095000000", "95", "000000")] | ||
[InlineData("095999999", "95", "999999")] | ||
public void Parse_Known_NonGeographicPhoneNumber_PremiumRate(string value, string NationalDestinationCode, string subscriberNumber) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<NonGeographicPhoneNumber>(phoneNumber); | ||
|
||
var nonGeographicPhoneNumber = (NonGeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, nonGeographicPhoneNumber.Country); | ||
Assert.False(nonGeographicPhoneNumber.IsFreephone); | ||
Assert.False(nonGeographicPhoneNumber.IsMachineToMachine); | ||
Assert.True(nonGeographicPhoneNumber.IsPremiumRate); | ||
Assert.False(nonGeographicPhoneNumber.IsSharedCost); | ||
Assert.Equal(NationalDestinationCode, nonGeographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, nonGeographicPhoneNumber.SubscriberNumber); | ||
} | ||
|
||
[Theory] | ||
[InlineData("083000000", "83", "000000")] | ||
[InlineData("083999999", "83", "999999")] | ||
public void Parse_Known_NonGeographicPhoneNumber_SharedCost(string value, string NationalDestinationCode, string subscriberNumber) | ||
{ | ||
var parseResult = s_parser.Parse(value); | ||
parseResult.ThrowIfFailure(); | ||
|
||
var phoneNumber = parseResult.PhoneNumber; | ||
|
||
Assert.NotNull(phoneNumber); | ||
Assert.IsType<NonGeographicPhoneNumber>(phoneNumber); | ||
|
||
var nonGeographicPhoneNumber = (NonGeographicPhoneNumber)phoneNumber; | ||
Assert.Equal(CountryInfo.Montenegro, nonGeographicPhoneNumber.Country); | ||
Assert.False(nonGeographicPhoneNumber.IsFreephone); | ||
Assert.False(nonGeographicPhoneNumber.IsMachineToMachine); | ||
Assert.False(nonGeographicPhoneNumber.IsPremiumRate); | ||
Assert.True(nonGeographicPhoneNumber.IsSharedCost); | ||
Assert.Equal(NationalDestinationCode, nonGeographicPhoneNumber.NationalDestinationCode); | ||
Assert.Equal(subscriberNumber, nonGeographicPhoneNumber.SubscriberNumber); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters