Exemplo n.º 1
0
        public void PartAddedViaAddExportedValue_ShouldNotBeDisposedWithContainer()
        {
            var container = new CompositionContainer();
            var disposablePart = new AnyPartDisposable();
            var batch = new CompositionBatch();
            batch.AddPart(batch);
            container.Compose(batch);

            container.Dispose();
            Assert.IsFalse(disposablePart.IsDisposed);
        }
Exemplo n.º 2
0
        public void PartAddedViaAddExportedValue_ShouldNotBeDisposedWithContainer()
        {
            var container      = new CompositionContainer();
            var disposablePart = new AnyPartDisposable();
            var batch          = new CompositionBatch();

            batch.AddPart(batch);
            container.Compose(batch);

            container.Dispose();
            Assert.IsFalse(disposablePart.IsDisposed);
        }
Exemplo n.º 3
0
        public void PartAddedTwice_AppearsTwice()
        {
            //  You probably shouldn't be adding a part to the container twice, but it's not something we're going to check for and throw an exception on
            var container = new CompositionContainer();
            var disposable = new AnyPartDisposable();
            var part = AttributedModelServices.CreatePart(disposable);
            var batch = new CompositionBatch();
            batch.AddPart(part);
            container.Compose(batch);

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

            var exports = container.GetExports<AnyPartDisposable>();
            Assert.AreEqual(2, exports.Count());

            container.Dispose();
        }
Exemplo n.º 4
0
        public void PartAddedTwice_AppearsTwice()
        {
            //  You probably shouldn't be adding a part to the container twice, but it's not something we're going to check for and throw an exception on
            var container  = new CompositionContainer();
            var disposable = new AnyPartDisposable();
            var part       = AttributedModelServices.CreatePart(disposable);
            var batch      = new CompositionBatch();

            batch.AddPart(part);
            container.Compose(batch);

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

            var exports = container.GetExports <AnyPartDisposable>();

            Assert.AreEqual(2, exports.Count());

            container.Dispose();
        }