Esempio n. 1
0
        public void ExportFactory_ImportRequiredMetadata_MissingMetadataShouldCauseImportToBeExcluded()
        {
            var container = CreateWithAttributedCatalog(typeof(Foo));

            var part = new ExportFactoryImportRequiredMetadata();

            container.SatisfyImportsOnce(part);

            Assert.Equal(1, part.FooCreator.Length);
            Assert.Equal(0, part.FooCreatorWithMetadata.Length);
        }
Esempio n. 2
0
        public void ExportFactory_ImportRequiredMetadata_MissingMetadataShouldCauseImportToBeExcluded()
        {
            var container = CreateWithAttributedCatalog(typeof(Foo));

            var part = new ExportFactoryImportRequiredMetadata();

            container.SatisfyImportsOnce(part);

            Assert.AreEqual(1, part.FooCreator.Length, "Should contain the one Foo");
            Assert.AreEqual(0, part.FooCreatorWithMetadata.Length, "Should NOT contain Foo because it is missing the required Id metadata property");
        }
Esempio n. 3
0
        public void ExportFactory_ImportShouldNotImportSharedPart()
        {
            var container = CreateWithAttributedCatalog(typeof(SharedFoo));

            var foo = container.GetExportedValue <Foo>();

            Assert.NotNull(foo);

            var part = new ExportFactoryImportRequiredMetadata();

            container.SatisfyImportsOnce(part);

            Assert.Equal(0, part.FooCreator.Length);
        }
Esempio n. 4
0
        public void ExportFactory_ImportShouldNotImportSharedPart()
        {
            var container = CreateWithAttributedCatalog(typeof(SharedFoo));

            var foo = container.GetExportedValue <Foo>();

            Assert.IsNotNull(foo, "Ensure that a Foo actually exists in the container");

            var part = new ExportFactoryImportRequiredMetadata();

            container.SatisfyImportsOnce(part);

            Assert.AreEqual(0, part.FooCreator.Length, "Should not contain the SharedFoo because the ExportFactory should only wrap Any/NonShared parts");
        }