public void ctor() { var plan = new BritishTelephoneNumberPlan { { "example", new BritishTelephoneNumberPlanItem() } }; Assert.True(plan.ContainsKey("example")); Assert.False(plan.ContainsKey("Example")); }
public void op_Item_string_whenNullResult(string telephone) { var plan = new BritishTelephoneNumberPlan(); Assert.Null(plan.Item(telephone)); }
public void op_Item_stringNull() { var plan = new BritishTelephoneNumberPlan(); Assert.Throws<ArgumentNullException>(() => plan.Item(null)); }
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; }