コード例 #1
0
        public void InitializationExceptionsAreWrapped()
        {
            var moduleInfo = CreateModuleInfo(typeof(ExceptionThrowingModule));

            ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), new MockLogger());

            loader.Initialize(moduleInfo);
        }
コード例 #2
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);
 }
コード例 #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");
        }
コード例 #4
0
        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();
            }

        }
コード例 #5
0
 public void NullLoggerThrows()
 {
     ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), null);
 }
コード例 #6
0
 public void NullContainerThrows()
 {
     ModuleInitializer loader = new ModuleInitializer(null, new MockLogger());
 }