public void ModuleNeedsRetrievalReturnsTrueWhenModulesAreNotImported()
        {
            TestableMefModuleManager moduleManager = new TestableMefModuleManager();
            bool result = moduleManager.CallModuleNeedsRetrieval(new ModuleInfo("name", "type"));

            Assert.IsTrue(result);
        }
Beispiel #2
0
        public void ModuleNeedsRetrievalReturnsTrueWhenModulesAreNotImported()
        {
            TestableMefModuleManager moduleManager = new TestableMefModuleManager();
            bool result = moduleManager.CallModuleNeedsRetrieval(new ModuleInfo("name", "type"));

            Assert.IsTrue(result);
        }
Beispiel #3
0
        public void DownloadCompletedRaisedForImportedModulesInCatalog()
        {
            var mockModuleInitializer = new Mock <IModuleInitializer>();
            var modules = new List <ModuleInfo>();

            var mockModuleCatalog = new Mock <IModuleCatalog>();

            mockModuleCatalog.Setup(x => x.Modules).Returns(modules);
            mockModuleCatalog
            .Setup(x => x.AddModule(It.IsAny <ModuleInfo>()))
            .Callback <ModuleInfo>(modules.Add);

            var mockLogger = new Mock <ILoggerFacade>();

            List <ModuleInfo> modulesCompleted = new List <ModuleInfo>();
            var moduleManager = new TestableMefModuleManager(mockModuleInitializer.Object, mockModuleCatalog.Object, mockLogger.Object)
            {
                Modules =
                    new List <Lazy <IModule, IModuleExport> >()
                {
                    new Lazy <IModule, IModuleExport>(() => new TestModule(),
                                                      new TestModuleMetadata())
                }
            };

            moduleManager.LoadModuleCompleted += (o, e) =>
            {
                modulesCompleted.Add(e.ModuleInfo);
            };

            moduleManager.OnImportsSatisfied();

            Assert.AreEqual(1, modulesCompleted.Count);
        }
        public void ModuleNeedsRetrievalReturnsFalseWhenModuleIsFound()
        {
            TestableMefModuleManager moduleManager = new TestableMefModuleManager
            {
                Modules = new List<Lazy<IModule, IModuleExport>>() { new Lazy<IModule, IModuleExport>(() => new TestModule(), new TestModuleMetadata()) }
            };

            bool result = moduleManager.CallModuleNeedsRetrieval(new ModuleInfo("TestModule", "Microsoft.Practices.Prism.MefExtensions.Tests.MefModuleManagerFixture.TestModule"));

            Assert.IsFalse(result);
        }
        public void ModuleNeedsRetrievalReturnsTrueWhenModuleNotFound()
        {
            TestableMefModuleManager moduleManager = new TestableMefModuleManager
            {
                Modules = new List<Lazy<IModule, IModuleExport>>() { new Lazy<IModule, IModuleExport>(() => new TestModule(), new TestModuleMetadata()) }
            };

            bool result = moduleManager.CallModuleNeedsRetrieval(new ModuleInfo("name", "type"));

            Assert.IsTrue(result);
        }
        public void ModuleNeedsRetrievalReturnsTrueWhenNoModulesAreAvailable()
        {
            TestableMefModuleManager moduleManager = new TestableMefModuleManager
                                                         {
                                                             Modules = (IEnumerable<Lazy<IModule, IModuleExport>>) new List<Lazy<IModule,  IModuleExport>>()
                                                         };

            bool result = moduleManager.CallModuleNeedsRetrieval(new ModuleInfo("name", "type"));

            Assert.IsTrue(result);
        }
Beispiel #7
0
        public void ModuleNeedsRetrievalReturnsTrueWhenNoModulesAreAvailable()
        {
            TestableMefModuleManager moduleManager = new TestableMefModuleManager
            {
                Modules = (IEnumerable <Lazy <IModule, IModuleExport> >) new List <Lazy <IModule, IModuleExport> >()
            };

            bool result = moduleManager.CallModuleNeedsRetrieval(new ModuleInfo("name", "type"));

            Assert.IsTrue(result);
        }
