コード例 #1
0
        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);
        }
コード例 #2
0
        public void ShouldRequireDetails()
        {
            var viewModel          = new FeedbackViewModel();
            var viewModelValidator = new FeedbackClientViewModelValidator();

            viewModelValidator.ShouldHaveValidationErrorFor(x => x.Details, viewModel);
        }
コード例 #3
0
        public void ShouldNotAllowDetailsWhenTooLong()
        {
            var viewModel = new FeedbackViewModel
            {
                Details = new string('X', 4001)
            };

            var viewModelValidator = new FeedbackClientViewModelValidator();

            viewModelValidator.ShouldHaveValidationErrorFor(x => x.Details, viewModel);
        }
コード例 #4
0
        public void ShouldNotAllowEmailWhenTooLong()
        {
            var viewModel = new FeedbackViewModel
            {
                Email = "baz@" + new string('X', 100) + ".com"
            };

            var viewModelValidator = new FeedbackClientViewModelValidator();

            viewModelValidator.ShouldHaveValidationErrorFor(x => x.Email, viewModel);
        }
コード例 #5
0
        public void ShouldNotAllowNameWhenTooLong()
        {
            var viewModel = new FeedbackViewModel
            {
                Name = new string('X', 72)
            };

            var viewModelValidator = new FeedbackClientViewModelValidator();

            viewModelValidator.ShouldHaveValidationErrorFor(x => x.Name, viewModel);
        }