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
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 bmains (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 dhelper (11.9k points)
...