One of the common bugs that slip through my unit tests is passing the wrong view model to my view. It results in an error like this:
The model item passed into the dictionary is of type 'ViewModel_A', but this dictionary requires a model item of type 'ViewModel_B'.
I often find the situation where I correctly pass ViewModel_A to the view and can unit this by executing the controller action and checking the view model is of the correct type.
However, if I mistakenly have the wrong view model referenced in the view, I have no tests to catch it.
Can this be done?
Aucun commentaire:
Enregistrer un commentaire