views:

63

answers:

1

I'm having some trouble unit testing the model returned by DefaultModelBinder. I want to feed in a fake form collection and check the model that it returns to make sure model properties are being bound properly. In my research, I'm not turning up -any- resources on testing the DefaultModelBinder. Maybe I'm missing something. Maybe I shouldn't be testing this part of MVC? Your thoughts?

+1  A: 

Byron, I really think you shouldn't be testing this. You have to focus on your controller actions and the interactions they may have with other components, like services, etc. The default model binder has already been tested by the MS team (I hope so :P). Just assume your action parameters have correctly been populated with the form posted values by the default model binder and test the actions in your controllers with objects built by yourself. This is what I usually do and what I have seen everywhere.

Regards.

uvita
Changed question a bit. I guess I'm really trying to test the ModelBinder output.
Byron Sommardahl
@Byron Sommardahl: You are trying to test if your input is correct (because input defines output). Testing is not about checking if input is good, but if code producing the output is ok. If you can't change it, what to test?
LukLed