When testing my controller\'s actions the ModelState is always valid.
public class Product
{
public int Id { get; set; }
[Required]
[StringLengt
Validation happens when the posted data is bound to the view model. The view model is then passed into the controller. You are skipping part 1 and passing a view model straight into a controller.
You can manually validate a view model using
System.ComponentModel.DataAnnotations.Validator.TryValidateObject()