public void Validate_TwoTimes_NotAccumulateErrorsValitationError() { var validator = new TestValidator2(); var first = new CreateEmployeeRequest { FirstName = "", EmployeeID = 4 }; var second = new CreateEmployeeRequest { FirstName = "asdf", EmployeeID = 2 }; validator.Validate(first); var validationResult = validator.Validate(second); Assert.That(validationResult.IsValid, Is.False); var validationFailures = validationResult.ValidationFailures.ToList(); Assert.That(validationFailures.Count, Is.EqualTo(1)); Assert.That(validationFailures[0].ValidationMessages.Count(), Is.EqualTo(1)); Assert.That( validationFailures[0].ValidationMessages.First(), Is.EqualTo("The value of EmployeeID must be greater than 3")); }
public void Validate_IntPropertyEmpty_SetDefaultValitationMessage() { var validator = new TestValidator2(); var entity = new CreateEmployeeRequest { FirstName = "asdf", EmployeeID = 1, DateOfBirth = DateTime.Now.AddMonths(1) }; var validationResult = validator.Validate(entity); var validationFailure = validationResult.ValidationFailures.First(); Assert.That(validationFailure.FieldName, Is.EqualTo("EmployeeID")); Assert.That( validationFailure.ValidationMessages.First(), Is.EqualTo("The value of EmployeeID must be greater than 3")); }