I am trying to make following mocking
var checkComponent = MockRepository.GenerateStub<IController>();
checkComponent.Stub(r => r.GetSelector().Select(new Position(3,6,1))).Return(true);
I am getting that r.GetSelector()
is returning null.
Is there a way to make mocking that i am trying to create ?
Thanks.
I am getting that r.GetSelector() is returning null.
This is because checkComponent
(r
in Stub() call) is not a real implementation of the IController
it is basically RhinoMock proxy object which implements IController
interface.
Is there a way to make mocking that i am trying to create?
You have to specify what should be returned when GetSelector()
is called,
use Mock for scenarios when you need to specify expectations on methods.
var componentMock = MockRepository.GenerateMock<IController>();
var selectorMock = MockRepository.GenerateMock<ISelector>();
// if you need - specify concrete arguments to return true
selectorMock.Expect(x => x.Select(null)).IgnoreArguments().Return(true).Repeat.Any();
componentMock.Expect(x => x.GetSelector()).Return(selectorMock).Repeat.Any();