jeudi 29 janvier 2015

Is it possible to use Rhino Mocks to stub a generic method where I don't care about the type?

I have a method with the following signature that I'd like to stub:



async Task<T> MyMethod<T>(SomeClass, bool, string, string, string, params object[])


The generic type, T, is the type that we expect the method to return (data returned from the server is cast to type T). Note that it can't be inferred from parameters passed in; it has to be specified each time.


I need to create a stub for this method in Rhino Mocks, but it's expecting me to provide the generic type. I would like it to cater for calls with any type. I tried using , but it then expects a call with that specific type.


I can see why this would be a problem, because calls to generic types are dealt with at compile-time, not run-time.


Thought it would be worth asking, though, just in case I'm missing a trick.


Aucun commentaire:

Enregistrer un commentaire