[TestMethod] public void testNationalPrefixRulesSetCorrectly() { String xmlInput = "<territory countryCode=\"33\" nationalPrefix=\"0\"" + " nationalPrefixFormattingRule=\"$NP$FG\">" + " <availableFormats>" + " <numberFormat pattern=\"(1)(\\d{3})\" nationalPrefixOptionalWhenFormatting=\"true\">" + " <leadingDigits>1</leadingDigits>" + " <format>$1</format>" + " </numberFormat>" + " <numberFormat pattern=\"(\\d{3})\" nationalPrefixOptionalWhenFormatting=\"false\">" + " <leadingDigits>2</leadingDigits>" + " <format>$1</format>" + " </numberFormat>" + " </availableFormats>" + " <fixedLine><nationalNumberPattern>\\d{1}</nationalNumberPattern></fixedLine>" + "</territory>"; XmlElement territoryElement = parseXmlString(xmlInput); PhoneMetadata metadata = BuildMetadataFromXml.loadCountryMetadata("FR", territoryElement, false /* liteBuild */, false /* isShortNumberMetadata */, true /* isAlternateFormatsMetadata */); Assert.IsTrue(metadata.getNumberFormat(0).isNationalPrefixOptionalWhenFormatting()); // This is inherited from the territory, with $NP replaced by the actual national prefix, and // $FG replaced with $1. Assert.AreEqual("0$1", metadata.getNumberFormat(0).getNationalPrefixFormattingRule()); // Here it is explicitly set to false. Assert.IsFalse(metadata.getNumberFormat(1).isNationalPrefixOptionalWhenFormatting()); }
[TestMethod] public void testAlternateFormatsOmitsDescPatterns() { String xmlInput = "<territory countryCode=\"33\">" + " <availableFormats>" + " <numberFormat pattern=\"(1)(\\d{3})\">" + " <leadingDigits>1</leadingDigits>" + " <format>$1</format>" + " </numberFormat>" + " </availableFormats>" + " <fixedLine><nationalNumberPattern>\\d{1}</nationalNumberPattern></fixedLine>" + " <shortCode><nationalNumberPattern>\\d{2}</nationalNumberPattern></shortCode>" + "</territory>"; XmlElement territoryElement = parseXmlString(xmlInput); PhoneMetadata metadata = BuildMetadataFromXml.loadCountryMetadata("FR", territoryElement, false /* liteBuild */, false /* isShortNumberMetadata */, true /* isAlternateFormatsMetadata */); Assert.AreEqual("(1)(\\d{3})", metadata.getNumberFormat(0).getPattern()); Assert.AreEqual("1", metadata.getNumberFormat(0).getLeadingDigitsPattern(0)); Assert.AreEqual("$1", metadata.getNumberFormat(0).getFormat()); Assert.IsFalse(metadata.HasFixedLine()); Assert.IsNull(metadata.getFixedLine()); Assert.IsFalse(metadata.HasShortCode()); Assert.IsNull(metadata.getShortCode()); }