/// <summary> /// Asserts that an ActionRedirectResult is for the specified action on the specified controller /// </summary> /// <typeparam name="TController">The type of the controller.</typeparam> /// <param name="result">The result to check.</param> /// <param name="action">The action to call on the controller.</param> /// <returns></returns> public static RedirectToRouteResult ToAction <TController>(this RedirectToRouteResult result, Expression <Action <TController> > action) where TController : IController { var methodCall = (MethodCallExpression)action.Body; string actionName = methodCall.Method.Name; const string ControllerSuffix = "Controller"; var controllerTypeName = typeof(TController).Name; if (controllerTypeName.EndsWith(ControllerSuffix, StringComparison.OrdinalIgnoreCase)) { controllerTypeName = controllerTypeName.Substring(0, controllerTypeName.Length - ControllerSuffix.Length); } return(result.ToController(controllerTypeName).ToAction(actionName)); }