【发布时间】:2011-06-22 12:13:06
【问题描述】:
我想存根ModelState.IsValid,所以我使用以下构造:
SomeController controller = MockRepository.GenerateStub<SomeController>();
controller.Stub(x => x.ModelState.IsValid).Return(false);
调用后,我得到:
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).
为什么会抛出这个异常以及如何对ModelState.IsValid 进行存根处理?我是否必须这样做:controller.ModelState.AddModelError("", "") 使模型状态无效?
问候
【问题讨论】:
标签: c# asp.net-mvc-3 rhino-mocks