chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I have a generic interface, IInsertionIdFactory<TEntity>.
That interface has a method whose signature is:
void SetNewId(Database db, DbCommand command, TEntity domainObj);

I need to be able set a DoInstead() on that method.

How do I go about doing this? I don't want to fake all of the concrete instances that implement IInsertionIdFactory<TEntity>, as this would number in the 30+ range.
asked by csustek (4k points)

1 Answer

0 votes

You can replace the behavior of the interface using a fake instance and set the DoInstead() behavior on that. You can do that for an IInsertionIdFactory which has the generic parameter defined:
var fake = Isolate.Fake.Instance<IInsertionIdFactory<Person>>();
Isolate.WhenCalled(() => fake.SetNewId(null, null, null)).IgnoreCall();

However, this cannot be done if you don't define what TEntity you're working on. Defining behavior for any generic parameter is not currently supported - it's an interesting feature request so I'll log it in our backlog.

Typemock Support
answered by doron (17.2k points)