コード例 #1
0
 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);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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");
        }