public void Validate_GivenAllPropertiesAreValid_ExpectValidationSuccess() { var cmd = new Details.Model { FirstName = "first-name", LastName = "last-name" }; var validator = new Details.Validator(); var result = validator.Validate(cmd); Assert.True(result.IsValid); }
public void Validate_GivenFirstNameIsNull_ExpectValidationFailure() { var cmd = new Details.Model { FirstName = null, LastName = "last-name" }; var validator = new Details.Validator(); var result = validator.Validate(cmd); Assert.False(result.IsValid); Assert.Contains( result.Errors, failure => failure.PropertyName == "FirstName"); }
public void Validate_GivenLastNameIsEmpty_ExpectValidationFailure() { var cmd = new Details.Model { FirstName = "first-name", LastName = string.Empty }; var validator = new Details.Validator(); var result = validator.Validate(cmd); Assert.False(result.IsValid); Assert.Contains( result.Errors, failure => failure.PropertyName == "LastName"); }