Exemplo n.º 1
0
        public void MemoryLeakFreeWithNoInvocation()
        {
            var target     = CreateActionTarget();
            var weakAction = new WeakAction(target, target.PublicActionToExecute);

            target = null;

            GCHelper.CollectAndFreeMemory();

            Assert.IsFalse(weakAction.IsTargetAlive);
        }
Exemplo n.º 2
0
        public void NonGeneric_PublicMethod()
        {
            var target     = CreateActionTarget();
            var weakAction = new WeakAction(target, target.PublicActionToExecute);

            Assert.IsTrue(weakAction.Execute());

            Assert.AreEqual(1, target.PublicActionExecutedCount);

            target = null;

            GCHelper.CollectAndFreeMemory();

            Assert.IsFalse(weakAction.IsTargetAlive);
        }