mardi 23 février 2016

Failing a controller unit test on ModelState.AddModelError

I am unit testing an MVC controller. While I can assert the model state after the test has run, I would prefer it if I could make the test fail when the error is being added to the ModelState. My idea was to mock ModelState but it has no setter.

Does anyone know how to listen for ModelState.AddModelError in a unit test?

Thanks,
Drutten

Aucun commentaire:

Enregistrer un commentaire