コード例 #1
0
ファイル: ProxyMiddleware.cs プロジェクト: kate-r/JustFakeIt
        private Task ProcessMatchingExpectation(IOwinResponse response, HttpExpectation httpExpectation)
        {
            var httpResponseExpectation = httpExpectation.Response;
            if (httpExpectation.ResponseExpectationCallback != null)
            {
                httpResponseExpectation = httpExpectation.ResponseExpectationCallback.Invoke();
            }

            var expectedResults = string.Empty;
            if (httpResponseExpectation != null)
            {
                response.StatusCode = (int)httpResponseExpectation.StatusCode;
                expectedResults = httpResponseExpectation.ExpectedResult;

                if (httpResponseExpectation.Headers != null)
                {
                    foreach (var key in httpResponseExpectation.Headers.AllKeys)
                        response.Headers.Add(key, new[] {httpResponseExpectation.Headers[key]});
                }
            }

            if (response.Headers != null)
                response.Headers.Add("Content-Type", new[] {"application/json"});

            Task.Delay(_expect.ResponseTime).Wait();

            return response.WriteAsync(expectedResults);
        }
コード例 #2
0
        private Task ProcessMatchingExpectation(IOwinResponse response, HttpExpectation httpExpectation)
        {
            var httpResponseExpectation = httpExpectation.Response;

            if (httpExpectation.ResponseExpectationCallback != null)
            {
                httpResponseExpectation = httpExpectation.ResponseExpectationCallback.Invoke();
            }

            var expectedResults = string.Empty;

            if (httpResponseExpectation != null)
            {
                response.StatusCode = (int)httpResponseExpectation.StatusCode;
                expectedResults     = httpResponseExpectation.ExpectedResult;

                if (httpResponseExpectation.Headers != null)
                {
                    foreach (var key in httpResponseExpectation.Headers.AllKeys)
                    {
                        response.Headers.Add(key, new[] { httpResponseExpectation.Headers[key] });
                    }
                }
            }

            if (response.Headers != null)
            {
                response.Headers.Add("Content-Type", new[] { "application/json" });
            }

            Task.Delay(_expect.ResponseTime).Wait();

            return(response.WriteAsync(expectedResults));
        }
コード例 #3
0
ファイル: Expect.cs プロジェクト: shaynevanasperen/JustFakeIt
        public HttpExpectation Put(string url, string body)
        {
            var httpExpectation = new HttpExpectation
            {
                Request = new HttpRequestExpectation(Http.Put, url, body),
            };

            Expectations.Add(httpExpectation);

            return httpExpectation;
        }
コード例 #4
0
ファイル: Expect.cs プロジェクト: shaynevanasperen/JustFakeIt
        public HttpExpectation Get(string url)
        {
            var httpExpectation = new HttpExpectation
            {
                Request = new HttpRequestExpectation(Http.Get, url),
            };

            Expectations.Add(httpExpectation);

            return httpExpectation;
        }
コード例 #5
0
ファイル: Expect.cs プロジェクト: JonahAcquah/JustFakeIt
        private HttpExpectation Method(Http method, string url, string body = null)
        {
            var httpExpectation = new HttpExpectation
            {
                Request = new HttpRequestExpectation(method, url, body)
            };

            Expectations.Add(httpExpectation);

            return httpExpectation;
        }
コード例 #6
0
ファイル: Expect.cs プロジェクト: justeat/JustFakeIt
        private HttpExpectation Method(Http method, string url, string body = null, WebHeaderCollection expectedHeaders = null)
        {
            var httpExpectation = new HttpExpectation
            {
                Request = new HttpRequestExpectation(method, url, body, expectedHeaders)
            };

            Expectations.Add(httpExpectation);

            return httpExpectation;
        }
コード例 #7
0
        private HttpExpectation Method(Http method, string url, string body = null, WebHeaderCollection expectedHeaders = null)
        {
            var httpExpectation = new HttpExpectation
            {
                Request = new HttpRequestExpectation(method, url, body, expectedHeaders)
            };

            Expectations.Add(httpExpectation);

            return(httpExpectation);
        }
コード例 #8
0
        private HttpExpectation Method(Http method, string url, string body = null)
        {
            var httpExpectation = new HttpExpectation
            {
                Request = new HttpRequestExpectation(method, url, body)
            };

            Expectations.Add(httpExpectation);

            return(httpExpectation);
        }
コード例 #9
0
ファイル: Expect.cs プロジェクト: tharris29/JustFakeIt
        public HttpExpectation Post(string url, string body)
        {
            var httpExpectation = new HttpExpectation
            {
                Request = new HttpRequestExpectation(Http.Post, url, body),
            };

            Expectations.Add(httpExpectation);

            return(httpExpectation);
        }
コード例 #10
0
ファイル: Expect.cs プロジェクト: tharris29/JustFakeIt
        public HttpExpectation Delete(string url)
        {
            var httpExpectation = new HttpExpectation
            {
                Request = new HttpRequestExpectation(Http.Delete, url),
            };

            Expectations.Add(httpExpectation);

            return(httpExpectation);
        }
コード例 #11
0
ファイル: ProxyMiddleware.cs プロジェクト: bitoiu/JustFakeIt
        private Task ProcessMatchingExpectation(IOwinResponse response, HttpExpectation httpExpectation)
        {
            foreach (var key in httpExpectation.Response.Headers.AllKeys)
                response.Headers.Add(key, new[] { httpExpectation.Response.Headers[key] });

            response.Headers.Add("Content-Type", new[] { "application/json" });
            response.StatusCode = (int)httpExpectation.Response.StatusCode;

            Task.Delay(_expect.ResponseTime).Wait();

            return response.WriteAsync(httpExpectation.Response.ExpectedResult);
        }