I answered my question, it is very similar to this.
You will also need the http method
(this is GET, POST) to get the correct result, in addition to the names of actions and controllers.
This is the part of the code that solves your problem:
var controllerFactory = ControllerBuilder.Current .GetControllerFactory(); var controllerContext = @this.ControllerContext; var otherController = (ControllerBase)controllerFactory .CreateController( new RequestContext(controllerContext.HttpContext, new RouteData()), controllerName); var controllerDescriptor = new ReflectedControllerDescriptor( otherController.GetType()); var controllerContext2 = new ControllerContext( new MockHttpContextWrapper( controllerContext.HttpContext.ApplicationInstance.Context, method), new RouteData(), otherController); var actionDescriptor = controllerDescriptor .FindAction(controllerContext2, actionName);
source share