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

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 so that these three calls in 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 installing it wrong? Actual methods return a List<int> .

+4
source share
1 answer

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

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

Source: https://habr.com/ru/post/1391545/


All Articles