Beispiel #1
0
        public Task <object> DeserializeError(HttpResponseMessage response, ITypedBuilderContext context)
        {
            var error = _errors.GetResponse(new MockTypedRequestContext(context, new MockHttpRequestMessage(response.RequestMessage)));

            if (error == null)
            {
                return(_innerFormatter.DeserializeError(response, context));
            }

            return(Task.FromResult(error.Result));
        }
        public Task <HttpResponseMessage> SendAsync(HttpRequestMessage request)
        {
            var url = request.RequestUri.ToString();

            UrlCount.AddOrUpdate(url, 1, (u, c) =>
            {
                return(c + 1);
            });

            long urlCount;

            UrlCount.TryGetValue(url, out urlCount);

            var context = new MockHttpRequestMessage(request)
            {
                RequestCount           = 1,
                RequestCountForThisUrl = urlCount
            };

            var response = _responses.GetResponse(context);


            return(Task.FromResult(response.ToHttpResponseMessage(request)));
        }