本文整理汇总了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);
}
示例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");
}
示例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());
}
示例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>();
}
示例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);
}
示例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>());
}