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 Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!
0 votes
Hello,

I have a method that I want to ignore the base method call. I have:

public class A : BaseA
{
public override void DoThis()
{
//Cust implementation code


base.DoThis();
}
}

I want to have typemock ignore base.DoThis(), while the derived class is called. Is that possible?

Thanks.
asked by (13.2k points)

1 Answer

0 votes
You can use the Reflective CallBase to do exactly that:
[Test]
public void Test()
{
    Mock mock = MockManager.Mock(typeof(A))
    // mock only BaseA.DoThat when called from a DerivedClass Type.
    mock.CallBase.ExpectCall("DoThat ");
    var a = new A();
    
    a.DoThat();
}
answered by (11.9k points)
...