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 am trying to swap any object that implements a certain Interface.
Isolate.Swap.NextInstance<IContentService>().With(fakeContentProcess);
But I am getting Cannot type mock Interfaces or Abstract classes exception. Is there any workaround for this?
Thanks.
Eric
asked by echong (600 points)

1 Answer

0 votes
Hi,

The Swap.NextInstance() API is used to handle 'new' calls in the code under test - the instance you provide to .With() will be returned when you call new. Because you asked to do this for an interface type, which cannot be instantiated (i.e. you will never see 'new IContentService') you the error.

What are you trying to test? Can you use a concrete class instead of the interface with NextInstance()?

Doron
Typemock Support
answered by doron (16.5k points)
...