Beispiel #1
0
        public void ChildContainerAddRemovePart_NonSharedPart_ShouldCollectWholeObjectChain()
        {
            var child = CreateParentChildContainerWithNonSharedImporter();

            var exportedValue = new NonSharedImporter();

            CompositionBatch batch = new CompositionBatch();
            var part = batch.AddPart(exportedValue);

            child.Compose(batch);
            batch = null;

            batch = new CompositionBatch();
            batch.RemovePart(part);
            child.Compose(batch);
            batch = null;

            var refTracker = new ReferenceTracker();

            refTracker.AddReferencesExpectedToBeCollected(
                exportedValue,
                exportedValue.AnyPartDisposable,
                exportedValue.AnyPartDisposableRecomposable,
                exportedValue.AnyPartRecomposable,
                exportedValue.AnyPartSimple);

            part          = null;
            exportedValue = null;

            refTracker.CollectAndAssert();

            GC.KeepAlive(child);
        }
Beispiel #2
0
        public void ChildContainerAddRemovePart_NonSharedRoot_ShouldDisposeChain()
        {
            var child = CreateParentChildContainerWithNonSharedImporter();

            var exportedValue = new NonSharedImporter();

            CompositionBatch batch = new CompositionBatch();
            var part = batch.AddPart(exportedValue);

            child.Compose(batch);

            batch = new CompositionBatch();
            batch.RemovePart(part);
            child.Compose(batch);

            Assert.IsTrue(exportedValue.AnyPartDisposable.IsDisposed);
            Assert.IsTrue(exportedValue.AnyPartDisposableRecomposable.IsDisposed);
        }
Beispiel #3
0
        public void AddRemovePart_NonSharedRoot_ShouldDisposeChain()
        {
            var container = GetContainer();

            var exportedValue = new NonSharedImporter();

            CompositionBatch batch = new CompositionBatch();
            var part = batch.AddPart(exportedValue);

            container.Compose(batch);

            batch = new CompositionBatch();
            batch.RemovePart(part);
            container.Compose(batch);

            Assert.True(exportedValue.AnyPartDisposable.IsDisposed);
            Assert.True(exportedValue.AnyPartDisposableRecomposable.IsDisposed);
        }
Beispiel #4
0
        public void AddRemovePart_NonSharedPart_ShouldCollectWholeObjectChain()
        {
            var container = GetContainer();

            var exportedValue = new NonSharedImporter();

            CompositionBatch batch = new CompositionBatch();
            var part = batch.AddPart(exportedValue);
            container.Compose(batch);
            batch = null;

            batch = new CompositionBatch();
            batch.RemovePart(part);
            container.Compose(batch);
            batch = null;

            var refTracker = new ReferenceTracker();

            refTracker.AddReferencesExpectedToBeCollected(
                exportedValue,
                exportedValue.AnyPartDisposable,
                exportedValue.AnyPartDisposableRecomposable,
                exportedValue.AnyPartRecomposable,
                exportedValue.AnyPartSimple);

            part = null;
            exportedValue = null;

            refTracker.CollectAndAssert();

            GC.KeepAlive(container);
        }
Beispiel #5
0
        public void ChildContainerAddRemovePart_NonSharedRoot_ShouldDisposeChain()
        {
            var child = CreateParentChildContainerWithNonSharedImporter();

            var exportedValue = new NonSharedImporter();

            CompositionBatch batch = new CompositionBatch();
            var part = batch.AddPart(exportedValue);
            child.Compose(batch);

            batch = new CompositionBatch();
            batch.RemovePart(part);
            child.Compose(batch);

            Assert.IsTrue(exportedValue.AnyPartDisposable.IsDisposed);
            Assert.IsTrue(exportedValue.AnyPartDisposableRecomposable.IsDisposed);
        }