public void WhenValidatingInvalidValidatableObjectCommandThenReturnsFalse() { // Assign ICommandValidator validator = new DefaultCommandValidator(); ICommand command = new ValidatableObjectCommand(false); CommandHandlerRequest request = new CommandHandlerRequest(this.configuration, command); // Act bool result = validator.Validate(request); // Assert Assert.False(result); Assert.Equal(2, request.ModelState.Sum(kvp => kvp.Value.Errors.Count)); }
public void WhenValidatingInvalidValidatableObjectCommandThenReturnsFalse() { // Assign ICommandValidator validator = new DefaultCommandValidator(); ICommand command = new ValidatableObjectCommand(false); CommandHandlerRequest request = new CommandHandlerRequest(this.configuration, command); // Act bool result = validator.Validate(request); // Assert Assert.False(result); Assert.Equal(2, request.ModelState.Sum(kvp => kvp.Value.Errors.Count)); }
public void WhenValidatingValidValidatableObjectCommandThenReturnsTrue() { // Assign ICommandValidator validator = new DefaultCommandValidator(); ICommand command = new ValidatableObjectCommand(true); CommandHandlerRequest request = new CommandHandlerRequest(this.configuration, command); // Act bool result = validator.Validate(request); // Assert Assert.True(result); Assert.Equal(0, request.ModelState.Count); }
public void WhenValidatingValidValidatableObjectCommandThenReturnsTrue() { // Assign ICommandValidator validator = new DefaultCommandValidator(); ICommand command = new ValidatableObjectCommand(true); CommandHandlerRequest request = new CommandHandlerRequest(this.configuration, command); // Act bool result = validator.Validate(request); // Assert Assert.True(result); Assert.Equal(0, request.ModelState.Count); }