コード例 #1
0
        public void SatisfyImportsOnce_Unsuccessful_ShouldNotBlockChanges()
        {
            var exportProvider = ExportProviderFactory.CreateRecomposable();
            var engine         = new ImportEngine(exportProvider);

            var import   = ImportDefinitionFactory.Create("Value");
            var importer = PartFactory.CreateImporter(import);

            Assert.Throws <CompositionException>(() =>
                                                 engine.SatisfyImportsOnce(importer));

            exportProvider.AddExport("Value", 22);
            exportProvider.AddExport("Value", 23);
            exportProvider.RemoveExport("Value");

            GC.KeepAlive(importer);
        }
コード例 #2
0
        public void SatisifyImportsOnce_Recomposable_ValueShouldNotChange_NoRecompositionRequested_ViaNonArgumentSignature()
        {
            var exportProvider = ExportProviderFactory.CreateRecomposable();
            var engine         = new ImportEngine(exportProvider);

            exportProvider.AddExport("Value", 21);

            var import   = ImportDefinitionFactory.Create("Value", true);
            var importer = PartFactory.CreateImporter(import);

            engine.SatisfyImportsOnce(importer);

            Assert.Equal(21, importer.GetImport(import));

            exportProvider.ReplaceExportValue("Value", 42);

            Assert.Equal(21, importer.GetImport(import));

            GC.KeepAlive(importer);
        }