public void AddResponderReturnInvalidChangesFeedJson()
        {
            var json = "{\"results\":[wedon'tneednoquotes]}";
            HttpResponseDelegate responder = (request) => GenerateHttpResponseMessage(HttpStatusCode.Accepted, null, json);

            SetResponder("_changes", responder);
        }
        public void AddResponderReturnEmptyChangesFeed()
        {
            var json = "{\"results\":[]}";
            HttpResponseDelegate responder = (request) => GenerateHttpResponseMessage(HttpStatusCode.Accepted, null, json);

            SetResponder("_changes", responder);
        }
        public void AddResponderFakeLocalDocumentUpdate404()
        {
            var json = "{\"error\":\"not_found\",\"reason\":\"missing\"}";
            HttpResponseDelegate responder = (request) => GenerateHttpResponseMessage(HttpStatusCode.NotFound, null, json);

            SetResponder("_local", responder);
        }
        public void AddResponderThrowExceptionAllRequests()
        {
            HttpResponseDelegate responder = (request) => {
                throw new WebException("Test WebException", WebExceptionStatus.ConnectionClosed);
            };

            SetResponder("*", responder);
        }
        public static HttpResponseDelegate TransientErrorResponder(Int32 statusCode, string statusMesg)
        {
            HttpResponseDelegate responder = (request) =>
            {
                if (statusCode == -1)
                {
                    throw new IOException("Fake IO Exception from TransientErrorResponder");
                }
                return(GenerateHttpResponseMessage((HttpStatusCode)statusCode, statusMesg, null));
            };

            return(responder);
        }
        public void AddResponderFakeLocalDocumentUpdateIOException()
        {
            HttpResponseDelegate responder = (request) => FakeLocalDocumentUpdateIOException(request);

            SetResponder("_local", responder);
        }
        public void AddResponderFailAllRequests(HttpStatusCode statusCode)
        {
            HttpResponseDelegate responder = (request) => new HttpResponseMessage(statusCode);

            SetResponder("*", responder);
        }
        public void AddResponderRevDiffsAllMissing()
        {
            HttpResponseDelegate responder = (request) => FakeRevsDiff(request);

            SetResponder("_revs_diff", responder);
        }
        public void AddResponderFakeBulkDocs()
        {
            HttpResponseDelegate responder = (request) => FakeBulkDocs(request);

            SetResponder("_bulk_docs", responder);
        }
 public void SetResponder(string urlPattern, HttpResponseDelegate responder)
 {
     responders[urlPattern] = responder;
 }
 public void SetResponder(string urlPattern, HttpResponseDelegate responder)
 {
     responders[urlPattern] = responder;
 }
예제 #12
0
 public HttpContentBuilder(HttpWebRequest httpWebRequest, IReadOnlyCollection <ISerializer> serializers, IReadOnlyCollection <IDeserializer> deserializers)
 {
     _httpRequest  = new HttpRequestDelegate(httpWebRequest, serializers);
     _httpResponse = new HttpResponseDelegate(httpWebRequest, deserializers);
 }