コード例 #1
0
        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);
        }
コード例 #2
0
        public static void SetupNormalContext(Controller controller, string login = "******")
        {
            var context = ControllerContextMock.getContextMock(false, login);

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
        }
コード例 #3
0
        public static void SetupNormalContext(Controller controller)
        {
            var context = ControllerContextMock.getContextMock(false);

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
        }
コード例 #4
0
        public static void SetupAjaxContext(Controller controller)
        {
            var context = ControllerContextMock.getContextMock(true);

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
        }