I’ve had to create a custom model binder to bind data for a complex object, see here:
Custom model binder for child collection
However, I’d like to know how doing this affects testing because if I test the controller method just straight up (not setting up a context etc) the binder should fail right? Maybe I’m just not clear on how to test a controller.
Thanks
You just test them independently.
The binder is required to properly form an instance of an object to pass to the Controller action when in the ASP.NET MVC pipeline, you do not need to test that it is invoked at the appropriate time. Just test that given the correct inputs, your custom binder produces the correct outputs and the same for your controller (and any negative tests you feel are appropriate).