我有一个叫做Common的属性的TxRx类。常见的有一个名为LastMod的属性。我想写一个RhinoMock的期望来表明LastMod已经设置了一些东西。所以,我想:RhinoMocks中的产业链
var txRx = MockRepository.GenerateMock<TxRx>();
var common = MockRepository.GenerateMock<Common>();
txRx.Expect(t => t.Common).Return(common);
txRx.Expect(t => t.Common.LastMod).SetPropertyAndIgnoreArgument();
,但我得到以下异常:
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).
at Rhino.Mocks.LastCall.GetOptions[T]()
at Rhino.Mocks.RhinoMocksExtensions.Expect[T,R](T mock, Function`2 action)
at ...
我相信,这意味着公共需要是虚拟的,但因为它是一个LinqToSql产生类的属性我不能使其成为虚拟的(除了黑客的自动代码,这不是一个真正的选择)。
有没有办法解决这个问题?
这不会编译,它需要Lambda表达式进行编译。我同意,看起来Common需要是虚拟的,这正是我想要避免的。好吧。 –
现在已经修复了这个问题。 –