slandau
slandau

Reputation: 24052

RhinoMocks Error "Only assignment, call, increment, decrement, and new object expressions can be used as a statement"

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>());

So I want to set this up so that those three calls on the mock object return new List<int>(), but I get this compiler error:

Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Am I setting this up wrong? The actual methods return type List<int>.

Upvotes: 4

Views: 1657

Answers (1)

Adam Rackis
Adam Rackis

Reputation: 83358

Since these are methods, you need parenthesis when setting up the Stub:

CoreDataManagerMock.Stub(r => r.LoadTranQuotesThatNeedBasicRates())
                   .Return(new List<int>());

Upvotes: 4

Related Questions