Exemplo n.º 1
0
        public void ShouldReturnFalseForValueType()
        {
            decimal   testValue            = 12345;
            Validator mobilePhoneValidator = new MobilePhoneValidator(testValue);

            Assert.IsFalse(mobilePhoneValidator.Validate());
        }
Exemplo n.º 2
0
        public void ShouldReturnFalseForEmptyObject()
        {
            object    testValue            = new object();
            Validator mobilePhoneValidator = new MobilePhoneValidator(testValue);

            Assert.IsFalse(mobilePhoneValidator.Validate());
        }
Exemplo n.º 3
0
        public void ShouldReturnFalseForIncorrectMobilePhone()
        {
            string[] testValues = new string[] { "+48696588", "+4869658813", "+486965881", "+48 696 588", "+48 696 588 13", "+48 696 588 1", "some text", string.Empty };

            foreach (string item in testValues)
            {
                Validator mobilePhoneValidator = new MobilePhoneValidator(item);
                Assert.IsFalse(mobilePhoneValidator.Validate());
            }
        }
Exemplo n.º 4
0
        public void ShouldReturnTrueForCorrectMobilePhone()
        {
            string[] testValues = new string[] { "+48696588133", "48696588133", "48 696 588 133", "+48 696 588 133", "+48 696 588 133" };

            foreach (string item in testValues)
            {
                Validator mobilePhoneValidator = new MobilePhoneValidator(item);
                Assert.IsTrue(mobilePhoneValidator.Validate());
            }
        }
        public void ErrorMessage_CustomFormat_AreEqual()
        {
            string column = "測試欄位";

            MobilePhoneValidator validator = new MobilePhoneValidator(column, "error", "{0}MobilePhone");

            validator.Validate();

            Assert.AreEqual(
                string.Format(validator.CustomErrorMessageFormat, column),
                validator.ErrorMessage
                );
        }
        public void ErrorMessage_BasicFormat_AreEqual()
        {
            string column = "測試欄位";

            MobilePhoneValidator validator = new MobilePhoneValidator(column, "error");

            validator.Validate();

            Assert.AreEqual(
                string.Format(validator.DefaultErrorMessageFormat, column),
                validator.ErrorMessage
                );
        }
        public void Validate_ReturnValue_AreEqual(string value, bool isValid)
        {
            MobilePhoneValidator validator = new MobilePhoneValidator("", value);

            Assert.AreEqual(validator.Validate(), isValid);
        }