I am creating a DynamicMultiMock as follows:
this.serviceClient = this.mocks.DynamicMultiMock<ISlippyPlateProcedureService>(typeof(ICommunicationObject));
Then setting the following expectation:
Expect.Call(((ICommunicationObject)this.serviceClient).State).Return(CommunicationState.Faulted);
When I execute the test, Rhino Mocks reports this:
Replayed expectation: ICommunicationObject.get_State();
Dynamic Mock: Unexpected method call ignored: ICommunicationObject.get_State();
Am I correctly setting this expectation or is there another way?
Editing to include the complete test code:
Expect.Call(this.syncContextContainer.SynchronizationContext).Return(new SlippyPlateProcedureSynchronizationContextMock());
Expect.Call(this.clientFactory.CreateServiceClient(null)).IgnoreArguments().Return(this.serviceClient);
Expect.Call(((ICommunicationObject)this.serviceClient).State).Return(CommunicationState.Faulted);
Expect.Call(() => this.serviceClient.IsAlive());
this.mocks.ReplayAll();
SlippyPlateProcedureClient client = new SlippyPlateProcedureClient(
this.syncContextContainer, this.clientFactory, this.container);
PrivateObject privateObject = new PrivateObject(client);
SlippyPlateProcedureClient_Accessor target = new SlippyPlateProcedureClient_Accessor(privateObject);
target.CheckServerConnectivity();
this.mocks.VerifyAll();
Thanks
Andrey
Its really hard to tell what is going wrong without seeing your production code. The following test passes:
which means that the multimocks work correctly. Are you sure you are not calling State more than once? Try changing your mocks to StrictMocks (you will get an exception when calls are not expected), so:
and let the property be read multiple times:
let me know what is your progress.