Implements the IModuleInitializer interface. Handles loading of a module based on a type.
Наследование: IModuleInitializer
Пример #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);
 }
        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 NullLoggerThrows()
 {
     ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), null);
 }
Пример #5
0
 public void NullContainerThrows()
 {
     ModuleInitializer loader = new ModuleInitializer(null, new MockLogger());
 }
Пример #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();
            }

        }
 public void NullLoggerThrows()
 {
     Assert.ThrowsException<ArgumentNullException>(() => { ModuleInitializer loader = new ModuleInitializer(new MockContainerAdapter(), null); });
 }