public void CleanupDependenciesTest() { var base_obj = new CleanupDependenciesBaseObject(); WeakReference obj_reference = null; new Action(() => { var obj = new CleanupDependenciesObject(base_obj); obj_reference = new WeakReference(obj); Assert.IsTrue(obj_reference.IsAlive, "CleanupDependenciesObject must be alive"); obj.CleanupDependencies(); })(); GC.Collect(); GC.WaitForPendingFinalizers(); Assert.IsFalse(obj_reference.IsAlive, "CleanupDependenciesObject must NOT be alive"); }
public CleanupDependenciesObject(CleanupDependenciesBaseObject base_object) { BaseObject = base_object; AddDependency(() => BaseObject.BaseProp1, () => Prop1); }