concept model binder in category asp.net

appears as: model binder, The model binder, model binders
ASP.NET MVC 2 in Action

This is an excerpt from Manning's book ASP.NET MVC 2 in Action.

We direct the model binder to collect all the inputs by accepting a List<CustomerSummary.CustomerSummaryInput> . This works out of the box.

Model binders are one cog in a larger machine, and only through testing that larger part can we have complete confidence in our model binders. It can often take quite a bit of trial and error to get the model binder to function correctly. When it’s working correctly, we need only construct the context objects used by our model binder in our unit test to re-create those scenarios.

Unfortunately, merely looking at a model binder may not show us how to construct the context objects it uses. A common test failure is a NullReferenceException, where a call to an MVC framework method requires other supporting objects in place. The easiest way to determine what pieces our model binder needs in place is to write a test and see if it passes. If it doesn’t pass because of an exception, we keep fixing the exceptions, often by supplying test doubles, until our test passes or fails due to an assertion failure.