Geeks With Blogs
Etienne Giust's .NET notes Some .NET tips and tricks for me to remember. That might help you too March 2012 Entries
UnitTesting Controller DataAnnotation Validation in MVC3 : ModelState.IsValid always true ?
Testing for ModelState.IsValid when unit testing your controller is not straightforward, since the Model Binding is responsible for validating you model. But Model Binding happens in OnActionExecuted filter (and NOT when you call your controller Action method). That means in your test context, Model Binding will not happen when you call your action method and ModelState.IsValid will always be true. But thanksfully, there is a solution below If we have the following simplistic model : public class ......

Posted On Tuesday, March 13, 2012 3:09 AM

Copyright © Etienne Giust | Powered by: