public void InitializationExceptionsAreWrapped() { var moduleInfo = CreateModuleInfo(typeof(ExceptionThrowingModule)); ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), new MockLogger()); loader.Initialize(moduleInfo); }
public void ShouldResolveModuleAndInitializeSingleModule() { IServiceLocator containerFacade = new MockContainerAdapter(); var service = new ModuleInitializer(containerFacade, new MockLogger()); FirstTestModule.wasInitializedOnce = false; var info = CreateModuleInfo(typeof(FirstTestModule)); service.Initialize(info); Assert.IsTrue(FirstTestModule.wasInitializedOnce); }
public void ShouldLogModuleInitializationError() { IServiceLocator containerFacade = new MockContainerAdapter(); var logger = new MockLogger(); var service = new ModuleInitializer(containerFacade, logger); ExceptionThrowingModule.wasInitializedOnce = false; var exceptionModule = CreateModuleInfo(typeof(ExceptionThrowingModule)); try { service.Initialize(exceptionModule); } catch (ModuleInitializeException) { } Assert.IsNotNull(logger.LastMessage); StringAssert.Contains(logger.LastMessage, "ExceptionThrowingModule"); }
public void ShouldThrowExceptionIfBogusType() { var moduleInfo = new ModuleInfo("TestModule", "BadAssembly.BadType"); ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), new MockLogger()); try { loader.Initialize(moduleInfo); Assert.Fail("Did not throw exception"); } catch (ModuleInitializeException ex) { StringAssert.Contains(ex.Message, "BadAssembly.BadType"); } catch(Exception) { Assert.Fail(); } }
public void NullLoggerThrows() { ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), null); }
public void NullContainerThrows() { ModuleInitializer loader = new ModuleInitializer(null, new MockLogger()); }