Beispiel #1
0
        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());
        }
Beispiel #2
0
        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);
        }