public static HttpContextBase ContextForUrl(HttpMethod method, string url, string requestBody)
        {
            var routeParts = url.Split('?');
            var relativeUrl = routeParts[0];
            var queryParams = UrlHelpers.MakeQueryParams(url);

            var request = new MockHttpRequest(method, relativeUrl, queryParams, requestBody);
            var httpContext = new MockHttpContext(request);

            var requestContext = new RequestContext(httpContext, new RouteData());
            request.SetContext(requestContext);

            return httpContext;
        }
Example #2
0
        public static HttpContextBase ContextForUrl(HttpMethod method, string url, string requestBody)
        {
            var routeParts  = url.Split('?');
            var relativeUrl = routeParts[0];
            var queryParams = UrlHelpers.MakeQueryParams(url);


            var request     = new MockHttpRequest(method, relativeUrl, queryParams, requestBody);
            var httpContext = new MockHttpContext(request);

            var requestContext = new RequestContext(httpContext, new RouteData());

            request.SetContext(requestContext);

            return(httpContext);
        }
Example #3
0
        public static HttpContextBase ContextForUrl(HttpMethod method, string url, string requestBody)
        {
            if (string.IsNullOrEmpty(url))
            {
                url = string.Empty;
            }
            var routeParts = url.Split('?');
            var relativeUrl = routeParts[0];
            var queryParamsValues = UrlHelpers.ReadQueryParams(url);
            var queryParams = queryParamsValues.AsNameValueCollection();

            var request = new MockHttpRequest(method, relativeUrl, queryParams, requestBody);
            var response = new MockHttpResponse();
            var httpContext = new MockHttpContext(request, response);

            var requestContext = new RequestContext(httpContext, new RouteData());
            request.SetContext(requestContext);

            return httpContext;
        }
Example #4
0
        public static HttpContextBase ContextForUrl(HttpMethod method, string url, string requestBody)
        {
            if (string.IsNullOrEmpty(url))
            {
                url = string.Empty;
            }
            var routeParts        = url.Split('?');
            var relativeUrl       = routeParts[0];
            var queryParamsValues = UrlHelpers.ReadQueryParams(url);
            var queryParams       = queryParamsValues.AsNameValueCollection();

            var request     = new MockHttpRequest(method, relativeUrl, queryParams, requestBody);
            var response    = new MockHttpResponse();
            var httpContext = new MockHttpContext(request, response);

            var requestContext = new RequestContext(httpContext, new RouteData());

            request.SetContext(requestContext);

            return(httpContext);
        }