Пример #1
0
        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();
        }
Пример #2
0
        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();
        }
Пример #3
0
 static void DoStuff(ActionEvent thing)
 {
     new ActionSubscriber(thing);
     thing.OnMyEvent();
 }