Example #1
0
        public void ShouldRegisterDefaultTypeMappings()
        {
            var bootstrapper = new MockedBootstrapper();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleEnumerator), bootstrapper.ModuleEnumerator);
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleLoader), new MockModuleLoader());

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(ILoggerFacade)));
            Assert.AreSame(bootstrapper.Logger, bootstrapper.MockUnityContainer.Instances[typeof(ILoggerFacade)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(IUnityContainer)));
            Assert.AreSame(bootstrapper.MockUnityContainer, bootstrapper.MockUnityContainer.Instances[typeof(IUnityContainer)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IContainerFacade)));
            Assert.AreEqual(typeof(UnityContainerAdapter), bootstrapper.MockUnityContainer.Types[typeof(IContainerFacade)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IModuleLoader)));
            Assert.AreEqual(typeof(ModuleLoader), bootstrapper.MockUnityContainer.Types[typeof(IModuleLoader)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IRegionManager)));
            Assert.AreEqual(typeof(RegionManager), bootstrapper.MockUnityContainer.Types[typeof(IRegionManager)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IEventAggregator)));
            Assert.AreEqual(typeof(EventAggregator), bootstrapper.MockUnityContainer.Types[typeof(IEventAggregator)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(RegionAdapterMappings)));
            Assert.AreEqual(typeof(RegionAdapterMappings), bootstrapper.MockUnityContainer.Types[typeof(RegionAdapterMappings)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(IModuleEnumerator)));
            Assert.AreSame(bootstrapper.ModuleEnumerator, bootstrapper.MockUnityContainer.Instances[typeof(IModuleEnumerator)]);
        }
Example #2
0
        public void ShouldCallGetStartupLoadedModules()
        {
            var bootstrapper = new MockedBootstrapper();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleEnumerator), bootstrapper.ModuleEnumerator);
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleLoader), new MockModuleLoader());

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.ModuleEnumerator.GetStartupLoadedModulesCalled);
        }
Example #3
0
        public void ShouldCallRunOnModuleManager()
        {
            var bootstrapper = new MockedBootstrapper();

            var moduleManager = new MockModuleManager();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleManager), moduleManager);

            bootstrapper.Run();

            Assert.IsTrue(moduleManager.RunCalled);
        }
Example #4
0
        public void ShouldCallInitializeOnModuleLoader()
        {
            var bootstrapper = new MockedBootstrapper();

            var moduleLoader = new MockModuleLoader();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleEnumerator), new MockModuleEnumerator());
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleLoader), moduleLoader);

            bootstrapper.Run();

            Assert.IsTrue(moduleLoader.InitializeCalled);
        }
Example #5
0
        public void ShouldCallInitializeOnModuleLoaderWithStartupModules()
        {
            var bootstrapper = new MockedBootstrapper();
            var moduleLoader = new MockModuleLoader();

            bootstrapper.ModuleEnumerator.StartupLoadedModules = new[] { new ModuleInfo("asm", "type", "name") };

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleEnumerator), bootstrapper.ModuleEnumerator);
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleLoader), moduleLoader);


            bootstrapper.Run();

            Assert.IsNotNull(moduleLoader.InitializeArgumentModuleInfos);
            Assert.AreEqual(1, moduleLoader.InitializeArgumentModuleInfos.Length);
            Assert.AreEqual("name", moduleLoader.InitializeArgumentModuleInfos[0].ModuleName);
        }
