public void FilteredCatalog_ScopeA()
        {
            var cat   = GetCatalog();
            var contA = new CompositionContainer(ScopeCatalog(cat, "A"));

            Assert.True(contA.IsPresent <ScopeAComponent1>());
            Assert.True(contA.IsPresent <ScopeAComponent2>());
            Assert.False(contA.IsPresent <ScopeBComponent>());
            Assert.False(contA.IsPresent <ScopeCComponent>());
        }
Exemple #2
0
        public void FilteredCatalog_ScopeC()
        {
            var cat   = GetCatalog();
            var contA = new CompositionContainer(ScopeCatalog(cat, "A"));
            var contB = new CompositionContainer(ScopeCatalog(cat, "B"), contA);
            var contC = new CompositionContainer(ScopeCatalog(cat, "C"), contB);

            Assert.IsTrue(contC.IsPresent <ScopeAComponent1>());
            Assert.IsTrue(contC.IsPresent <ScopeAComponent2>());
            Assert.IsTrue(contC.IsPresent <ScopeBComponent>());
            Assert.IsTrue(contC.IsPresent <ScopeCComponent>());
        }
        public void AddAndRemoveDirectory()
        {
            var cat       = new AggregateCatalog();
            var container = new CompositionContainer(cat);

            Assert.False(container.IsPresent <MyExport>());

            var dir1 = new DirectoryCatalog(TemporaryFileCopier.GetTemporaryDirectory());

            cat.Catalogs.Add(dir1);
            Assert.True(container.IsPresent <MyExport>());

            cat.Catalogs.Remove(dir1);

            Assert.False(container.IsPresent <MyExport>());
        }
Exemple #4
0
        public void AddAndRemoveDirectory()
        {
            using (var directory = CreateTemporaryDirectory())
            {
                var cat       = new AggregateCatalog();
                var container = new CompositionContainer(cat);

                Assert.IsFalse(container.IsPresent <MyExport>());

                var dir1 = new DirectoryCatalog(directory.DirectoryPath);
                cat.Catalogs.Add(dir1);
                Assert.IsTrue(container.IsPresent <MyExport>());

                cat.Catalogs.Remove(dir1);

                Assert.IsFalse(container.IsPresent <MyExport>());
            }
        }