예제 #1
0
 [TestMethod] public void testGetExampleShortNumber()
 {
     Assert.AreEqual("8711", shortInfo.getExampleShortNumber(RegionCode.AM));
     Assert.AreEqual("1010", shortInfo.getExampleShortNumber(RegionCode.FR));
     Assert.AreEqual("", shortInfo.getExampleShortNumber(RegionCode.UN001));
     Assert.AreEqual("", shortInfo.getExampleShortNumber(null));
 }
예제 #2
0
        [TestMethod] public void testShortNumbersValidAndCorrectCost()
        {
            List <String> invalidStringCases = new List <String>();

            foreach (String regionCode in shortNumberInfo.getSupportedRegions())
            {
                String exampleShortNumber = shortNumberInfo.getExampleShortNumber(regionCode);
                if (!shortNumberInfo.isValidShortNumberForRegion(exampleShortNumber, regionCode))
                {
                    String invalidStringCase = "region_code: " + regionCode + ", national_number: " +
                                               exampleShortNumber;
                    invalidStringCases.Add(invalidStringCase);
                    LOGGER.log(Level.SEVERE, "Failed validation for string " + invalidStringCase);
                }
                PhoneNumber phoneNumber = phoneNumberUtil.parse(exampleShortNumber, regionCode);
                if (!shortNumberInfo.isValidShortNumber(phoneNumber))
                {
                    invalidCases.Add(phoneNumber);
                    LOGGER.log(Level.SEVERE, "Failed validation for " + phoneNumber.ToString());
                }

                foreach (
                    ShortNumberInfo.ShortNumberCost cost in Enum.GetValues(typeof(ShortNumberInfo.ShortNumberCost)))
                {
                    exampleShortNumber = shortNumberInfo.getExampleShortNumberForCost(regionCode, cost);
                    if (!exampleShortNumber.Equals(""))
                    {
                        if (cost != shortNumberInfo.getExpectedCostForRegion(exampleShortNumber, regionCode))
                        {
                            wrongTypeCases.Add(phoneNumber);
                            LOGGER.log(Level.SEVERE, "Wrong cost for " + phoneNumber.ToString());
                        }
                    }
                }
            }
            Assert.AreEqual(0, invalidStringCases.Count);
            Assert.AreEqual(0, invalidCases.Count);
            Assert.AreEqual(0, wrongTypeCases.Count);
        }