コード例 #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)]);
        }
コード例 #2
0
        public void ReturningNullContainerThrows()
        {
            var bootstrapper = new MockedBootstrapper();

            bootstrapper.MockUnityContainer = null;

            AssertExceptionThrownOnRun(bootstrapper, typeof(InvalidOperationException), "IUnityContainer");
        }
コード例 #3
0
        public void NullModuleLoaderThrowsOnDefaultModuleInitialization()
        {
            var bootstrapper = new MockedBootstrapper();

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

            AssertExceptionThrownOnRun(bootstrapper, typeof(InvalidOperationException), "IModuleLoader");
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
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);
        }
コード例 #8
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);
        }
コード例 #9
0
        public void ReturningNullContainerThrows()
        {
            var bootstrapper = new MockedBootstrapper();
            bootstrapper.MockUnityContainer = null;

            AssertExceptionThrownOnRun(bootstrapper, typeof(InvalidOperationException), "IUnityContainer");
        }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
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);
        }
コード例 #13
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)]);
        }
コード例 #14
0
        public void NullModuleLoaderThrowsOnDefaultModuleInitialization()
        {
            var bootstrapper = new MockedBootstrapper();

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

            AssertExceptionThrownOnRun(bootstrapper, typeof(InvalidOperationException), "IModuleLoader");
        }
コード例 #15
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);
        }
コード例 #16
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);

        }