Suppose I have a strongly typed caching interface that I want to mock. It takes objects of any kind and returns them, like this:
interface IMyCache
{
void Add( int key, object obj );
T Get<T>(int key);
}
Can I write a RhinoMocks stub that will mock any parameter type that I send to it? Ideally it would just look something like this:
var mock = MockRepository.GenerateStub<IMyCache>();
mock.Stub( m => m.Get<T>(1234)).Return( new T());
This doesn't work because it's expecting T to be a concrete class, but I'd like to genericize it. Is this possible?