コード例 #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.");
        }
        public void Constructor1_ShouldSetMetadataPropertyToReadOnlyDictionary()
        {
            var definition = PartDefinitionFactory.Create();

            Assert.Throws <NotSupportedException>(() =>
            {
                definition.Metadata["Value"] = "Value";
            });
        }
        public void Constructor1_ShouldSetMetadataPropertyToEmptyDictionary()
        {
            var definition = PartDefinitionFactory.Create();

            Assert.Empty(definition.Metadata);
        }
 public void Constructor1_ShouldNotThrow()
 {
     PartDefinitionFactory.Create();
 }
コード例 #5
0
        private IQueryable <ComposablePartDefinition> GetPartDefinitions(ExportDefinition definition)
        {
            var partDefinition = PartDefinitionFactory.Create(null, () => null, Enumerable.Empty <ImportDefinition>(), new ExportDefinition[] { definition });

            return(new ComposablePartDefinition[] { partDefinition }.AsQueryable());
        }