private IModuleExecutionEngine GetModuleExecutionEngine() { var moduleExecutionEngine = ComponentFactory.GetComponent <IModuleExecutionEngine>(); if (moduleExecutionEngine == null) { moduleExecutionEngine = new ModuleExecutionEngine(); ComponentFactory.RegisterComponentInstance <IModuleExecutionEngine>(moduleExecutionEngine); } return(moduleExecutionEngine); }
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); }
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); }
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); }
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>())); }
public void ExecuteModule_Requires_NonNull_ModuleRequestContext() { var engine = new ModuleExecutionEngine(); Assert.Throws <ArgumentNullException>(() => engine.ExecuteModule(null)); }