public void DutchPhoneNumberValidator_Emergency_Invalid()
        {
            DutchPhoneNumberValidator testSubject = new DutchPhoneNumberValidator("message {0}", "tag", false)
            {
                Categories = PhoneNumberCategories.Emergency
            };

            EntLib.ValidationResults results = testSubject.Validate("113");
            Assert.IsFalse(results.IsValid);

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

            results = testSubject.Validate("11613");
            Assert.IsFalse(results.IsValid);

            testSubject = new DutchPhoneNumberValidator("message {0}", "tag", true)
            {
                Categories = PhoneNumberCategories.Emergency
            };
            results = testSubject.Validate("113");
            Assert.IsTrue(results.IsValid);

            results = testSubject.Validate("1a4");
            Assert.IsTrue(results.IsValid);

            results = testSubject.Validate("11613");
            Assert.IsTrue(results.IsValid);
        }
        public void DutchPhoneNumberValidator_Configuration_NamedValidator()
        {
            DutchPhoneNumberValidator testSubject = new DutchPhoneNumberValidator("Custom Validator", "message {0}", "tag", false);
            string input = "+31582141740";

            EntLib.ValidationResults results = testSubject.Validate(input);
            Assert.IsFalse(results.IsValid, input);
        }
        public void DutchPhoneNumberValidator_Regular_IncludeAreaCodes()
        {
            DutchPhoneNumberValidator testSubject = new DutchPhoneNumberValidator("message {0}", "tag", false)
            {
                Categories = PhoneNumberCategories.Regular, AllowCountryCallingCode = true, IncludeAreaCodes = "012;013"
            };
            string input = "+31122151740";

            EntLib.ValidationResults results = testSubject.Validate(input);
            Assert.IsTrue(results.IsValid);

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

            input   = "0031582151740";
            results = testSubject.Validate(input);
            Assert.IsFalse(results.IsValid);
        }
        public void DutchPhoneNumberValidator_Regular_NoCountryCode_ExcludeAreaCodes_WithCarrierPreselect()
        {
            DutchPhoneNumberValidator testSubject = new DutchPhoneNumberValidator("message {0}", "tag", false)
            {
                Categories = PhoneNumberCategories.Regular, ExcludeAreaCodes = "058;020", AllowCountryCallingCode = false, AllowCarrierPreselect = true, IncludeAreaCodes = null
            };
            string input = "+31502151740";

            EntLib.ValidationResults results = testSubject.Validate(input);
            Assert.IsFalse(results.IsValid);

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

            input   = "16990582151740";
            results = testSubject.Validate(input);
            Assert.IsFalse(results.IsValid);
        }
        public void DutchPhoneNumberValidator_Configuration()
        {
            DutchPhoneNumberValidator testSubject = new DutchPhoneNumberValidator("message {0}", "tag", false);
            string input = "+31582141740";

            EntLib.ValidationResults results = testSubject.Validate(input);
            Assert.IsTrue(results.IsValid, input);

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

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

            input   = "+31519214174";
            results = testSubject.Validate(input);
            Assert.IsTrue(results.IsValid, input);
        }
        public void DutchPhoneNumberValidator_Default()
        {
            DutchPhoneNumberValidator testSubject = new DutchPhoneNumberValidator("message {0}", "tag", false)
            {
                Categories = PhoneNumberCategories.Default, AllowCountryCallingCode = true, IncludeAreaCodes = null
            };
            string input    = this.TestContext.DataRow["PhoneNumber"].ToString();
            bool   expected = Convert.ToBoolean(this.TestContext.DataRow["IsValid"]);

            EntLib.ValidationResults results = testSubject.Validate(input);
            Assert.AreEqual(expected, results.IsValid, input);

            testSubject = new DutchPhoneNumberValidator("message {0}", "tag", true)
            {
                Categories = PhoneNumberCategories.Default, AllowCountryCallingCode = true, IncludeAreaCodes = null
            };
            results = testSubject.Validate(input);
            Assert.AreEqual(!expected, results.IsValid, input);
        }
        public void DutchPhoneNumberValidator_Service()
        {
            DutchPhoneNumberValidator testSubject = new DutchPhoneNumberValidator("message {0}", "tag", false)
            {
                Categories = PhoneNumberCategories.Service
            };
            string input    = this.TestContext.DataRow["PhoneNumber"].ToString();
            bool   expected = Convert.ToBoolean(this.TestContext.DataRow["IsValid"]);

            EntLib.ValidationResults results = testSubject.Validate(input);
            Assert.AreEqual(expected, results.IsValid);

            testSubject = new DutchPhoneNumberValidator("message {0}", "tag", true)
            {
                Categories = PhoneNumberCategories.Service
            };
            results = testSubject.Validate(input);
            Assert.AreEqual(!expected, results.IsValid, input);
        }
        public void DutchPhoneNumberValidator_Other()
        {
            DutchPhoneNumberValidator testSubject = new DutchPhoneNumberValidator("message {0}", "tag", false)
            {
                Categories = PhoneNumberCategories.Other, AllowCountryCallingCode = true
            };
            string input = this.TestContext.DataRow["PhoneNumber"].ToString();
            bool   containsCarrierPreselect = Convert.ToBoolean(this.TestContext.DataRow["ContainsCarrierPreselect"]);
            bool   expected = !containsCarrierPreselect && Convert.ToBoolean(this.TestContext.DataRow["IsValid"]);

            EntLib.ValidationResults results = testSubject.Validate(input);
            Assert.AreEqual(expected, results.IsValid);

            testSubject = new DutchPhoneNumberValidator("message {0}", "tag", true)
            {
                Categories = PhoneNumberCategories.Other, AllowCountryCallingCode = true
            };
            results = testSubject.Validate(input);
            Assert.AreEqual(!expected, results.IsValid, input);
        }