I'm new to FakeItEasy, sorry if the solution is obvious.
This is the simplified code which reproduces the problem:
I have a base class:
public abstract class BaseClass
{
public void Do()
{
Do_Override();
}
protected abstract void Do_Override();
}
and a derived one:
public class ImplementingClass: BaseClass
{
protected override void Do_Override()
{
ProtectedDo();
}
protected virtual void ProtectedDo()
{
}
}
In my test I want to see if ProtectedDo()
was called. I've tried to test in two ways, but tests are failing with the same message:
1st. In debug mode it is not entering in Do_Override()
public class ImplementingClassShould
{
[Fact]
public void Run_ProtectedDo()
{
var fake = A.Fake<ImplementingClass>();
fake.Do();
A.CallTo(fake).Where(_ => _.Method.Name == "ProtectedDo").MustHaveHappened();
}
}
2nd. In debug mode it is entering in Do_Override()
public class ImplementingClassShould
{
[Fact]
public void Run_ProtectedDo_V2()
{
var sut = new ImplementingClass();
var sutFakeWrapper = A.Fake<ImplementingClass>(_ => _.Wrapping(sut));
sutFakeWrapper.Do();
A.CallTo(sutFakeWrapper).Where(_ => _.Method.Name == "ProtectedDo").MustHaveHappened();
}
}
Fail message: