当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestBase.Stub方法代码示例

本文整理汇总了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);
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:8,代码来源:JsonModelMapperTester.cs

示例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());
		}
开发者ID:envoyat,项目名称:Envoy.ArrCookieRestorer,代码行数:10,代码来源:ArrCookieRestorerModuleTest.cs

示例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);
        }
开发者ID:bclubb,项目名称:yabe,代码行数:15,代码来源:WebSpecification.cs

示例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());
        }
开发者ID:bnathyuw,项目名称:Restful-Simple-MVC,代码行数:15,代码来源:GetRouteDataActionTests.cs

示例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);
 }
开发者ID:pedroreys,项目名称:BlogPosts,代码行数:8,代码来源:HandlerTestBase.cs

示例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);
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:8,代码来源:FormsAuthenticationRequestContextTester.cs

示例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" }
             });
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:11,代码来源:FormToIConvertibleMapperTester.cs

示例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))
         };
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:21,代码来源:MostMatchingRestrictionsGeneratorTester.cs

示例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>();
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:19,代码来源:CacheableResponseHandlerTester.cs

示例10: SetUp

 public void SetUp()
 {
     _restriction = new RefererUrlPortRestriction(8080);
     _request = MockRepository.GenerateMock<HttpRequestBase>();
     _request.Stub(arg => arg.UrlReferrer).Return(new Uri("http://localhost:8081"));
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:6,代码来源:RefererUrlPortRestrictionTester.cs

示例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>());
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:17,代码来源:DescriptiveTextStatusCodeHandlerTester.cs

示例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"));
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:6,代码来源:RefererUrlAbsolutePathRestrictionTester.cs

示例13: SetUp

 public void SetUp()
 {
     _restriction = new MissingHeaderRestriction("field");
     _request = MockRepository.GenerateMock<HttpRequestBase>();
     _request.Stub(arg => arg.Headers).Return(new NameValueCollection { { "field", "value" } });
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:6,代码来源:MissingHeaderRestrictionTester.cs

示例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());
        }
开发者ID:bnathyuw,项目名称:Restful-Simple-MVC,代码行数:20,代码来源:GetVirtualPathResponseTypeTests.cs

示例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"));
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:6,代码来源:RefererUrlHostTypeRestrictionTester.cs


注:本文中的System.Web.HttpRequestBase.Stub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。