public void ReferenceCycleShouldNotBeCollectedByReferenceCountTest() { var selfReferencingChild = new ReferencingCircleHelper(); selfReferencingChild.Other = selfReferencingChild; var referenceToChild = new ReferencingCircleHelper { Other = selfReferencingChild }; var syncSourceRoot = new SyncSourceRoot(referenceToChild, _sourceSettings); Assert.Equal(2, syncSourceRoot.TrackedReferences.Count()); referenceToChild.Other = null; Assert.Equal(2, syncSourceRoot.TrackedReferences.Count()); }
public void ReferenceCycleShouldBeCollectedByGarbageCollectionTest() { var selfReferencingChild = new ReferencingCircleHelper(); selfReferencingChild.Other = selfReferencingChild; var referenceToChild = new ReferencingCircleHelper { Other = selfReferencingChild }; var syncSourceRoot = new SyncSourceRoot(referenceToChild, _sourceSettings); Assert.Equal(2, syncSourceRoot.TrackedReferences.Count()); referenceToChild.Other = null; syncSourceRoot.GarbageCollect(); syncSourceRoot.WriteChangesAndDispose(); Assert.Single(syncSourceRoot.TrackedReferences); }