This action is invalid when the mock object is in replay state

622 Views Asked by At

I'm converting MSUnit test to XUnit.

public class ClassName
{
    protected IDomainQueries MockILogQueries { get; private set; }
    protected IQueryContext MockQueryContext { get; private set; }

    public ClassName()
    {
        MockQueryContext = MockRepository.GenerateStub<IQueryContext>();
        MockILogQueries = MockRepository.GenerateStub<IDomainQueries>();
        //Getting error for the below line            
        MockQueryContext.Stub(r => r.LogQueries).Return(MockILogQueries);
    }
}

Above specified code is working in MSUnit but not in XUnit.

I'm getting the following error

Message:     System.InvalidOperationException : This action is invalid when the mock object is in replay state.
Stack Trace:
    ReplayMockState.GetLastMethodOptions[T]()
    RhinoMocksExtensions.Expect[T,R](T mock, Function`2 action)
    RhinoMocksExtensions.Stub[T,R](T mock, Function`2 action)
    ClassName.ctor() line 
0

There are 0 best solutions below