Пример #1
0
        public void DutchPhoneNumberAttribute_Emergency_Invalid()
        {
            DutchPhoneNumberAttribute testSubject = new DutchPhoneNumberAttribute {
                Categories = PhoneNumberCategories.Emergency
            };
            bool result = testSubject.IsValid("113");

            Assert.IsFalse(result);

            result = testSubject.IsValid("1a4");
            Assert.IsFalse(result);

            result = testSubject.IsValid("11613");
            Assert.IsFalse(result);
        }
Пример #2
0
        public void DutchPhoneNumberAttribute_Emergency_Valid()
        {
            DutchPhoneNumberAttribute testSubject = new DutchPhoneNumberAttribute {
                Categories = PhoneNumberCategories.Emergency
            };
            bool result = testSubject.IsValid("112");

            Assert.IsTrue(result);

            result = testSubject.IsValid("144");
            Assert.IsTrue(result);

            result = testSubject.IsValid("116123");
            Assert.IsTrue(result);
        }
Пример #3
0
        public void DutchPhoneNumberAttribute_Configuration_NamedValidator()
        {
            DutchPhoneNumberAttribute testSubject = new DutchPhoneNumberAttribute("Custom Validator");
            string input  = "+31582141740";
            bool   result = testSubject.IsValid(input);

            Assert.IsFalse(result, input);
        }
Пример #4
0
        public void DutchPhoneNumberAttribute_Regular_IncludeAreaCodes()
        {
            DutchPhoneNumberAttribute testSubject = new DutchPhoneNumberAttribute {
                Categories = PhoneNumberCategories.Regular, AllowCountryCallingCode = true, IncludeAreaCodes = "012;013"
            };
            string input  = "+31122151740";
            bool   result = testSubject.IsValid(input);

            Assert.IsTrue(result);

            input  = "16420031122151740";
            result = testSubject.IsValid(input);
            Assert.IsFalse(result);

            input  = "0031582151740";
            result = testSubject.IsValid(input);
            Assert.IsFalse(result);
        }
Пример #5
0
        public void DutchPhoneNumberAttribute_Regular_NoCountryCode_ExcludeAreaCodes_WithCarrierPreselect()
        {
            DutchPhoneNumberAttribute testSubject = new DutchPhoneNumberAttribute {
                Categories = PhoneNumberCategories.Regular, ExcludeAreaCodes = "058;020", AllowCountryCallingCode = false, AllowCarrierPreselect = true, IncludeAreaCodes = null
            };
            string input  = "+31502151740";
            bool   result = testSubject.IsValid(input);

            Assert.IsFalse(result);

            input  = "16000031582151740";
            result = testSubject.IsValid(input);
            Assert.IsFalse(result);

            input  = "16990582151740";
            result = testSubject.IsValid(input);
            Assert.IsFalse(result);
        }
Пример #6
0
        public void DutchPhoneNumberAttribute_Configuration()
        {
            DutchPhoneNumberAttribute testSubject = new DutchPhoneNumberAttribute();
            string input  = "+31582141740";
            bool   result = testSubject.IsValid(input);

            Assert.IsTrue(result, input);

            input  = "1688582141740";
            result = testSubject.IsValid(input);
            Assert.IsFalse(result, input);

            input  = "+31202141740";
            result = testSubject.IsValid(input);
            Assert.IsFalse(result, input);

            input  = "+31519214174";
            result = testSubject.IsValid(input);
            Assert.IsTrue(result, input);
        }
Пример #7
0
        public void DutchPhoneNumberAttribute_Mobile_NoCountryCode()
        {
            DutchPhoneNumberAttribute testSubject = new DutchPhoneNumberAttribute {
                Categories = PhoneNumberCategories.Mobile, AllowCountryCallingCode = false, IncludeAreaCodes = null
            };
            string input = this.TestContext.DataRow["PhoneNumber"].ToString();
            bool   containsCarrierPreselect = Convert.ToBoolean(this.TestContext.DataRow["ContainsCarrierPreselect"]);
            bool   expected = !containsCarrierPreselect && Convert.ToBoolean(this.TestContext.DataRow["IsValid"]) && !Convert.ToBoolean(this.TestContext.DataRow["ContainsCountryAccessCode"]);
            bool   result   = testSubject.IsValid(input);

            Assert.AreEqual(expected, result);
        }
Пример #8
0
        public void DutchPhoneNumberAttribute_Regular_NoCountryCode_IncludeAreaCodes_WithCarrierPreselect()
        {
            DutchPhoneNumberAttribute testSubject = new DutchPhoneNumberAttribute {
                Categories = PhoneNumberCategories.Regular, IncludeAreaCodes = "012;013", AllowCountryCallingCode = false, AllowCarrierPreselect = true
            };
            string input  = "+31122151740";
            bool   result = testSubject.IsValid(input);

            Assert.IsFalse(result);

            input  = "16420122151740";
            result = testSubject.IsValid(input);
            Assert.IsTrue(result);

            input  = "105880031582151740";
            result = testSubject.IsValid(input);
            Assert.IsFalse(result);

            input  = "109420582151740";
            result = testSubject.IsValid(input);
            Assert.IsFalse(result);
        }