コード例 #1
0
        public void TestEmergency()
        {
            ShortNumberUtil shortUtil        = new ShortNumberUtil(phoneNumberUtil);
            int             wrongTypeCounter = 0;

            foreach (var regionCode in phoneNumberUtil.GetSupportedRegions())
            {
                PhoneNumberDesc desc =
                    phoneNumberUtil.GetMetadataForRegion(regionCode).Emergency;
                if (desc.HasExampleNumber)
                {
                    String exampleNumber = desc.ExampleNumber;
                    if (!new PhoneRegex(desc.PossibleNumberPattern).MatchAll(exampleNumber).Success ||
                        !shortUtil.IsEmergencyNumber(exampleNumber, regionCode))
                    {
                        wrongTypeCounter++;
                        // LOGGER.log(Level.SEVERE, "Emergency example number Test failed for " + regionCode);
                    }
                }
            }
            Assert.Equal(0, wrongTypeCounter);
        }
コード例 #2
0
 public void testIsEmergencyNumber_US()
 {
     Assert.IsTrue(shortUtil.IsEmergencyNumber("911", RegionCode.US));
     Assert.IsTrue(shortUtil.IsEmergencyNumber("119", RegionCode.US));
     Assert.IsFalse(shortUtil.IsEmergencyNumber("999", RegionCode.US));
 }
コード例 #3
0
 public void TestEmergency()
 {
     ShortNumberUtil shortUtil = new ShortNumberUtil(phoneNumberUtil);
     int wrongTypeCounter = 0;
     foreach(var regionCode in phoneNumberUtil.GetSupportedRegions())
     {
         PhoneNumberDesc desc =
             phoneNumberUtil.GetMetadataForRegion(regionCode).Emergency;
         if (desc.HasExampleNumber)
         {
             String exampleNumber = desc.ExampleNumber;
             if (!new PhoneRegex(desc.PossibleNumberPattern).MatchAll(exampleNumber).Success ||
                 !shortUtil.IsEmergencyNumber(exampleNumber, regionCode))
             {
                 wrongTypeCounter++;
             // LOGGER.log(Level.SEVERE, "Emergency example number test failed for " + regionCode);
             }
         }
     }
     Assert.AreEqual(0, wrongTypeCounter);
 }