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
Hey guys,
I’m having trouble doing one more thing with Type Mock.

I have a base class as below with multiple derived classes. I want to mock ALL INSTANCES of the Discover method on the base class. The method is not virtual. Unfortunately, the only way I was able to get this to work was to mock All Instances of DerivedClassA.Discover and also all instances of DerivedClassB.Discover. That isn’t an elegant solution because there could be lots of derived classes. Is there a way to mock methods on a Base class without needing to know what the derived class is?

Public class BaseClass
{
Public void Discover();
}

Public class DerivedClassA : BaseClass
{
}

Public class DerivedClassB : BaseClass
{
}

Thanks,
James
asked by JamesKing (48.2k points)

1 Answer

0 votes
Hi James,

I think this will help you figure it out:

http://tinyurl.com/ovzr2br

Faking only the base instance should solve this issue.

Also i'm glad to tell you that we are working on a new feature
in which all derived are faked if you fake all abstract types.
answered by Shai Barak (1.5k points)
...