Beispiel #8
0
        public void ModuleNeedsRetrievalReturnsFalseWhenModuleIsFound()
        {
            TestableMefModuleManager moduleManager = new TestableMefModuleManager
            {
                Modules = new List <Lazy <IModule, IModuleExport> >()
                {
                    new Lazy <IModule, IModuleExport>(() => new TestModule(), new TestModuleMetadata())
                }
            };

            bool result = moduleManager.CallModuleNeedsRetrieval(new ModuleInfo("TestModule", "Microsoft.Practices.Prism.MefExtensions.Tests.MefModuleManagerFixture.TestModule"));

            Assert.IsFalse(result);
        }
Beispiel #9
0
        public void ModuleNeedsRetrievalReturnsTrueWhenModuleNotFound()
        {
            TestableMefModuleManager moduleManager = new TestableMefModuleManager
            {
                Modules = new List <Lazy <IModule, IModuleExport> >()
                {
                    new Lazy <IModule, IModuleExport>(() => new TestModule(), new TestModuleMetadata())
                }
            };

            bool result = moduleManager.CallModuleNeedsRetrieval(new ModuleInfo("name", "type"));

            Assert.IsTrue(result);
        }
        public void DownloadCompletedNotRaisedForOnDemandImportedModules()
        {
            var mockModuleInitializer = new Mock <IModuleInitializer>();
            var modules = new List <ModuleInfo>();

            var mockModuleCatalog = new Mock <IModuleCatalog>();

            mockModuleCatalog.Setup(x => x.Modules).Returns(modules);
            mockModuleCatalog
            .Setup(x => x.AddModule(It.IsAny <ModuleInfo>()))
            .Callback <ModuleInfo>(modules.Add);

            var mockLogger = new Mock <ILoggerFacade>();

            List <ModuleInfo> modulesCompleted = new List <ModuleInfo>();
            var moduleManager = new TestableMefModuleManager(mockModuleInitializer.Object, mockModuleCatalog.Object, mockLogger.Object)
            {
                Modules =
                    new List <Lazy <IModule, IPluginModuleExport> >()
                {
                    new Lazy <IModule, IPluginModuleExport>(() => new TestModule(),
                                                            new TestModuleMetadata()
                    {
                        InitializationMode = InitializationMode.OnDemand
                    }),
                    new Lazy <IModule, IPluginModuleExport>(() => new TestModule(),
                                                            new TestModuleMetadata()
                    {
                        ModuleName = "WhenAvailableModule"
                    })
                }
            };

            moduleManager.LoadModuleCompleted += (o, e) =>
            {
                modulesCompleted.Add(e.ModuleInfo);
            };

            moduleManager.OnImportsSatisfied();

            Assert.AreEqual(1, modulesCompleted.Count);
            Assert.AreEqual("WhenAvailableModule", modulesCompleted[0].ModuleName);
        }
        public void DownloadCompletedNotRaisedForOnDemandImportedModules()
        {
            var mockModuleInitializer = new Mock<IModuleInitializer>();
            var modules = new List<ModuleInfo>();

            var mockModuleCatalog = new Mock<IModuleCatalog>();
            mockModuleCatalog.Setup(x => x.Modules).Returns(modules);
            mockModuleCatalog
                .Setup(x => x.AddModule(It.IsAny<ModuleInfo>()))
                .Callback<ModuleInfo>(modules.Add);

            var mockLogger = new Mock<ILoggerFacade>();

            List<ModuleInfo> modulesCompleted = new List<ModuleInfo>();
            var moduleManager = new TestableMefModuleManager(mockModuleInitializer.Object, mockModuleCatalog.Object, mockLogger.Object)
            {
                Modules =
                    new List<Lazy<IModule, IModuleExport>>()
                                                {
                                                    new Lazy<IModule, IModuleExport>(() => new TestModule(),
                                                                                     new TestModuleMetadata()
                                                                                         {
                                                                                             InitializationMode = InitializationMode.OnDemand
                                                                                         }),
                                                    new Lazy<IModule, IModuleExport>(() => new TestModule(),
                                                                                        new TestModuleMetadata()
                                                                                            {
                                                                                                ModuleName = "WhenAvailableModule"
                                                                                            })
                                                }
            };

            moduleManager.LoadModuleCompleted += (o, e) =>
            {
                modulesCompleted.Add(e.ModuleInfo);
            };

            moduleManager.OnImportsSatisfied();

            Assert.AreEqual(1, modulesCompleted.Count);
            Assert.AreEqual("WhenAvailableModule", modulesCompleted[0].ModuleName);
        }