示例#1
0
        private IModuleExecutionEngine GetModuleExecutionEngine()
        {
            var moduleExecutionEngine = ComponentFactory.GetComponent <IModuleExecutionEngine>();

            if (moduleExecutionEngine == null)
            {
                moduleExecutionEngine = new ModuleExecutionEngine();
                ComponentFactory.RegisterComponentInstance <IModuleExecutionEngine>(moduleExecutionEngine);
            }
            return(moduleExecutionEngine);
        }
示例#2
0
        public void ExecuteModule_Returns_Null_If_Application_Is_Null()
        {
            // Arrange
            var engine         = new ModuleExecutionEngine();
            var requestContext = new ModuleRequestContext()
            {
                ModuleApplication = null
            };

            // Act
            ModuleRequestResult result = engine.ExecuteModule(requestContext);

            // Assert
            Assert.IsNull(result);
        }
示例#3
0
        public void ExecuteModule_Executes_ModuleApplication_If_Not_Null()
        {
            // Arrange
            var engine = new ModuleExecutionEngine();

            var moduleApp      = new Mock <ModuleApplication>();
            var requestContext = new ModuleRequestContext()
            {
                ModuleApplication = moduleApp.Object
            };

            // Act
            engine.ExecuteModule(requestContext);

            // Assert
            moduleApp.Verify(app => app.ExecuteRequest(It.IsAny <ModuleRequestContext>()));
        }
        public void ModuleExecutionTests()
        {
            var modules = new List<Type> { typeof(Module2), typeof(Module1), typeof(Module5), typeof(Module3), typeof(Module4) };

            var modulesWithDep =
                modules.Select(
                               m =>
                               new ModuleDescriptor(this._container.GetInstance(m) as IInitializableModule,
                                                    m,
                                                    TypeHelper.GetAttributes<ModuleDependencyAttribute>(m).Select(d => d.DependencyModule))).ToList();

            Assert.NotNull(modulesWithDep);

            var engine = new ModuleExecutionEngine();
            var weighter = new ModuleWeighter();

            var context = engine.RunModules(weighter.SortModules(modulesWithDep), new ModuleExecutionContext());
            Assert.NotEmpty(context.Log);
        }
示例#5
0
        public void ExecuteModule_Returns_Result_Of_Executing_ModuleApplication()
        {
            // Arrange
            var engine   = new ModuleExecutionEngine();
            var expected = new ModuleRequestResult();

            var moduleApp = new Mock <ModuleApplication>();

            moduleApp.Setup(app => app.ExecuteRequest(It.IsAny <ModuleRequestContext>()))
            .Returns(expected);
            var requestContext = new ModuleRequestContext()
            {
                ModuleApplication = moduleApp.Object
            };

            // Act
            ModuleRequestResult actual = engine.ExecuteModule(requestContext);

            // Assert
            Assert.AreSame(expected, actual);
        }
示例#6
0
        public void ModuleExecutionTests()
        {
            var modules = new List <Type> {
                typeof(Module2), typeof(Module1), typeof(Module5), typeof(Module3), typeof(Module4)
            };

            var modulesWithDep =
                modules.Select(
                    m =>
                    new ModuleDescriptor(this._container.GetInstance(m) as IInitializableModule,
                                         m,
                                         TypeHelper.GetAttributes <ModuleDependencyAttribute>(m).Select(d => d.DependencyModule))).ToList();

            Assert.NotNull(modulesWithDep);

            var engine   = new ModuleExecutionEngine();
            var weighter = new ModuleWeighter();

            var context = engine.RunModules(weighter.SortModules(modulesWithDep), new ModuleExecutionContext());

            Assert.NotEmpty(context.Log);
        }
        public void ExecuteModuleResult_Calls_IDnnViewResult_ExecuteResult()
        {
            // Arrange
            var engine = new ModuleExecutionEngine();

            var actionResultMock = new Mock <ActionResult>();

            var viewResultMock = actionResultMock.As <IDnnViewResult>();

            var controllerContext   = MockHelper.CreateMockControllerContext();
            var moduleRequestResult = new ModuleRequestResult
            {
                ActionResult      = actionResultMock.Object,
                ControllerContext = controllerContext,
            };

            // Act
            engine.ExecuteModuleResult(moduleRequestResult, new StringWriter());

            // Arrange
            viewResultMock.Verify(v => v.ExecuteResult(It.IsAny <ControllerContext>(), It.IsAny <TextWriter>()));
        }
示例#8
0
        public void ExecuteModule_Requires_NonNull_ModuleRequestContext()
        {
            var engine = new ModuleExecutionEngine();

            Assert.Throws <ArgumentNullException>(() => engine.ExecuteModule(null));
        }