コード例 #1
0
        public void TagsValidationRule_Should_Have_An_Errors(int maxTagsCount)
        {
            string[] tags = Enumerable.Repeat(GetStringWithLength(5), maxTagsCount).ToArray();

            _validator.ShouldHaveValidationErrorFor(x => x.Tags, tags)
            .WithErrorCode(ErrorCodes.TagsCountIsLarge);
        }
コード例 #2
0
        public void Name_ValidationRule_Should_Have_An_Error(int minLength, int maxLength)
        {
            for (int length = 0; length < minLength; ++length)
            {
                string name = GetStringWithLength(length);
                _validator.ShouldHaveValidationErrorFor(x => x.Name, name);
            }

            for (int length = maxLength + 1; length < maxLength + 2; ++length)
            {
                string name = GetStringWithLength(length);
                _validator.ShouldHaveValidationErrorFor(x => x.Name, name);
            }
        }
コード例 #3
0
        public void TextValidationRule_Should_Have_An_Error(int minLength, int maxLength)
        {
            for (int length = 0; length < minLength; ++length)
            {
                string text = GetStringWithLength(length);
                _validator.ShouldHaveValidationErrorFor(x => x.Text, text);
            }

            for (int length = maxLength + 1; length < maxLength + 2; ++length)
            {
                string text = GetStringWithLength(length);
                _validator.ShouldHaveValidationErrorFor(x => x.Text, text);
            }
        }
コード例 #4
0
 public void Password_ValidationRule_Should_Have_An_Error(string password)
 {
     _validator.ShouldHaveValidationErrorFor(x => x.Password, password)
     .WithErrorCode(ErrorCodes.PasswordFormatIsNotValid);
 }
コード例 #5
0
        public void Is_valid_tests_lowercase()
        {
            var userSettings = new UserSettings
            {
                PasswordMinLength        = 3,
                PasswordRequireLowercase = true
            };

            _validator.RuleFor(x => x.Password).IsPassword(userSettings);

            _validator.ShouldHaveValidationErrorFor(x => x.Password, _person.Password    = "******");
            _validator.ShouldNotHaveValidationErrorFor(x => x.Password, _person.Password = "******");
        }
コード例 #6
0
 public void Email_ValidationRule_Should_Have_An_Error(string email)
 {
     _validator.ShouldHaveValidationErrorFor(x => x.Email, email)
     .WithErrorCode(ErrorCodes.EmailFormatIsNotValid);
 }