public void InitializeSetsControllerContext() { // Arrange ControllerBaseHelper helper = new ControllerBaseHelper(); RequestContext requestContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData()); // Act helper.PublicInitialize(requestContext); // Assert Assert.AreSame(requestContext.HttpContext, helper.ControllerContext.HttpContext); Assert.AreSame(requestContext.RouteData, helper.ControllerContext.RouteData); Assert.AreSame(helper, helper.ControllerContext.Controller); }
public void InitializeSetsControllerContext() { // Arrange ControllerBaseHelper helper = new ControllerBaseHelper(); RequestContext requestContext = new RequestContext(new Mock <HttpContextBase>().Object, new RouteData()); // Act helper.PublicInitialize(requestContext); // Assert Assert.Same(requestContext.HttpContext, helper.ControllerContext.HttpContext); Assert.Same(requestContext.RouteData, helper.ControllerContext.RouteData); Assert.Same(helper, helper.ControllerContext.Controller); }
public void TempDataReturnsParentTempDataWhenInChildRequest() { // Arrange TempDataDictionary tempData = new TempDataDictionary(); ViewContext viewContext = new ViewContext { TempData = tempData }; RouteData routeData = new RouteData(); routeData.DataTokens[ControllerContext.ParentActionViewContextToken] = viewContext; RequestContext requestContext = new RequestContext(new Mock <HttpContextBase>().Object, routeData); ControllerBaseHelper controller = new ControllerBaseHelper(); controller.PublicInitialize(requestContext); // Act TempDataDictionary result = controller.TempData; // Assert Assert.Same(result, tempData); }
public void TempDataReturnsParentTempDataWhenInChildRequest() { // Arrange TempDataDictionary tempData = new TempDataDictionary(); ViewContext viewContext = new ViewContext { TempData = tempData }; RouteData routeData = new RouteData(); routeData.DataTokens[ControllerContext.PARENT_ACTION_VIEWCONTEXT] = viewContext; RequestContext requestContext = new RequestContext(new Mock<HttpContextBase>().Object, routeData); ControllerBaseHelper controller = new ControllerBaseHelper(); controller.PublicInitialize(requestContext); // Act TempDataDictionary result = controller.TempData; // Assert Assert.AreSame(result, tempData); }