Example #1
0
        public void Should_Return_Failed_ViewEngineResult_For_FindView_If_No_Current_Module_Application()
        {
            // Arrange
            var mockEngines = new Mock <ViewEngineCollection>();
            var viewEngine  = new ModuleDelegatingViewEngine();
            var controller  = new Mock <DnnController>();

            controller.SetupAllProperties();
            var context = MockHelper.CreateMockControllerContext(controller.Object);

            // Act
            var engineResult = viewEngine.FindView(context, "Foo", "Bar", true);

            // Assert
            Assert.IsNotNull(engineResult);
            Assert.IsNull(engineResult.View);
            Assert.AreEqual(0, engineResult.SearchedLocations.Count());
        }
        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 ExecuteRequest_Returns_Result_And_ControllerContext_From_Controller()
        {
            // Arrange
            var app = new ModuleApplication();

            ControllerContext controllerContext = MockHelper.CreateMockControllerContext();
            ActionResult      actionResult      = new Mock <ActionResult>().Object;

            var controller = SetupMockController(actionResult, controllerContext);

            var controllerFactory = SetupControllerFactory(controller.Object);

            app.ControllerFactory = controllerFactory.Object;

            ModuleRequestContext moduleRequestContext = CreateModuleContext(ControllerName, ActionName);

            // Act
            ModuleRequestResult result = app.ExecuteRequest(moduleRequestContext);

            // Assert
            Assert.AreSame(actionResult, result.ActionResult);
            Assert.AreSame(controllerContext, result.ControllerContext);
        }