var CoreDataManagerMock = MockRepository.GenerateMock<ICoreDataManager>();
CoreDataManagerMock.Stub(r => r.LoadTranQuotesThatNeedBasicRates).Return(new List<int>());
CoreDataManagerMock.Stub(r => r.LoadTranQuotesThatNeedCompoundRates).Return(new List<int>());
CoreDataManagerMock.Stub(r => r.LoadTranQuotesThatNeedResetRates).Return(new List<int>());
所以我想设置它以便模拟对象上的那三个调用返回new List<int>()
,但是我得到了这个编译器错误:
Only assignment, call, increment, decrement, and new object expressions can be used as a statement
我说错了吗?实际方法返回类型List<int>
。
答案 0 :(得分:4)
由于这些是方法,因此在设置Stub时需要括号:
CoreDataManagerMock.Stub(r => r.LoadTranQuotesThatNeedBasicRates())
.Return(new List<int>());