コード例 #1
0
        static async Task CreateAndWrite(CompositionManager.Caching caching)
        {
            var composition = await CompositionManager.CreateRuntimeCompositionFromDiscovery(caching);

            var cacheManager = new CachedComposition();

            await caching.Write(composition, cacheManager);
        }
コード例 #2
0
        static async Task <RuntimeComposition> CreateAndWrite(CompositionManager.Caching caching)
        {
            var(composition, catalog) = await CompositionManager.CreateRuntimeCompositionFromDiscovery(caching);

            var cacheManager = new CachedComposition();

            await caching.Write(composition, catalog, cacheManager);

            return(composition);
        }
コード例 #3
0
        public async Task TestControlCacheFaultInjection(Type injectorType)
        {
            var injector    = (CompositionManager.ICachingFaultInjector)Activator.CreateInstance(injectorType);
            var caching     = GetCaching(injector);
            var composition = await CompositionManager.CreateRuntimeCompositionFromDiscovery(caching);

            var cacheManager = new CachedComposition();

            await caching.Write(composition, cacheManager);

            Assert.IsFalse(caching.CanUse());
        }
コード例 #4
0
        public async Task TestControlCacheFileStaleList()
        {
            var caching     = GetCaching();
            var composition = await CompositionManager.CreateRuntimeCompositionFromDiscovery(caching);

            var cacheManager = new CachedComposition();

            await caching.Write(composition, cacheManager);

            caching.Assemblies.Add(typeof(Console).Assembly);

            Assert.IsFalse(caching.CanUse());
        }
コード例 #5
0
        public async Task TestCacheControlDataIntegrity()
        {
            var caching = GetCaching();

            var(composition, catalog) = await CompositionManager.CreateRuntimeCompositionFromDiscovery(caching);

            var inputAssemblies = catalog.GetInputAssemblies().Select(x => x.ToString()).ToArray();

            Assert.That(caching.MefAssemblies, Contains.Item(typeof(CompositionManager).Assembly));
            Assert.That(inputAssemblies, Contains.Item(typeof(CompositionManager).Assembly.GetName().ToString()));

            Assert.That(caching.MefAssemblies, Is.Not.Contains(typeof(Console).Assembly));
            Assert.That(inputAssemblies, Contains.Item(typeof(Console).Assembly.GetName().ToString()));
        }
コード例 #6
0
        public async Task ValidateRuntimeCompositionIsValid()
        {
            var mefAssemblies = CompositionManager.ReadAssembliesFromAddins();
            var caching       = new CompositionManager.Caching(mefAssemblies, file => {
                var tmpDir = Path.Combine(Util.TmpDir, "mef", nameof(ValidateRuntimeCompositionIsValid));
                if (Directory.Exists(tmpDir))
                {
                    Directory.Delete(tmpDir, true);
                }
                Directory.CreateDirectory(tmpDir);
                return(Path.Combine(tmpDir, file));
            }, exceptionHandler: new ThrowingHandler());

            var(composition, catalog) = await CompositionManager.CreateRuntimeCompositionFromDiscovery(caching);

            var cacheManager = new CachedComposition();

            await caching.Write(composition, catalog, cacheManager);
        }