public void ShouldLogModuleInitializeErrorsAndContinueLoading() { IServiceLocator containerFacade = new MockContainerAdapter(); var logger = new MockLogger(); var service = new CustomModuleInitializerService(containerFacade, logger); var invalidModule = CreateModuleInfo(typeof(InvalidModule)); Assert.IsFalse(service.HandleModuleInitializerrorCalled); service.Initialize(invalidModule); Assert.IsTrue(service.HandleModuleInitializerrorCalled); }
public void ShouldLogMessageOnModuleRetrievalError() { var loader = new MockModuleInitializer(); var moduleInfo = CreateModuleInfo("ModuleThatNeedsRetrieval", InitializationMode.WhenAvailable); var catalog = new MockModuleCatalog { Modules = { moduleInfo } }; var logger = new MockLogger(); ModuleManager manager = new ModuleManager(loader, catalog, logger); var moduleTypeLoader = new MockModuleTypeLoader(); manager.ModuleTypeLoaders = new List<IModuleTypeLoader> { moduleTypeLoader }; manager.Run(); try { moduleTypeLoader.RaiseCallbackForModule(moduleInfo, new Exception()); } catch { // Ignore all errors to make sure logger is called even if errors thrown. } Assert.IsNotNull(logger.LastMessage); StringAssert.Contains(logger.LastMessage, "ModuleThatNeedsRetrieval"); Assert.AreEqual<Category>(Category.Exception, logger.LastMessageCategory); }
public void ShouldLogModuleInitializationError() { IContainerFacade containerFacade = new MockContainerAdapter(); var logger = new MockLogger(); var service = new ModuleLoader(containerFacade, logger); ExceptionThrowingModule.wasInitializedOnce = false; var exceptionModule = new ModuleInfo(typeof(ExceptionThrowingModule).Assembly.Location, typeof(ExceptionThrowingModule).FullName, "ExceptionThrowingModule"); try { service.Initialize(new[] { exceptionModule }); } catch (ModuleLoadException) { } Assert.IsNotNull(logger.LastMessage); StringAssert.Contains(logger.LastMessage, "ExceptionThrowingModule"); }
public void ShouldLogModuleInitializeErrorsAndContinueLoading() { IContainerFacade containerFacade = new MockContainerAdapter(); var logger = new MockLogger(); var service = new CustomModuleInitializerService(containerFacade, logger); var invalidModule = new ModuleInfo(typeof(InvalidModule).Assembly.Location, typeof(InvalidModule).FullName, "InvalidModule"); Assert.IsFalse(service.HandleModuleLoadErrorCalled); service.Initialize(new[] { invalidModule }); Assert.IsTrue(service.HandleModuleLoadErrorCalled); }
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"); }