예제 #1
0
        public void AtLeastNCharacterValidationRulePassesWithLongString()
        {
            var validationRule = new AtLeastNCharacterValidationRule()
            {
                MinimumStringLength = 5
            };

            ValidationResult result = validationRule.Validate("1234567891011121314151617181920", CultureInfo.CurrentCulture);

            Assert.IsTrue(result.IsValid);
        }
예제 #2
0
        public void AtLeastNCharacterValidationRulePassesWithLongEnoughString()
        {
            var validationRule = new AtLeastNCharacterValidationRule()
            {
                MinimumStringLength = 4
            };

            ValidationResult result = validationRule.Validate("1234", CultureInfo.CurrentCulture);

            Assert.IsTrue(result.IsValid);
        }
예제 #3
0
        public void AtLeastNCharacterValidationRuleFailsWithEmptyStringWhenZeroCharsIsInvalid()
        {
            var validationRule = new AtLeastNCharacterValidationRule()
            {
                MinimumStringLength = 4
            };

            ValidationResult result = validationRule.Validate(string.Empty, CultureInfo.CurrentCulture);

            Assert.IsFalse(result.IsValid);
        }
예제 #4
0
        public void AtLeastNCharacterValidationRuleFailsWithShortString()
        {
            var validationRule = new AtLeastNCharacterValidationRule()
            {
                MinimumStringLength = 4
            };

            ValidationResult result = validationRule.Validate("123", CultureInfo.CurrentCulture);

            Assert.IsFalse(result.IsValid);
        }
예제 #5
0
        public void AtLeastNCharacterValidationRulePassesWithNullValueWhenZeroCharsIsValid()
        {
            var validationRule = new AtLeastNCharacterValidationRule()
            {
                MinimumStringLength   = 4,
                ZeroCharactersIsValid = true
            };

            ValidationResult result = validationRule.Validate(null, CultureInfo.CurrentCulture);

            Assert.IsTrue(result.IsValid);
        }