public void op_ToServiceType_string(string expected, string telephone) { var actual = BritishTelephone.ToServiceType(telephone); Assert.Equal(expected, actual); }
public void op_ToNumberGroups_string_string(string expected, string areaCode, string telephone) { var actual = BritishTelephone.ToNumberGroups(areaCode, telephone); Assert.Equal(expected, actual); }
public void op_Load_BritishTelephoneNumberPlan_Telephone_whenInvalid(string number) { var plan = BritishTelephoneNumberPlan.Load(new FileInfo("sabc.csv")); Telephone telephone = number; var actual = BritishTelephone.Load(plan, telephone); Assert.Empty(actual.Area); Assert.Empty(actual.AreaCode); Assert.Empty(actual.NumberGroups); Assert.Empty(actual.DialingCode); Assert.Empty(actual.LocalNumber); Assert.Empty(actual.ServiceType); Assert.Equal(telephone, actual.Number); Assert.False(actual.IsValid); }
public static BritishTelephone Load(BritishTelephoneNumberPlan plan, Telephone telephone) { if (null == plan) { throw new ArgumentNullException("plan"); } if (null == telephone) { throw new ArgumentNullException("telephone"); } var result = new BritishTelephone { Number = telephone, AreaCode = string.Empty, Area = string.Empty, NumberGroups = string.Empty, DialingCode = string.Empty, LocalNumber = string.Empty, ServiceType = string.Empty, }; var item = plan.Item(telephone); if (null == item) { return(result); } var valid = item.Use.IndexOf("Unassigned", StringComparison.OrdinalIgnoreCase).Is(-1); result.Number = telephone; result.AreaCode = item.AreaCode; result.Area = item.Use; result.LocalNumber = ToLocalNumber(item.DialingCode, telephone.Number); result.NumberGroups = ToNumberGroups(item.AreaCode, telephone.Number); result.DialingCode = item.DialingCode; result.ServiceType = ToServiceType(telephone.Number); result.IsValid = valid; return(result); }
public void op_Load_BritishTelephoneNumberPlan_Telephone(string number, bool valid, string area, string areaCode, string numberGroups, string dialingCode, string localNumber, string serviceType) { var plan = BritishTelephoneNumberPlan.Load(new FileInfo("sabc.csv")); Telephone telephone = number; var actual = BritishTelephone.Load(plan, telephone); Assert.Equal(area, actual.Area); Assert.Equal(areaCode, actual.AreaCode); Assert.Equal(numberGroups, actual.NumberGroups); Assert.Equal(dialingCode, actual.DialingCode); Assert.Equal(localNumber, actual.LocalNumber); Assert.Equal(serviceType, actual.ServiceType); Assert.Equal(telephone, actual.Number); Assert.Equal(valid, actual.IsValid); }
public void op_ToLocalNumber_string_stringEmpty() { Assert.Empty(BritishTelephone.ToLocalNumber("01234", string.Empty)); }
public void op_ToLocalNumber_stringNull_string() { Assert.Empty(BritishTelephone.ToLocalNumber(null, "+441483999999")); }
public void op_ToLocalNumber_stringEmpty_string() { Assert.Empty(BritishTelephone.ToLocalNumber(string.Empty, "+441483999999")); }
public void op_Load_BritishTelephoneNumberPlan_TelephoneNull() { Assert.Throws <ArgumentNullException>(() => BritishTelephone.Load(new BritishTelephoneNumberPlan(), null)); }
public void op_Load_BritishTelephoneNumberPlanNull_Telephone() { Assert.Throws <ArgumentNullException>(() => BritishTelephone.Load(null, "(01234) 567 890")); }
public void op_ToServiceType_string_whenFormatException(string telephone) { Assert.Throws <FormatException>(() => BritishTelephone.ToServiceType(telephone)); }
public void op_ToServiceType_stringNull() { Assert.Throws <ArgumentNullException>(() => BritishTelephone.ToServiceType(null)); }
public void op_ToNumberGroups_string_stringNull() { Assert.Throws <ArgumentNullException>(() => BritishTelephone.ToNumberGroups("01234", null)); }
public void op_ToNumberGroups_stringNull_string() { Assert.Empty(BritishTelephone.ToNumberGroups(null, "+441483999999")); }
public void op_ToNumberGroups_stringEmpty_string() { Assert.Empty(BritishTelephone.ToNumberGroups(string.Empty, "+441483999999")); }
public static BritishTelephone Load(BritishTelephoneNumberPlan plan, Telephone telephone) { if (null == plan) { throw new ArgumentNullException("plan"); } if (null == telephone) { throw new ArgumentNullException("telephone"); } var result = new BritishTelephone { Number = telephone, AreaCode = string.Empty, Area = string.Empty, NumberGroups = string.Empty, DialingCode = string.Empty, LocalNumber = string.Empty, ServiceType = string.Empty, }; var item = plan.Item(telephone); if (null == item) { return result; } var valid = item.Use.IndexOf("Unassigned", StringComparison.OrdinalIgnoreCase).Is(-1); result.Number = telephone; result.AreaCode = item.AreaCode; result.Area = item.Use; result.LocalNumber = ToLocalNumber(item.DialingCode, telephone.Number); result.NumberGroups = ToNumberGroups(item.AreaCode, telephone.Number); result.DialingCode = item.DialingCode; result.ServiceType = ToServiceType(telephone.Number); result.IsValid = valid; return result; }