public async void Must_not_handle_non_configured_status_codes(int statusCode) { _response.Stub(arg => arg.StatusCode).Return(new StatusAndSubStatusCode(statusCode)); ResponseHandlerResult result = await _handler.HandleResponseAsync(_httpContext, _response, null, null); Assert.That(result.ResultType, Is.EqualTo(ResponseHandlerResultType.ResponseNotHandled)); }
public async void Must_handle_response_if_no_accept_headers_present(int statusCode) { _response.Stub(arg => arg.StatusCode).Return(new StatusAndSubStatusCode(statusCode)); ResponseHandlerResult result = await _handler.HandleResponseAsync(_httpContext, _response, null, null); Assert.That(result.ResultType, Is.EqualTo(ResponseHandlerResultType.ResponseWritten)); }
public async void Must_not_handle_response_when_response_has_no_cache_policy_but_cache_and_cache_key_was_provided() { _response.CachePolicy.Stub(arg => arg.HasPolicy).Return(false); ResponseHandlerResult result = await _handler.HandleResponseAsync(_httpContext, _response, _cache, "key"); Assert.That(result.ResultType, Is.EqualTo(ResponseHandlerResultType.ResponseNotHandled)); }
public async void Must_handle_response_if_accept_headers_allow_text_html(int statusCode) { _response.Stub(arg => arg.StatusCode).Return(new StatusAndSubStatusCode(statusCode)); _httpRequest.Headers["Accept"] = "text/html"; ResponseHandlerResult result = await _handler.HandleResponseAsync(_httpContext, _response, null, null); Assert.That(result.ResultType, Is.EqualTo(ResponseHandlerResultType.ResponseWritten)); }
private async Task ProcessResponseAsync(HttpContext context, IResponse response, string cacheKey) { foreach (IResponseHandler handler in _responseHandlers) { ResponseHandlerResult handlerResult = await handler.HandleResponseAsync(new HttpContextWrapper(context), response, _cache, cacheKey); switch (handlerResult.ResultType) { case ResponseHandlerResultType.ResponseWritten: return; case ResponseHandlerResultType.ResponseSuggested: response = handlerResult.SuggestedResponse; break; } } throw new ApplicationException("No response handler handled the response."); }
public void SetUp() { _result = ResponseHandlerResult.ResponseWritten(); }
public void SetUp() { _response = MockRepository.GenerateMock <IResponse>(); _result = ResponseHandlerResult.ResponseSuggested(_response); }
public void SetUp() { _result = ResponseHandlerResult.ResponseNotHandled(); }