Example #6
0
        public void ShouldRegisterDefaultTypeMappings()
        {
            var bootstrapper = new MockedBootstrapper();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleCatalog), bootstrapper.ModuleCatalog);
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleInitializer), new MockModuleInitializer());
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleManager), new MockModuleManager());

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(ILoggerFacade)));
            Assert.AreSame(bootstrapper.Logger, bootstrapper.MockUnityContainer.Instances[typeof(ILoggerFacade)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IServiceLocator)));
            Assert.AreEqual(typeof(UnityServiceLocatorAdapter), bootstrapper.MockUnityContainer.Types[typeof(IServiceLocator)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IModuleInitializer)));
            Assert.AreEqual(typeof(ModuleInitializer), bootstrapper.MockUnityContainer.Types[typeof(IModuleInitializer)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(IModuleCatalog)));
            Assert.AreSame(bootstrapper.ModuleCatalog, bootstrapper.MockUnityContainer.Instances[typeof(IModuleCatalog)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IRegionManager)));
            Assert.AreEqual(typeof(RegionManager), bootstrapper.MockUnityContainer.Types[typeof(IRegionManager)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(RegionAdapterMappings)));
            Assert.AreEqual(typeof(RegionAdapterMappings), bootstrapper.MockUnityContainer.Types[typeof(RegionAdapterMappings)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IRegionViewRegistry)));
            Assert.AreEqual(typeof(RegionViewRegistry), bootstrapper.MockUnityContainer.Types[typeof(IRegionViewRegistry)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IRegionBehaviorFactory)));
            Assert.AreEqual(typeof(RegionBehaviorFactory), bootstrapper.MockUnityContainer.Types[typeof(IRegionBehaviorFactory)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IEventAggregator)));
            Assert.AreEqual(typeof(EventAggregator), bootstrapper.MockUnityContainer.Types[typeof(IEventAggregator)]);

            Assert.AreEqual(8, bootstrapper.MockUnityContainer.Types.Count);
        }
        public void ShouldCallInitializeOnModuleLoaderWithStartupModules()
        {
            var bootstrapper = new MockedBootstrapper();
            var moduleLoader = new MockModuleLoader();

            bootstrapper.ModuleEnumerator.StartupLoadedModules = new[] { new ModuleInfo("asm", "type", "name") };

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleEnumerator), bootstrapper.ModuleEnumerator);
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleLoader), moduleLoader);


            bootstrapper.Run();

            Assert.IsNotNull(moduleLoader.InitializeArgumentModuleInfos);
            Assert.AreEqual(1, moduleLoader.InitializeArgumentModuleInfos.Length);
            Assert.AreEqual("name", moduleLoader.InitializeArgumentModuleInfos[0].ModuleName);
        }
        public void ShouldCallInitializeOnModuleLoader()
        {
            var bootstrapper = new MockedBootstrapper();

            var moduleLoader = new MockModuleLoader();
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleEnumerator), new MockModuleEnumerator());
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleLoader), moduleLoader);

            bootstrapper.Run();

            Assert.IsTrue(moduleLoader.InitializeCalled);
        }
        public void ShouldCallGetStartupLoadedModules()
        {
            var bootstrapper = new MockedBootstrapper();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleEnumerator), bootstrapper.ModuleEnumerator);
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleLoader), new MockModuleLoader());

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.ModuleEnumerator.GetStartupLoadedModulesCalled);
        }
        public void ShouldRegisterDefaultTypeMappings()
        {
            var bootstrapper = new MockedBootstrapper();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleEnumerator), bootstrapper.ModuleEnumerator);
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleLoader), new MockModuleLoader());

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(ILoggerFacade)));
            Assert.AreSame(bootstrapper.Logger, bootstrapper.MockUnityContainer.Instances[typeof(ILoggerFacade)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(IUnityContainer)));
            Assert.AreSame(bootstrapper.MockUnityContainer, bootstrapper.MockUnityContainer.Instances[typeof(IUnityContainer)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IContainerFacade)));
            Assert.AreEqual(typeof(UnityContainerAdapter), bootstrapper.MockUnityContainer.Types[typeof(IContainerFacade)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IModuleLoader)));
            Assert.AreEqual(typeof(ModuleLoader), bootstrapper.MockUnityContainer.Types[typeof(IModuleLoader)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IRegionManager)));
            Assert.AreEqual(typeof(RegionManager), bootstrapper.MockUnityContainer.Types[typeof(IRegionManager)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IEventAggregator)));
            Assert.AreEqual(typeof(EventAggregator), bootstrapper.MockUnityContainer.Types[typeof(IEventAggregator)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(RegionAdapterMappings)));
            Assert.AreEqual(typeof(RegionAdapterMappings), bootstrapper.MockUnityContainer.Types[typeof(RegionAdapterMappings)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(IModuleEnumerator)));
            Assert.AreSame(bootstrapper.ModuleEnumerator, bootstrapper.MockUnityContainer.Instances[typeof(IModuleEnumerator)]);
        }
Example #11
0
        public void ShouldCallRunOnModuleManager()
        {
            var bootstrapper = new MockedBootstrapper();

            var moduleManager = new MockModuleManager();
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleManager), moduleManager);

            bootstrapper.Run();

            Assert.IsTrue(moduleManager.RunCalled);
        }
Example #12
0
        public void ShouldRegisterDefaultTypeMappings()
        {
            var bootstrapper = new MockedBootstrapper();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleCatalog), bootstrapper.ModuleCatalog);
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleInitializer), new MockModuleInitializer());
            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleManager), new MockModuleManager());

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(ILoggerFacade)));
            Assert.AreSame(bootstrapper.Logger, bootstrapper.MockUnityContainer.Instances[typeof(ILoggerFacade)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IServiceLocator)));
            Assert.AreEqual(typeof(UnityServiceLocatorAdapter), bootstrapper.MockUnityContainer.Types[typeof(IServiceLocator)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IModuleInitializer)));
            Assert.AreEqual(typeof(ModuleInitializer), bootstrapper.MockUnityContainer.Types[typeof(IModuleInitializer)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(IModuleCatalog)));
            Assert.AreSame(bootstrapper.ModuleCatalog, bootstrapper.MockUnityContainer.Instances[typeof(IModuleCatalog)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IRegionManager)));
            Assert.AreEqual(typeof(RegionManager), bootstrapper.MockUnityContainer.Types[typeof(IRegionManager)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(RegionAdapterMappings)));
            Assert.AreEqual(typeof(RegionAdapterMappings), bootstrapper.MockUnityContainer.Types[typeof(RegionAdapterMappings)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IRegionViewRegistry)));
            Assert.AreEqual(typeof(RegionViewRegistry), bootstrapper.MockUnityContainer.Types[typeof(IRegionViewRegistry)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IRegionBehaviorFactory)));
            Assert.AreEqual(typeof(RegionBehaviorFactory), bootstrapper.MockUnityContainer.Types[typeof(IRegionBehaviorFactory)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Types.ContainsKey(typeof(IEventAggregator)));
            Assert.AreEqual(typeof(EventAggregator), bootstrapper.MockUnityContainer.Types[typeof(IEventAggregator)]);

            Assert.AreEqual(8, bootstrapper.MockUnityContainer.Types.Count);

        }