Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorPilley committed Nov 21, 2024
1 parent 26f8927 commit 6118bd5
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/PhoneNumbers/CountryInfo_Africa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,18 @@ public partial class CountryInfo
NsnLengths = new ReadOnlyCollection<int>([9, 12]),
TrunkPrefix = "0",
};

/// <summary>
/// Gets the <see cref="CountryInfo"/> for Uganda.
/// </summary>
public static CountryInfo Uganda { get; } = new()
{
CallingCode = "256",
Continent = Africa,
Iso3166Code = "UG",
Name = "Uganda",
NdcLengths = new ReadOnlyCollection<int>([6, 5, 4, 3, 1]),
NsnLengths = new ReadOnlyCollection<int>([9]),
TrunkPrefix = "0",
};
}
9 changes: 9 additions & 0 deletions src/PhoneNumbers/DataFiles/UG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Reference: https://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000F10014PDFE.pdf
# Reference Date: 27/09/2023
N|200-201,207||000000-999999|
N|20240,20611||0000-9999|
N|2031-2032,2050-2054||00000-99999|
N|206300-206304||000-999|
N|3-4||00000000-99999999|
M|700-720,740-744,750-765,770-789||000000-999999|
M|7240,7260,7280,7660-7664||00000-99999|
20 changes: 20 additions & 0 deletions test/PhoneNumbers.Tests/CountryInfo_Africa_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,24 @@ public void CountryInfo_Tanzania()
Assert.False(countryInfo.SharesCallingCode);
Assert.Equal("0", countryInfo.TrunkPrefix);
}

[Fact]
public void CountryInfo_Uganda()
{
Assert.Same(CountryInfo.Uganda, CountryInfo.Uganda);

var countryInfo = CountryInfo.Uganda;

Assert.False(countryInfo.AllowsLocalGeographicDialling);
Assert.Equal("256", countryInfo.CallingCode);
Assert.Equal(CountryInfo.Africa, countryInfo.Continent);
Assert.IsType<ComplexPhoneNumberFormatProvider>(countryInfo.FormatProvider);
Assert.False(countryInfo.IsEuropeanUnionMember);
Assert.Equal("UG", countryInfo.Iso3166Code);
Assert.Equal("Uganda", countryInfo.Name);
Assert.Equal(new[] { 6, 5, 4, 3, 1 }, countryInfo.NdcLengths);
Assert.Equal(new[] { 9 }, countryInfo.NsnLengths);
Assert.False(countryInfo.SharesCallingCode);
Assert.Equal("0", countryInfo.TrunkPrefix);
}
}
8 changes: 8 additions & 0 deletions test/PhoneNumbers.Tests/PhoneNumber_Parse_Africa_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,12 @@ public void Parse_Value_For_Tanzania_CallingCode()
Assert.NotNull(phoneNumber);
Assert.Equal(CountryInfo.Tanzania, phoneNumber.Country);
}

[Fact]
public void Parse_Value_For_Uganda_CallingCode()
{
var phoneNumber = PhoneNumber.Parse("+256414348832");
Assert.NotNull(phoneNumber);
Assert.Equal(CountryInfo.Uganda, phoneNumber.Country);
}
}
7 changes: 7 additions & 0 deletions test/PhoneNumbers.Tests/PhoneNumber_ToString_Africa_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ public void SouthAfrica_Numbers(string input, string format, string expected) =>
[InlineData("+255222199760", "RFC3966", "tel:+255-22-219-9760")]
public void Tanzania_Numbers(string input, string format, string expected) =>
Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format));

[Theory]
[InlineData("+256414348832", "E.123", "+256 41 434 8832")]
[InlineData("+256414348832", "N", "041 434 8832")]
[InlineData("+256414348832", "RFC3966", "tel:+256-41-434-8832")]
public void Uganda_Numbers(string input, string format, string expected) =>
Assert.Equal(expected, PhoneNumber.Parse(input).ToString(format));
}

0 comments on commit 6118bd5

Please sign in to comment.