예제 #1
0
        [TestMethod] public void testSetRelevantDescPatternsSetsAllDescriptionsForRegularLengthNumbers()
        {
            String xmlInput =
                "<territory countryCode=\"33\">" +
                "  <fixedLine><nationalNumberPattern>\\d{1}</nationalNumberPattern></fixedLine>" +
                "  <mobile><nationalNumberPattern>\\d{2}</nationalNumberPattern></mobile>" +
                "  <pager><nationalNumberPattern>\\d{3}</nationalNumberPattern></pager>" +
                "  <tollFree><nationalNumberPattern>\\d{4}</nationalNumberPattern></tollFree>" +
                "  <premiumRate><nationalNumberPattern>\\d{5}</nationalNumberPattern></premiumRate>" +
                "  <sharedCost><nationalNumberPattern>\\d{6}</nationalNumberPattern></sharedCost>" +
                "  <personalNumber><nationalNumberPattern>\\d{7}</nationalNumberPattern></personalNumber>" +
                "  <voip><nationalNumberPattern>\\d{8}</nationalNumberPattern></voip>" +
                "  <uan><nationalNumberPattern>\\d{9}</nationalNumberPattern></uan>" +
                "</territory>";
            XmlElement territoryElement = parseXmlString(xmlInput);

            PhoneMetadata.Builder metadata = PhoneMetadata.newBuilder();
            BuildMetadataFromXml.setRelevantDescPatterns(metadata, territoryElement, false /* liteBuild */,
                                                         false /* isShortNumberMetadata */);
            Assert.AreEqual("\\d{1}", metadata.getFixedLine().getNationalNumberPattern());
            Assert.AreEqual("\\d{2}", metadata.getMobile().getNationalNumberPattern());
            Assert.AreEqual("\\d{3}", metadata.getPager().getNationalNumberPattern());
            Assert.AreEqual("\\d{4}", metadata.getTollFree().getNationalNumberPattern());
            Assert.AreEqual("\\d{5}", metadata.getPremiumRate().getNationalNumberPattern());
            Assert.AreEqual("\\d{6}", metadata.getSharedCost().getNationalNumberPattern());
            Assert.AreEqual("\\d{7}", metadata.getPersonalNumber().getNationalNumberPattern());
            Assert.AreEqual("\\d{8}", metadata.getVoip().getNationalNumberPattern());
            Assert.AreEqual("\\d{9}", metadata.getUan().getNationalNumberPattern());
        }