How would you unit test data annotations?
Two of the class properties have the following annotations: [Key] [Column] [Required] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [MaxLength(25)] public string Name { get; set; } I understand that testing Key, Column and Required attributes is no longer a unit test, it's an integration test as it would depend on the underlying database, but how do you go about testing MaxLength(25) attribute? One of the alternatives that I can think of, is to add a code contract into the property. Update As suggested, I wrote the following helper: public class