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!

Can I Ignore a base.<Method> call?

+1 vote
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 Oct 17, 2009 by bmains (1,810 points)

1 Answer

+2 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 Oct 17, 2009 by dhelper (23,700 points)
...