Ejemplo 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);
        }
Ejemplo 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");
        }
Ejemplo 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);
        }
Ejemplo 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");
        }