public void TestParseSingleMobile() { PhoneNoParser parser2 = new PhoneNoParser(TestUtility.CreateParserContext("+86 13482572088", ParserPattern.China)); ParseResultCollection prc2 = parser2.Parse(0); Assert.AreEqual(1, prc2.Count); TestUtility.AssertParseResult(prc2[0], "+86 13482572088", 0, POSType.A_M); AssertPhoneValue(prc2[0], "86", null, "13482572088", null, true); }
public void TestParseSingleIllegalPhone() { PhoneNoParser parser = new PhoneNoParser(TestUtility.CreateParserContext(" ", ParserPattern.China)); ParseResultCollection prc = parser.Parse(0); Assert.AreEqual(0, prc.Count); parser = new PhoneNoParser(TestUtility.CreateParserContext("611212341", ParserPattern.China)); prc = parser.Parse(0); Assert.AreEqual(0, prc.Count); parser = new PhoneNoParser(TestUtility.CreateParserContext("2", ParserPattern.China)); prc = parser.Parse(0); Assert.AreEqual(0, prc.Count); parser = new PhoneNoParser(TestUtility.CreateParserContext("23", ParserPattern.China)); prc = parser.Parse(0); Assert.AreEqual(0, prc.Count); }
public void TestParseSingleNorthAmericanPhone() { PhoneNoParser parser = new PhoneNoParser(TestUtility.CreateParserContext("+1-415-555-2374", ParserPattern.NorthAmerica)); ParseResultCollection prc = parser.Parse(0); Assert.AreEqual(1, prc.Count); TestUtility.AssertParseResult(prc[0], "+1-415-555-2374", 0, POSType.A_M); AssertPhoneValue(prc[0], "1", "415", "555-2374", null, true); parser = new PhoneNoParser(TestUtility.CreateParserContext("(800) 628-1058", ParserPattern.NorthAmerica)); prc = parser.Parse(0); Assert.AreEqual(1, prc.Count); TestUtility.AssertParseResult(prc[0], "(800) 628-1058", 0, POSType.A_M); AssertPhoneValue(prc[0], null, "800", "628-1058", null, true); }
public void TestParseSinglePhoneWithExtension() { PhoneNoParser parser = new PhoneNoParser(TestUtility.CreateParserContext("+86 21 62253302#302", ParserPattern.China)); ParseResultCollection prc = parser.Parse(0); Assert.AreEqual(1, prc.Count); TestUtility.AssertParseResult(prc[0], "+86 21 62253302#302", 0, POSType.A_M); AssertPhoneValue(prc[0], "86", "21", "62253302", "302"); parser = new PhoneNoParser(TestUtility.CreateParserContext("+86 21 62253302#302", ParserPattern.China)); prc = parser.Parse(0); Assert.AreEqual(1, prc.Count); TestUtility.AssertParseResult(prc[0], "+86 21 62253302#302", 0, POSType.A_M); AssertPhoneValue(prc[0], "86", "21", "62253302", "302"); parser = new PhoneNoParser(TestUtility.CreateParserContext("+86 21 62253302#302a", ParserPattern.China)); prc = parser.Parse(0); Assert.AreEqual(1, prc.Count); TestUtility.AssertParseResult(prc[0], "+86 21 62253302#302", 0, POSType.A_M); AssertPhoneValue(prc[0], "86", "21", "62253302", "302"); }
public void TestParseSinglePhone() { PhoneNoParser parser = new PhoneNoParser(TestUtility.CreateParserContext("(021)6655 2433", ParserPattern.China)); ParseResultCollection prc = parser.Parse(0); Assert.AreEqual(1, prc.Count); TestUtility.AssertParseResult(prc[0], "(021)6655 2433", 0, POSType.A_M); AssertPhoneValue(prc[0], null, "021", "6655 2433", null); parser = new PhoneNoParser(TestUtility.CreateParserContext("021-64393615", ParserPattern.China)); prc = parser.Parse(0); Assert.AreEqual(1, prc.Count); TestUtility.AssertParseResult(prc[0], "021-64393615", 0, POSType.A_M); AssertPhoneValue(prc[0], null, "021", "64393615", null); PhoneNoParser parser2 = new PhoneNoParser(TestUtility.CreateParserContext("+86 21 6225 3302", ParserPattern.China)); ParseResultCollection prc2 = parser2.Parse(0); Assert.AreEqual(1, prc2.Count); TestUtility.AssertParseResult(prc2[0], "+86 21 6225 3302", 0, POSType.A_M); AssertPhoneValue(prc2[0], "86", "21", "6225 3302", null); parser2 = new PhoneNoParser(TestUtility.CreateParserContext("电话号码:62253302", ParserPattern.China)); prc2 = parser2.Parse(0); Assert.AreEqual(0, prc2.Count); prc2 = parser2.Parse(5); Assert.AreEqual(1, prc2.Count); TestUtility.AssertParseResult(prc2[0], "62253302", 5, POSType.A_M); AssertPhoneValue(prc2[0], null, null, "62253302", null); parser2 = new PhoneNoParser(TestUtility.CreateParserContext("13566223388(手机)", ParserPattern.China)); prc2 = parser2.Parse(0); Assert.AreEqual(1, prc2.Count); TestUtility.AssertParseResult(prc2[0], "13566223388", 0, POSType.A_M); }