public void OnActionExecuted_NullTempDataAlerts_SetsTempDataAlerts() { controller.TempData["Alerts"] = null; controller.BaseOnActionExecuted(new ActionExecutedContext()); Object actual = controller.TempData["Alerts"]; Object expected = controller.Alerts; Assert.Same(expected, actual); }
public void OnActionExecuted_SetsAlertsToTempDataThenAlertsInTempDataAreNull() { controller.TempData["Alerts"] = null; controller.BaseOnActionExecuted(new ActionExecutedContext()); Object actual = controller.TempData["Alerts"]; Object expected = controller.Alerts; Assert.AreSame(expected, actual); }
public void OnActionExecuted_MergesTempDataAlerts() { HttpContextBase context = controller.HttpContext; BaseControllerProxy mergedController = new BaseControllerProxy(); mergedController.ControllerContext = new ControllerContext(); mergedController.ControllerContext.HttpContext = context; mergedController.TempData = controller.TempData; mergedController.Alerts.AddError("Test1"); IEnumerable <Alert> controllerAlerts = controller.Alerts; IEnumerable <Alert> mergedAlerts = mergedController.Alerts; controller.Alerts.AddError("Test2"); controller.BaseOnActionExecuted(new ActionExecutedContext()); mergedController.BaseOnActionExecuted(new ActionExecutedContext()); IEnumerable <Alert> actual = controller.TempData["Alerts"] as AlertsContainer; IEnumerable <Alert> expected = controllerAlerts.Union(mergedAlerts); Assert.Equal(expected, actual); }
public void OnActionExecuted_MergesTempDataAlerts() { HttpContextBase context = controller.HttpContext; BaseControllerProxy mergedController = new BaseControllerProxy(); mergedController.ControllerContext = new ControllerContext(); mergedController.ControllerContext.HttpContext = context; mergedController.TempData = controller.TempData; mergedController.Alerts.AddError("Test1"); IEnumerable<Alert> controllerAlerts = controller.Alerts; IEnumerable<Alert> mergedAlerts = mergedController.Alerts; controller.Alerts.AddError("Test2"); controller.BaseOnActionExecuted(new ActionExecutedContext()); mergedController.BaseOnActionExecuted(new ActionExecutedContext()); IEnumerable<Alert> actual = controller.TempData["Alerts"] as AlertsContainer; IEnumerable<Alert> expected = controllerAlerts.Union(mergedAlerts); Assert.Equal(expected, actual); }