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); }
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); } }
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); } }
public void Password_ValidationRule_Should_Have_An_Error(string password) { _validator.ShouldHaveValidationErrorFor(x => x.Password, password) .WithErrorCode(ErrorCodes.PasswordFormatIsNotValid); }
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 = "******"); }
public void Email_ValidationRule_Should_Have_An_Error(string email) { _validator.ShouldHaveValidationErrorFor(x => x.Email, email) .WithErrorCode(ErrorCodes.EmailFormatIsNotValid); }