コード例 #1
0
        [TestMethod] public void testEmergency()
        {
            int wrongTypeCounter = 0;

            foreach (String regionCode in shortNumberInfo.getSupportedRegions())
            {
                PhoneNumberDesc desc =
                    MetadataManager.getShortNumberMetadataForRegion(regionCode).getEmergency();
                if (desc.HasExampleNumber())
                {
                    String exampleNumber = desc.getExampleNumber();
                    if (!Regex.IsMatch(exampleNumber, desc.getPossibleNumberPattern()) ||
                        !shortNumberInfo.isEmergencyNumber(exampleNumber, regionCode))
                    {
                        wrongTypeCounter++;
                        LOGGER.log(Level.SEVERE, "Emergency example number test failed for " + regionCode);
                    }
                    else if (shortNumberInfo.getExpectedCostForRegion(exampleNumber, regionCode) !=
                             ShortNumberInfo.ShortNumberCost.TOLL_FREE)
                    {
                        wrongTypeCounter++;
                        LOGGER.log(Level.WARNING, "Emergency example number not toll free for " + regionCode);
                    }
                }
            }
            Assert.AreEqual(0, wrongTypeCounter);
        }
コード例 #2
0
 [TestMethod] public void testIsEmergencyNumber_US()
 {
     Assert.IsTrue(shortInfo.isEmergencyNumber("911", RegionCode.US));
     Assert.IsTrue(shortInfo.isEmergencyNumber("112", RegionCode.US));
     Assert.IsFalse(shortInfo.isEmergencyNumber("999", RegionCode.US));
 }