TDD: What is best practice to test DataAnnotations in ASP.NET MVC 3?

Viewed 4361

I'm participating in a project using ASP.NET MVC 3 and DataAnnotations. We have DataAnnotations in ViewModels classes.

How do you write unit tests for these validations?

ViewModel example:

public class AchievementVM
{
    [Required(ErrorMessage = "The title field is required.")]
    [StringLength(100, ErrorMessage = "Title must be 100 characters or less.")]
    public string Title { get; set; }
}

Thanks!

3 Answers
Related