I\'m using the System.ComponentModel.DataAnnotations.CustomValidationAttribute to validate one of my POCO classes and when I try to unit test it, it\'s not even calling the
Try using the overload that takes a bool that specifies if all properties should be validated. Pass true for the last parameter.
public static bool TryValidateObject(
Object instance,
ValidationContext validationContext,
ICollection<ValidationResult> validationResults,
bool validateAllProperties
)
If you pass false or omit the validateAllProperties, only the RequiredAttribute will be checked. Here is the MSDN documentation.