コード例 #1
0
        public void ShouldNotHaveErrorWhenPasswordsMatch(string password)
        {
            var viewModel = new RegisterViewModel
            {
                Password        = password,
                ConfirmPassword = password
            };
            var viewModelServerValidator = new RegisterViewModelServerValidator();

            viewModelServerValidator.ShouldNotHaveValidationErrorFor(x => x.Password, viewModel);
        }
コード例 #2
0
        public void ShouldWhitelistLastName(string lastName, bool expectValid)
        {
            // Arrange.
            var viewModel = new RegisterViewModel
            {
                Lastname = lastName
            };

            // Act.
            var validator = new RegisterViewModelServerValidator();

            // Assert.
            if (expectValid)
            {
                validator.ShouldNotHaveValidationErrorFor(vm => vm.Lastname, viewModel);
            }
            else
            {
                validator.ShouldHaveValidationErrorFor(vm => vm.Lastname, viewModel);
            }
        }
コード例 #3
0
        public void ShouldRequireLastName(int?length, bool expectValid)
        {
            // Arrange.
            var viewModel = new RegisterViewModel
            {
                Lastname = length.HasValue ? new string('X', length.Value) : null
            };

            // Act.
            var validator = new RegisterViewModelServerValidator();

            // Assert.
            if (expectValid)
            {
                validator.ShouldNotHaveValidationErrorFor(vm => vm.Lastname, viewModel);
            }
            else
            {
                validator.ShouldHaveValidationErrorFor(vm => vm.Lastname, viewModel);
            }
        }