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 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 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");
        }