コード例 #1
0
        public void GetExports_AfterResurrectedDefinitionHasBeenRemovedAndReaddedToCatalog_ShouldNotBeTreatedAsRejected()
        {
            var definition1 = PartDefinitionFactory.Create(PartFactory.CreateImporterExporter("Export", "Import"));
            var definition2 = PartDefinitionFactory.Create(PartFactory.CreateImporterExporter("Export", "Import"));
            var catalog     = CatalogFactory.CreateMutable(definition1, definition2);

            var provider       = CreateCatalogExportProvider(catalog);
            var sourceProvider = ExportProviderFactory.CreateRecomposable();

            provider.SourceProvider = sourceProvider;

            var exports = provider.GetExports <object>("Export");

            EnumerableAssert.IsEmpty(exports, "definition1 and definition2 should have been rejected.");

            // Resurrect both definitions
            sourceProvider.AddExport("Import", new object());

            exports = provider.GetExports <object>("Export");

            Assert.AreEqual(2, exports.Count(), "definition1 and definition2 should have been resurrected.");

            catalog.RemoveDefinition(definition1);

            exports = provider.GetExports <object>("Export");
            Assert.AreEqual(1, exports.Count(), "definition1 should have been removed.");

            catalog.AddDefinition(definition1);

            exports = provider.GetExports <object>("Export");

            Assert.AreEqual(2, exports.Count(), "definition1 and definition2 should be both present.");
        }