Hi,
It looks like a bug in the Isolator.
The problem is that the Isolator 'see' the event adder during runtime as a BaseClass method (which is what's really happens at runtime) while the faked instance is of type DerivedClass.
The workaround is to add another fake for BaseClass
[Test]
public void TestUsingClass()
{
var fakeDerived = Isolate.Fake.Instance<DerivedClass>();
Isolate.Swap.NextInstance<DerivedClass>().With(fakeDerived);
// dummy fake for BaseClass
Isolate.Fake.Instance<BaseClass>();
Action baseClassEvent = null;
Isolate.WhenCalled(() => fakeDerived.BaseClassEvent += null).DoInstead((call) =>
{
baseClassEvent = (Action)call.Parameters[0];
});
UsingClass usingClass = new UsingClass();
baseClassEvent();
}
Please let me know if it helps.