當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。