Exemplo n.º 1
0
        public void InitializationExceptionsAreWrapped()
        {
            var moduleInfo = CreateModuleInfo(typeof(ExceptionThrowingModule));

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

            loader.Initialize(moduleInfo);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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");
        }
Exemplo n.º 4
0
 public void NullLoggerThrows()
 {
     ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), null);
 }
Exemplo n.º 5
0
 public void NullContainerThrows()
 {
     ModuleInitializer loader = new ModuleInitializer(null, new MockLogger());
 }
Exemplo n.º 6
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();
            }

        }