コード例 #1
0
        public void ShouldRegisterDefaultTypeMappings()
        {
            var bootstrapper = new MockedBootstrapper();

            bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleCatalog), 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(IEventAggregator)));
            Assert.AreEqual(typeof(EventAggregator), bootstrapper.MockUnityContainer.Types[typeof(IEventAggregator)]);

            Assert.IsTrue(bootstrapper.MockUnityContainer.Instances.ContainsKey(typeof(IModuleCatalog)));
            Assert.AreSame(bootstrapper.ModuleEnumerator, bootstrapper.MockUnityContainer.Instances[typeof(IModuleCatalog)]);
        }
コード例 #2
0
        public void ShouldCallInitializeOnModuleLoader()
        {
            var bootstrapper = new MockedBootstrapper();

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

            bootstrapper.Run();

            Assert.IsTrue(moduleLoader.InitializeCalled);
        }
コード例 #3
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(IModuleCatalog), 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);
        }
コード例 #4
0
        public void ShouldCallGetStartupLoadedModules()
        {
            var bootstrapper = new MockedBootstrapper();

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

            bootstrapper.Run();

            Assert.IsTrue(bootstrapper.ModuleEnumerator.GetStartupLoadedModulesCalled);
        }