本文整理汇总了C#中System.Web.HttpRequestBase.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestBase.Stub方法的具体用法?C# HttpRequestBase.Stub怎么用?C# HttpRequestBase.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpRequestBase
的用法示例。
在下文中一共展示了HttpRequestBase.Stub方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request.Stub(arg => arg.ContentEncoding).Return(Encoding.ASCII);
_request.Stub(arg => arg.ContentType).Return("application/json");
_request.Stub(arg => arg.InputStream).Return(new MemoryStream(Encoding.ASCII.GetBytes("{")));
_mapper = new JsonModelMapper(DataConversionErrorHandling.ThrowException);
}
示例2: Initialise
public void Initialise()
{
request = MockRepository.GenerateStub<HttpRequestBase>();
request.Stub(r => r.Headers).Return(new NameValueCollection());
request.Stub(r => r.QueryString).Return(new NameValueCollection());
request.Stub(r => r.ApplicationPath).Return("/");
request.Stub(r => r.Url).Return(new Uri("http://www.example.com/"));
response = MockRepository.GenerateStub<HttpResponseBase>();
response.Stub(r => r.Headers).Return(new NameValueCollection());
}
示例3: SetUp
public virtual void SetUp()
{
mockRequest = MockRepository.GenerateStub<HttpRequestBase>();
mockContext = MockRepository.GenerateStub<HttpContextBase>();
mockSession = new MockSession();
formCollection = new NameValueCollection();
querystringCollection = new NameValueCollection();
mockRequest.Stub(x => x.Form).Return(formCollection);
mockRequest.Stub(x => x.QueryString).Return(querystringCollection);
mockContext.Stub(x => x.Request).Return(mockRequest);
mockContext.Stub(x => x.Session).Return(mockSession);
}
示例4: SetUp
public void SetUp()
{
_httpRequest = MockRepository.GenerateStub<HttpRequestBase>();
_httpRequest.Stub(r => r.AppRelativeCurrentExecutionFilePath).Return("~/" + URL);
_httpRequest.Stub(r => r.PathInfo).Return("");
_httpRequest.Stub(r => r.Form).Return(_form);
_httpRequest.Stub(r => r.Headers).Return(_headers);
_httpRequest.Stub(r => r.QueryString).Return(_queryString);
_httpContext = MockRepository.GenerateStub<HttpContextBase>();
_httpContext.Stub(c => c.Request).Return(_httpRequest);
var acceptHeaderResponseTypeResolver = MockRepository.GenerateStub<IAcceptHeaderResponseTypeResolver>();
_route = new RestfulRoute(URL, CONTROLLER, new ResponseTypeMapper(acceptHeaderResponseTypeResolver), new ActionMapper());
}
示例5: SetUp
public void SetUp()
{
HttpContext = Stub<HttpContextBase>();
HttpRequest = Stub<HttpRequestBase>();
HttpContext.Stub(x => x.Request).Return(HttpRequest);
Headers = new NameValueCollection();
HttpRequest.Stub(x => x.Headers).Return(Headers);
}
示例6: SetUp
public void SetUp()
{
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request.Stub(arg => arg.Cookies).Return(new HttpCookieCollection { new HttpCookie(".juniorauth", "invalid") });
_requestContext = MockRepository.GenerateMock<IRequestContext>();
_requestContext.Stub(arg => arg.Request).Return(_request);
_authenticationData = new FormsAuthenticationData<dynamic>(_requestContext);
}
示例7: SetUp
public void SetUp()
{
_mapper = new FormToIConvertibleMapper(errorHandling:DataConversionErrorHandling.ThrowException);
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request
.Stub(arg => arg.Form)
.Return(new NameValueCollection
{
{ "I", "1.2" }
});
}
示例8: SetUp
public void SetUp()
{
_generator = new MostMatchingRestrictionsGenerator();
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request.Stub(arg => arg.Url).Return(new Uri("http://localhost"));
_request.Stub(arg => arg.HttpMethod).Return("GET");
_route1Response = new Response(200);
_route1 = new Route.Routing.Route("name1", Guid.NewGuid(), "relative1");
_route1.RestrictByMethods(HttpMethod.Get);
_route1.RespondWith(_route1Response);
_route2Response = new Response(200);
_route2 = new Route.Routing.Route("name2", Guid.NewGuid(), "relative2");
_route2.RestrictByMethods(HttpMethod.Get);
_route2.RestrictByUrl(uri => true);
_route2.RespondWith(_route2Response);
_routeMatchResults = new[]
{
new RouteMatchResult(_route1, _route1.MatchesRequest(_request)),
new RouteMatchResult(_route2, _route2.MatchesRequest(_request))
};
}
示例9: SetUp
public void SetUp()
{
_systemClock = MockRepository.GenerateMock<ISystemClock>();
_handler = new CacheableResponseHandler(_systemClock);
_httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
_httpRequest.Stub(arg => arg.Headers).Return(new NameValueCollection());
_httpResponse = MockRepository.GenerateMock<HttpResponseBase>();
_httpResponse.Stub(arg => arg.Headers).Return(new NameValueCollection());
_cachePolicy = MockRepository.GenerateMock<ICachePolicy>();
_cachePolicy.Stub(arg => arg.Clone()).Return(_cachePolicy);
_cachePolicy.Stub(arg => arg.ClientCacheExpirationUtcTimestamp).Return(DateTime.UtcNow);
_response = MockRepository.GenerateMock<IResponse>();
_response.Stub(arg => arg.CachePolicy).Return(_cachePolicy);
_response.Stub(arg => arg.Cookies).Return(Enumerable.Empty<Cookie>());
_response.Stub(arg => arg.Headers).Return(Enumerable.Empty<Header>());
_response.Stub(arg => arg.StatusCode).Return(new StatusAndSubStatusCode(HttpStatusCode.OK));
_response.Stub(arg => arg.GetContent()).Return(new byte[0]);
_cache = MockRepository.GenerateMock<ICache>();
}
示例10: SetUp
public void SetUp()
{
_restriction = new RefererUrlPortRestriction(8080);
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request.Stub(arg => arg.UrlReferrer).Return(new Uri("http://localhost:8081"));
}
示例11: SetUp
public void SetUp()
{
_handler = new DescriptiveTextStatusCodeHandler(200);
_httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
_httpRequest.Stub(arg => arg.Headers).Return(new NameValueCollection());
_httpCachePolicyBase = MockRepository.GenerateMock<HttpCachePolicyBase>();
_httpResponse = MockRepository.GenerateMock<HttpResponseBase>();
_httpResponse.Stub(arg => arg.Cache).Return(_httpCachePolicyBase);
_httpResponse.Stub(arg => arg.TrySkipIisCustomErrors).PropertyBehavior();
_cachePolicy = MockRepository.GenerateMock<ICachePolicy>();
_cachePolicy.Stub(arg => arg.Clone()).Return(_cachePolicy);
_response = MockRepository.GenerateMock<IResponse>();
_response.Stub(arg => arg.CachePolicy).Return(_cachePolicy);
_response.Stub(arg => arg.Cookies).Return(Enumerable.Empty<Cookie>());
_response.Stub(arg => arg.GetContent()).Return(new byte[0]);
_response.Stub(arg => arg.Headers).Return(Enumerable.Empty<Header>());
}
示例12: SetUp
public void SetUp()
{
_restriction = new RefererUrlAbsolutePathRestriction("path1", CaseInsensitivePlainComparer.Instance);
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request.Stub(arg => arg.UrlReferrer).Return(new Uri("http://localhost/path2"));
}
示例13: SetUp
public void SetUp()
{
_restriction = new MissingHeaderRestriction("field");
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request.Stub(arg => arg.Headers).Return(new NameValueCollection { { "field", "value" } });
}
示例14: SetUp
public void SetUp()
{
_httpRequest = MockRepository.GenerateStub<HttpRequestBase>();
_httpRequest.Stub(r => r.PathInfo).Return("");
_httpRequest.Stub(r => r.HttpMethod).Return("Get");
_httpRequest.Stub(r => r.Form).Return(_form);
_httpRequest.Stub(r => r.Headers).Return(_headers);
_httpContext = MockRepository.GenerateStub<HttpContextBase>();
_httpContext.Stub(c => c.Request).Return(_httpRequest);
_routeData = MockRepository.GenerateStub<RouteData>();
_requestContext = MockRepository.GenerateStub<RequestContext>();
_requestContext.RouteData = _routeData;
_requestContext.HttpContext = _httpContext;
_acceptHeaderResponseTypeResolver = MockRepository.GenerateStub<IAcceptHeaderResponseTypeResolver>();
_route = new RestfulRoute(URL, CONTROLLER, new ResponseTypeMapper(_acceptHeaderResponseTypeResolver), new ActionMapper());
}
示例15: SetUp
public void SetUp()
{
_restriction = new RefererUrlHostTypeRestriction(UriHostNameType.IPv6);
_request = MockRepository.GenerateMock<HttpRequestBase>();
_request.Stub(arg => arg.UrlReferrer).Return(new Uri("http://127.0.0.1"));
}