public void TestActionNotNull() { ActionEvent athing = new ActionEvent(); DoStuff(athing); Assert.AreEqual(ActionSubscriber.Count, 1); GC.Collect(); GC.WaitForPendingFinalizers(); Assert.AreEqual(ActionSubscriber.Count, 1, "Action sub list should still hold a subscriber reference"); athing.OnMyEvent(); }
public void TestActionNull() { ActionEvent athing = new ActionEvent(); DoStuff(athing); Assert.AreEqual(ActionSubscriber.Count, 1); athing.SetActionNull(); // Should clear out the list, removing all refs to subscribers GC.Collect(); GC.WaitForPendingFinalizers(); Assert.AreEqual(ActionSubscriber.Count, 0, "Setting action to null should have cleared sub list"); athing.OnMyEvent(); }
static void DoStuff(ActionEvent thing) { new ActionSubscriber(thing); thing.OnMyEvent(); }