public void Test() { Setup(); Assert.NotNull(_target); Assert.NotNull(_reference); _target = null; GC.Collect(); Assert.Null(_reference.Target); }
public void TestStaticMethodWithNonNullTarget() { Reset(); _common = new CommonTestClass(); _reference = new WeakReference(_common); Assert.IsTrue(_reference.IsAlive); var func = new WeakFunc <string>(_common, DoStuffStaticWithResult); Assert.IsTrue(func.IsAlive); _common = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); Assert.IsFalse(func.IsAlive); }
public void TestStaticMethodWithNonNullTarget() { Reset(); _common = new CommonTestClass(); _reference = new WeakReference(_common); Assert.IsTrue(_reference.IsAlive); var action = new WeakAction <string>(_common, DoStuffStatic); Assert.IsTrue(action.IsAlive); _common = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); Assert.IsFalse(action.IsAlive); }
public void TestStaticMethodWithNonNullTarget() { Reset(); _common = new CommonTestClass(); _reference = new WeakReference(_common); Assert.IsTrue(_reference.IsAlive); var func = new WeakFunc<string>(_common, DoStuffStaticWithResult); Assert.IsTrue(func.IsAlive); _common = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); Assert.IsFalse(func.IsAlive); }
public void TestStaticMethodWithNonNullTarget() { Reset(); _common = new CommonTestClass(); _reference = new WeakReference(_common); Assert.IsTrue(_reference.IsAlive); var action = new WeakAction<string>(_common, DoStuffStatic); Assert.IsTrue(action.IsAlive); _common = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); Assert.IsFalse(action.IsAlive); }
private void Setup() { _target = new CommonTestClass(); _reference = WeakReferenceEx.Create(_target); }