public static void SetFakeContext(this ControllerBase controller) { var sessionContext = new HttpSessionStateBaseFake(); var httpContext = new HttpContextBaseFake(sessionContext); var controllerContext = new ControllerContextFake(); controllerContext.HttpContext = httpContext; controller.ControllerContext = controllerContext; }