Inheritance: IModuleInitializer
        public void ShouldWorkIfModuleLoadsAnotherOnDemandModuleWhenInitializing()
        {
            var initializer    = new StubModuleInitializer();
            var onDemandModule = CreateModuleInfo(typeof(MockModule), InitializationMode.OnDemand);

            onDemandModule.ModuleName = "OnDemandModule";
            var moduleThatLoadsOtherModule = CreateModuleInfo(typeof(MockModule), InitializationMode.WhenAvailable);
            var catalog = new MockModuleCatalog {
                Modules = { moduleThatLoadsOtherModule, onDemandModule }
            };
            ModuleManager manager = new ModuleManager(initializer, catalog, new MockLogger());

            bool onDemandModuleWasInitialized = false;

            initializer.Initialize = m =>
            {
                if (m == moduleThatLoadsOtherModule)
                {
                    manager.LoadModule("OnDemandModule");
                }
                else if (m == onDemandModule)
                {
                    onDemandModuleWasInitialized = true;
                }
            };

            manager.Run();

            Assert.IsTrue(onDemandModuleWasInitialized);
        }
Example #2
0
        public void ShouldWorkIfModuleLoadsAnotherOnDemandModuleWhenInitializing()
        {
            var initializer = new StubModuleInitializer();
            var onDemandModule = CreateModuleInfo(typeof(MockModule), InitializationMode.OnDemand);
            onDemandModule.ModuleName = "OnDemandModule";
            var moduleThatLoadsOtherModule = CreateModuleInfo(typeof(MockModule), InitializationMode.WhenAvailable);
            var catalog = new MockModuleCatalog { Modules = { moduleThatLoadsOtherModule, onDemandModule } };
            ModuleManager manager = new ModuleManager(initializer, catalog, new MockLogger());
            
            bool onDemandModuleWasInitialized = false;
            initializer.Initialize = m =>
                                     {
                                         if (m == moduleThatLoadsOtherModule)
                                         {
                                             manager.LoadModule("OnDemandModule");
                                         }
                                         else if (m == onDemandModule)
                                         {
                                             onDemandModuleWasInitialized = true;
                                         }
                                     };

            manager.Run();

            Assert.IsTrue(onDemandModuleWasInitialized);
        }