public FakeHttpContext(
            IPrincipal principal,
            IFormParamsProvider formParams,
            IQueryStringParamsProvider queryStringParams,
            ICookieProvider cookies,
            IServerVariablesParamsProvider serverVariablesParams,
            IHeadersParamsProvider headersParams,
            SessionStateItemCollection sessionItems,
            HttpServerUtilityBase server,
            FakeHttpRequest request,
            IHttpContextBehavior contextBehavior)
        {
            User = principal;
            _sessionItems = sessionItems ?? new SessionStateItemCollection();
            _request = request ?? new FakeHttpRequest(formParams, queryStringParams, cookies, serverVariablesParams, headersParams);
            _request.SetIsAuthenticated(User.Identity != null ? User.Identity.IsAuthenticated : false);
            _server = server ?? new Mock<HttpServerUtilityBase>().Object;

            var httpResponse = new Mock<HttpResponseBase>();
            httpResponse.Setup(x => x.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(s => s);
            _response = httpResponse.Object;

            _behavior = contextBehavior;

            _items = new Hashtable();
        }
        public FakeHttpContext(
            IPrincipal principal,
            IFormParamsProvider formParams,
            IQueryStringParamsProvider queryStringParams,
            ICookieProvider cookies,
            IServerVariablesParamsProvider serverVariablesParams,
            IHeadersParamsProvider headersParams,
            SessionStateItemCollection sessionItems,
            HttpServerUtilityBase server,
            FakeHttpRequest request,
            IHttpContextBehavior contextBehavior)
        {
            User          = principal;
            _sessionItems = sessionItems ?? new SessionStateItemCollection();
            _request      = request ?? new FakeHttpRequest(formParams, queryStringParams, cookies, serverVariablesParams, headersParams);
            _request.SetIsAuthenticated(User?.Identity?.IsAuthenticated ?? false);
            Server = server ?? new Mock <HttpServerUtilityBase>().Object;

            var httpResponse = new Mock <HttpResponseBase>();

            httpResponse.Setup(x => x.ApplyAppPathModifier(It.IsAny <string>())).Returns <string>(s => s);
            Response = httpResponse.Object;

            _behavior = contextBehavior;

            Items = new Hashtable();
        }
Beispiel #3
0
 public FakeHttpContext(
     IPrincipal principal,
     IFormParamsProvider formParams,
     IQueryStringParamsProvider queryStringParams,
     HttpCookieCollection cookies,
     SessionStateItemCollection sessionItems,
     HttpServerUtilityBase server,
     FakeHttpRequest request,
     IHttpContextBehavior contextBehavior)
 {
     User = principal;
     _formParams = formParams ?? new EmptyFormsParamProvider();
     _queryStringParams = queryStringParams ?? new EmptyQueryStringParamProvider();
     _cookies = cookies ?? new HttpCookieCollection();
     _sessionItems = sessionItems ?? new SessionStateItemCollection();
     _request = request ?? new FakeHttpRequest();
     _request.SetIsAuthenticated(User.Identity != null ? User.Identity.IsAuthenticated : false);
     _server = server ?? new Mock<HttpServerUtilityBase>().Object;
     var httpResponse = new Mock<HttpResponseBase>();
     httpResponse.Setup(x => x.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(s => s);
     this._response = httpResponse.Object;
     this._behavior = contextBehavior;
 }
Beispiel #4
0
        public FakeHttpContext(
            IPrincipal principal,
            IFormParamsProvider formParams,
            IQueryStringParamsProvider queryStringParams,
            HttpCookieCollection cookies,
            SessionStateItemCollection sessionItems,
            HttpServerUtilityBase server,
            FakeHttpRequest request,
            IHttpContextBehavior contextBehavior)
        {
            User               = principal;
            _formParams        = formParams ?? new EmptyFormsParamProvider();
            _queryStringParams = queryStringParams ?? new EmptyQueryStringParamProvider();
            _cookies           = cookies ?? new HttpCookieCollection();
            _sessionItems      = sessionItems ?? new SessionStateItemCollection();
            _request           = request ?? new FakeHttpRequest();
            _request.SetIsAuthenticated(User.Identity != null ? User.Identity.IsAuthenticated : false);
            _server = server ?? new Mock <HttpServerUtilityBase>().Object;
            var httpResponse = new Mock <HttpResponseBase>();

            httpResponse.Setup(x => x.ApplyAppPathModifier(It.IsAny <string>())).Returns <string>(s => s);
            this._response = httpResponse.Object;
            this._behavior = contextBehavior;
        }