I have a class, A, that contains an object of a class B. The B class can fire an event that is handled by A.
public class B
{
public Event EventHandler SomethingHappened;
}
public class A
{
private B _b;
public class A(B b)
{
_b = b;
_b.SomethingHappened += OnSomethingHappened();
}
public void OnSomethingHappened()
{
}
}
I would like to test all of this, and I would like to test fire the event in B so that my faked instance of A can process it:
var fakeB = Isolate.Fake.Instance<B>(Members.CallOriginal);
Isolate.Swap.AllInstances<B>().With(fakeB);
var fakeA = Isolate.Fake.Instance<A>(Members.CallOriginal, ConstructorWillBe.Called, fakeB);
Isolate.Swap.AllInstances<A>().With(fakeA);
Isolate.Invoke.Event(() => fakeB.SomethingHappened += null, /*event parameter*/);
This doesn't seem to work. If I put a breakpoint at A.OnSomethingHappened(), it is never hit. Any ideas as to why?