public void ShouldAllowOnlyWhitelistedCharacters() { var viewModel = new FeedbackViewModel { Email = "<sqlattacker>@example.com", Name = "<baz>", Details = "<script>" }; var viewModelValidator = new FeedbackClientViewModelValidator(); viewModelValidator.ShouldHaveValidationErrorFor(x => x.Name, viewModel); viewModelValidator.ShouldHaveValidationErrorFor(x => x.Email, viewModel); viewModelValidator.ShouldHaveValidationErrorFor(x => x.Details, viewModel); }
public void ShouldRequireDetails() { var viewModel = new FeedbackViewModel(); var viewModelValidator = new FeedbackClientViewModelValidator(); viewModelValidator.ShouldHaveValidationErrorFor(x => x.Details, viewModel); }
public void ShouldNotAllowDetailsWhenTooLong() { var viewModel = new FeedbackViewModel { Details = new string('X', 4001) }; var viewModelValidator = new FeedbackClientViewModelValidator(); viewModelValidator.ShouldHaveValidationErrorFor(x => x.Details, viewModel); }
public void ShouldNotAllowEmailWhenTooLong() { var viewModel = new FeedbackViewModel { Email = "baz@" + new string('X', 100) + ".com" }; var viewModelValidator = new FeedbackClientViewModelValidator(); viewModelValidator.ShouldHaveValidationErrorFor(x => x.Email, viewModel); }
public void ShouldNotAllowNameWhenTooLong() { var viewModel = new FeedbackViewModel { Name = new string('X', 72) }; var viewModelValidator = new FeedbackClientViewModelValidator(); viewModelValidator.ShouldHaveValidationErrorFor(x => x.Name, viewModel); }