Flushing the whole method call

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?

+5
source share
1 answer

I do not think you can. When writing tests with bullying by rhino, you need to follow the rules of the compiler and avoid specifying the type type T, which makes the compiler unhappy.

- , T, , : Rhino Mocks: ?

+3

All Articles