Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorPilley committed Dec 4, 2023
1 parent 309ee5b commit b084972
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/PhoneNumbers/CountryInfo_Europe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ namespace PhoneNumbers;

public partial class CountryInfo
{
/// <summary>
/// Gets the <see cref="CountryInfo"/> for Albania.
/// </summary>
public static CountryInfo Albania { get; } = new()
{
CallingCode = "355",
Continent = Europe,
Iso3166Code = "AL",
Name = "Albania",
NsnLengths = new ReadOnlyCollection<int>(new[] { 8 }),
TrunkPrefix = "0",
};

/// <summary>
/// Gets the <see cref="CountryInfo"/> for Austria.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/PhoneNumbers/DataFiles/AL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# References:
# - https://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000020002PDFE.pdf
20 changes: 20 additions & 0 deletions test/PhoneNumbers.Tests/CountryInfo_Europe_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ namespace PhoneNumbers.Tests;

public class CountryInfo_Europe_Tests
{
[Fact]
public void CountryInfo_Albania()
{
Assert.Same(CountryInfo.Albania, CountryInfo.Albania);

var countryInfo = CountryInfo.Albania;

Assert.False(countryInfo.AllowsLocalGeographicDialling);
Assert.Equal("355", countryInfo.CallingCode);
Assert.Equal(CountryInfo.Europe, countryInfo.Continent);
Assert.IsType<ComplexPhoneNumberFormatProvider>(countryInfo.FormatProvider);
Assert.False(countryInfo.IsEuropeanUnionMember);
Assert.Equal("AL", countryInfo.Iso3166Code);
Assert.Equal("Albania", countryInfo.Name);
Assert.Empty(countryInfo.NdcLengths);
Assert.Equal(new[] { 8 }, countryInfo.NsnLengths);
Assert.False(countryInfo.SharesCallingCode);
Assert.Equal("0", countryInfo.TrunkPrefix);
}

[Fact]
public void CountryInfo_Austria()
{
Expand Down
8 changes: 8 additions & 0 deletions test/PhoneNumbers.Tests/PhoneNumber_Parse_Europe_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ namespace PhoneNumbers.Tests;

public class PhoneNumber_Parse_Europe_Tests
{
[Fact]
public void Parse_Value_For_Albania_CallingCode()
{
var phoneNumber = PhoneNumber.Parse("+35542259571");
Assert.NotNull(phoneNumber);
Assert.Equal(CountryInfo.Albania, phoneNumber.Country);
}

[Fact]
public void Parse_Value_For_Austria_CallingCode()
{
Expand Down
7 changes: 7 additions & 0 deletions test/PhoneNumbers.Tests/PhoneNumber_ToString_Europe_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ namespace PhoneNumbers.Tests;

public class PhoneNumber_ToString_Europe_Tests
{
[Theory]
[InlineData("+35542259571", "E.123", "+355 4 2259571")]
[InlineData("+35542259571", "N", "04 2259571")]
[InlineData("+35542259571", "RFC3966", "tel:+355-4-2259571")]
public void Albania_Numbers(string input, string format, string expected) =>
Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format));

[Theory]
[InlineData("+375172171185", "E.123", "+375 17 2171185")]
[InlineData("+375172171185", "N", "817 2171185")]
Expand Down

0 comments on commit b084972

Please sign in to comment.