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)]); }
public void ReturningNullContainerThrows() { var bootstrapper = new MockedBootstrapper(); bootstrapper.MockUnityContainer = null; AssertExceptionThrownOnRun(bootstrapper, typeof(InvalidOperationException), "IUnityContainer"); }
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"); }
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 ShouldCallRunOnModuleManager() { var bootstrapper = new MockedBootstrapper(); var moduleManager = new MockModuleManager(); bootstrapper.MockUnityContainer.ResolveBag.Add(typeof(IModuleManager), moduleManager); bootstrapper.Run(); Assert.IsTrue(moduleManager.RunCalled); }
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 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 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); }