private static Mock <HttpContextBase> getContextMock(bool isAjaxContext) { Mock <HttpRequestBase> request = ControllerContextMock.getRequestMock(isAjaxContext); Mock <HttpContextBase> context = new Mock <HttpContextBase>(); context .SetupGet(x => x.Request) .Returns(request.Object); context .SetupGet(x => x.Cache) .Returns(new Cache()); HttpContext.Current = new HttpContext( new HttpRequest(null, "http://tempuri.org", null), new HttpResponse(null) ); return(context); }
public static void SetupNormalContext(Controller controller, string login = "******") { var context = ControllerContextMock.getContextMock(false, login); controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller); }
public static void SetupNormalContext(Controller controller) { var context = ControllerContextMock.getContextMock(false); controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller); }
public static void SetupAjaxContext(Controller controller) { var context = ControllerContextMock.getContextMock(true); controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller); }