Hi all,
Today, I've come across some code that's testing an MVC controller to ensure that the controller responds correctly if the model passed in is invalid. This sounds a good plan - except that you need to be mindful that your controller doesn't validate your model! Your view model is validated by a separate class, the ModelBinder, that fires up just before your controller is executed. This ModelBinder is built into the MVC engine, you can bet that it's been tested a zillion times by a zillion other devs, so you definitely don't want to find some way to test this ModelBinder directly.
So what to do? Let's take a look at the original test, exactly what code we've written, and so what we want to test.
More...