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


C# HttpResponseBase.Stub方法代码示例

本文整理汇总了C#中System.Web.HttpResponseBase.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseBase.Stub方法的具体用法?C# HttpResponseBase.Stub怎么用?C# HttpResponseBase.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpResponseBase的用法示例。


在下文中一共展示了HttpResponseBase.Stub方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Context

        protected override void Context()
        {
            AccountService = MockRepository.GenerateStub<IAccountService>();

            Identity = new FakeIdentity(Username);
            _user = new FakePrincipal(Identity, null);

            HttpRequest = MockRepository.GenerateStub<HttpRequestBase>();
            HttpContext = MockRepository.GenerateStub<HttpContextBase>();
            HttpContext.Stub(x => x.Request).Return(HttpRequest);
            HttpContext.User = _user;

            _httpResponse = MockRepository.GenerateStub<HttpResponseBase>();
            _httpResponse.Stub(x => x.Cookies).Return(new HttpCookieCollection());
            HttpContext.Stub(x => x.Response).Return(_httpResponse);

            Logger = MockRepository.GenerateStub<ILogger>();
            WebAuthenticationService = MockRepository.GenerateStub<IWebAuthenticationService>();

            MappingEngine = MockRepository.GenerateStub<IMappingEngine>();
            AccountCreator = MockRepository.GenerateStub<IAccountCreator>();

            AccountController = new AccountController(AccountService, Logger, WebAuthenticationService, MappingEngine, null, AccountCreator);
            AccountController.ControllerContext = new ControllerContext(HttpContext, new RouteData(), AccountController);
        }
开发者ID:AcklenAvenue,项目名称:PRTools,代码行数:25,代码来源:given_an_account_controller_context.cs

示例2: SetUp

 public void SetUp()
 {
     _handler = new NonCacheableResponseHandler();
     _httpRequest = MockRepository.GenerateMock<HttpRequestBase>();
     _httpCachePolicyBase = MockRepository.GenerateMock<HttpCachePolicyBase>();
     _httpResponse = MockRepository.GenerateMock<HttpResponseBase>();
     _httpResponse.Stub(arg => arg.BinaryWrite(Arg<byte[]>.Is.Anything)).WhenCalled(arg => _responseWritten = true);
     _httpResponse.Stub(arg => arg.Cache).Return(_httpCachePolicyBase);
     _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>());
     _response.Stub(arg => arg.StatusCode).Return(new StatusAndSubStatusCode(HttpStatusCode.OK));
     _cache = MockRepository.GenerateMock<ICache>();
     _result = _handler.HandleResponse(_httpRequest, _httpResponse, _response, _cache, "key");
 }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:19,代码来源:NonCacheableResponseHandlerTester.cs

示例3: 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

示例4: 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

示例5: SetUp

            public void SetUp()
            {
                _httpCachePolicyBase = MockRepository.GenerateMock<HttpCachePolicyBase>();

                _httpResponseBase = MockRepository.GenerateMock<HttpResponseBase>();
                _httpResponseBase.Stub(arg => arg.Cache).Return(_httpCachePolicyBase);
                _httpResponseBase.Stub(arg => arg.Cookies).Return(new HttpCookieCollection());
                _httpResponseBase.Stub(arg => arg.Headers).Return(new NameValueCollection());

                Response response = Response
                    .OK()
                    .ApplicationJson()
                    .Charset("utf-8")
                    .Content("content")
                    .ContentEncoding(Encoding.ASCII)
                    .Cookie(new HttpCookie("name", "value"))
                    .Header("field", "value")
                    .HeaderEncoding(Encoding.UTF8);

                response.CachePolicy.NoClientCaching();

                _cacheResponse = new CacheResponse(response);
                _cacheResponse.WriteResponse(_httpResponseBase);
            }
开发者ID:dblchu,项目名称:JuniorRoute,代码行数:24,代码来源:CacheResponseTester.cs

示例6: 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


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