public void ShouldNotHaveErrorWhenPasswordsMatch(string password) { var viewModel = new RegisterViewModel { Password = password, ConfirmPassword = password }; var viewModelServerValidator = new RegisterViewModelServerValidator(); viewModelServerValidator.ShouldNotHaveValidationErrorFor(x => x.Password, viewModel); }
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); } }
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); } }