IMockControlCallBase Property

Typemock Isolator Developer Guide
Allow mocking a method in a base class that is hidden by the mocked class

Namespace:  TypeMock
Assembly:  TypeMock (in TypeMock.dll) Version: 9.3.6.0 (9.3.6.0)
Syntax

IMockControl CallBase { get; }

Property Value

Type: IMockControl
Exceptions

ExceptionCondition
TypeMockExceptionIf a static method is mocked
Remarks

In most cases there is no need to use this method as Typemock Isolator will mock all methods in the hierarcy of the mocked type. CallBase should be used when a method of a base class is overriden in the mocked type, and there is a need to mock the base method only.
Examples

public class BaseClass
{
    public virtual int SomeMethod()
    {
        return 1;
    }
}

public class DerivedClass() : BaseClass
{
    public override int SomeMethod()
    {
        return base.SomeMethod() + 1;
    }
}

[Test]
public void Test()
{
    Mock mock = MockManager.Mock(typeof(DerivedClass))
    // mock only BaseClass.SomeMethod when called from a DerivedClass Type.
    mock.CallBase.ExpectAndReturn("SomeMethod", 100);
    DerivedClass d = new DerivedClass();
    Assert.AreEqual(101, d.SomeMethod());
}
See Also

Reference