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.
But I am getting Cannot type mock Interfaces or Abstract classes exception. Is there any workaround for this?
asked by echong (600 points)

1 Answer

0 votes

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()?

Typemock Support
answered by doron (17.2k points)