public void AddRemovePart_SharedPart_ShouldCollectOnlyRoot() { var container = GetContainer(); var exportedValue = new SharedImporter(); 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); refTracker.AddReferencesNotExpectedToBeCollected( exportedValue.AnyPartDisposable, exportedValue.AnyPartDisposableRecomposable, exportedValue.AnyPartRecomposable, exportedValue.AnyPartSimple); part = null; exportedValue = null; refTracker.CollectAndAssert(); GC.KeepAlive(container); }
public void AddRemovePart_SharedRoot_ShouldNotDisposeChain() { var container = GetContainer(); var exportedValue = new SharedImporter(); CompositionBatch batch = new CompositionBatch(); var part = batch.AddPart(exportedValue); container.Compose(batch); batch = new CompositionBatch(); batch.RemovePart(part); container.Compose(batch); Assert.IsFalse(exportedValue.AnyPartDisposable.IsDisposed); Assert.IsFalse(exportedValue.AnyPartDisposableRecomposable.IsDisposed); }