public void ImportSingleToInternal()
        {
            var container = ContainerFactory.Create();
            var importer = new Int32ImporterInternal();
            var exporter = new Int32Exporter(42);

            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(importer);
            batch.AddPart(exporter);
            container.Compose(batch);

            Assert.AreEqual(42, importer.Value, "Expecting value to be imported");
        }
        public void ImportSingleIntoCollection()
        {
            var container = ContainerFactory.Create();
            var importer  = new Int32CollectionImporter();
            var exporter  = new Int32Exporter(42);

            CompositionBatch batch = new CompositionBatch();

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

            EnumerableAssert.AreEqual(importer.Values, 42);
        }
        public void ImportSingleToInternal()
        {
            var container = ContainerFactory.Create();
            var importer  = new Int32ImporterInternal();
            var exporter  = new Int32Exporter(42);

            CompositionBatch batch = new CompositionBatch();

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

            Assert.Equal(42, importer.Value);
        }
        public void ImportSingle()
        {
            var container = ContainerFactory.Create();
            var importer  = new Int32Importer();
            var exporter  = new Int32Exporter(42);

            CompositionBatch batch = new CompositionBatch();

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

            Assert.AreEqual(42, importer.Value, "Expecting value to be imported");
        }
        public void ComposeReentrantChildContainerDisposed()
        {
            var container = CreateCompositionContainer();
            Int32Importer outerImporter = new Int32Importer();
            Int32Importer innerImporter = new Int32Importer();
            Int32Exporter exporter = new Int32Exporter(42);
            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(exporter);
            container.Compose(batch);
            CallbackExecuteCodeDuringCompose callback = new CallbackExecuteCodeDuringCompose(() =>
            {
                using (CompositionContainer innerContainer = new CompositionContainer(container))
                {
                    CompositionBatch nestedBatch = new CompositionBatch();
                    nestedBatch.AddPart(innerImporter);
                    innerContainer.Compose(nestedBatch);
                }
                Assert.AreEqual(42, innerImporter.Value, "Expected value imported from export");
            });

            batch = new CompositionBatch();
            batch.AddParts(outerImporter, callback);
            container.Compose(batch);

            Assert.AreEqual(42, outerImporter.Value, "Expected value imported from export");
            Assert.AreEqual(42, innerImporter.Value, "Expected value imported from export");
        }
        public void ImportSingleIntoCollection()
        {
            var container = ContainerFactory.Create();
            var importer = new Int32CollectionImporter();
            var exporter = new Int32Exporter(42);

            CompositionBatch batch = new CompositionBatch();
            batch.AddPart(importer);
            batch.AddPart(exporter);
            container.Compose(batch);

            EnumerableAssert.AreEqual(importer.Values, 42);
        }