The usual rules for stubbing objects apply:
- The method has to be public.
- Generate the stub from the interface and not the physical object to avoid the actual implementation being called.
- If you want to create a partial stub of an object instead of the interface, the methods you wish to stub HAS to be virtual, or they'll be called as you are stubbing them (this should really be a separate post).
stubObject = MockRepository.GenerateStub<IInterfaceToBeStubbed>();
stubObject.Stub(x =>
x.MethodToBeStubbed(Arg<Byte[]>.Is.Anything, Arg<int>.Is.Anything))
.WhenCalled(new Action<MethodInvocation>( (mi) => {}));