I want to stub ModelState.IsValid
, so I'm using following construction:
SomeController controller = MockRepository.GenerateStub<SomeController>();
controller.Stub(x => x.ModelState.IsValid).Return(false);
After invoke, I get:
System.InvalidOperationException: Invalid call, the last call has been used or no call has been made (make sure that you are calling a virtual (C#) / Overridable (VB) method).
Why this exception is thrown and how the ModelState.IsValid
can be stubbed ? Do I have to do something like this: controller.ModelState.AddModelError("", "")
for invalidating model state ?
Regards