ASP MVC 3 testing controller calling ModelState.IsValid always returns true?

It's true because you haven't called anything which sets it false This normally happens during binding, but since you just pass the model directly in the test you skip that altogether If you're trying to test validation, do that directly. If you're trying to test the error path in your controller, your test's arrange can call controller.ModelState. AddModelError(.

It's true because you haven't called anything which sets it false. This normally happens during binding, but since you just pass the model directly in the test you skip that altogether. If you're trying to test validation, do that directly.

If you're trying to test the error path in your controller, your test's arrange can call _controller.ModelState. AddModelError( //...

I'm not trying to test validation with this test. I'm trying to test that the controller has validated the model before it does x. – Adam Feb 21 at 16:51 1 Controllers don't validate models.

Nor do they invoke validators. ControllerActionInvoker does that. All controllers can do is test the state.

– Craig Stuntz Feb 21 at 17:25 1 Thanks, small paradigm shift, big difference. :) – Adam Mar 8 at 17:02.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions