Force to call virtual base function instead of the overriden one.
- by Roberto Sebestyen
In the following example "Test that v1 function was called" fails. Is there a way to force call the base implementation of "RunFunction" through an instance of "class V2" ??
class V1
{
public virtual string RunFunction()
{
return "V1";
}
}
class V2 : V1
{
public override string RunFunction()
{
return "V2";
}
}
[Test]
public void TestCall()
{
var v1 = (V1)new V2();
var v2 = new V2();
Assert.IsTrue(v1.RunFunction() == "V1", "Test that v1 function was called");
Assert.IsTrue(v2.RunFunction() == "V2", "Test that v2 function was called");
}