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

The . NET framework comes with a Validator class which can exercise your validation logic in isolation. The code to test could look like this.

Since those annotations are very declarative, there is little sense in writing unit tests which just check (with reflection) that the methods are annotated - the tests would just be duplicating the production code. And that would still leave the possibility that the annotations are not being used the way that the framework expects them to be used (maybe they are the wrong annotations, they are in the wrong place, or they are missing some additional configuration).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions