TDD: What is best practice to test DataAnnotations in ASP.NET MVC 3?
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! Phil Patterson The .NET framework comes with a Validator class which can exercise your validation logic in isolation. The code to test could look like this: var achievement = new AchievementVM(); var