Suppose I have a strongly typed caching interface that I want to make fun of. It takes objects of any kind and returns them, for example:
interface IMyCache
{
void Add( int key, object obj );
T Get<T>(int key);
}
Can I write a RhinoMocks stub that will mock any type of parameter that I send to it? Ideally, it would look something like this:
var mock = MockRepository.GenerateStub<IMyCache>();
mock.Stub( m => m.Get<T>(1234)).Return( new T());
This does not work because he expects T to be a concrete class, but I would like to generalize it. Is it possible?
source
share