예제 #1
0
        public void CompareBody(string recordedEncoding, string recordedBody, string encoding, string body, bool compare, bool found)
        {
            //arrange
            var matcher = new DefaultRequestMatcher()
            {
                CompareBody = compare
            };
            var recordedRequest = new HttpRequest {
                Uri    = "https://example.com",
                Method = "POST",
                Body   = new HttpBody {
                    Encoding = recordedEncoding,
                    String   = recordedBody
                }
            };
            var request = new HttpRequest {
                Uri    = "https://example.com",
                Method = "POST",
                Body   = new HttpBody {
                    Encoding = encoding,
                    String   = body
                }
            };

            //act
            var result = matcher.FindMatch(new[] { new HttpInteraction {
                                                       Request = recordedRequest
                                                   } }, request);

            //assert
            Assert.Equal(found, result != null);
        }
예제 #2
0
        public void CompareHeaders(Dictionary <string, List <string> > recordedHeaders, Dictionary <string, List <string> > headers, bool compare, bool found)
        {
            //arrange
            var matcher = new DefaultRequestMatcher()
            {
                CompareHeaders = compare
            };
            var recordedRequest = new HttpRequest
            {
                Uri     = "https://example.com",
                Method  = "GET",
                Headers = recordedHeaders
            };
            var request = new HttpRequest
            {
                Uri     = "https://example.com",
                Method  = "GET",
                Headers = headers
            };

            //act
            var result = matcher.FindMatch(new[] { new HttpInteraction {
                                                       Request = recordedRequest
                                                   } }, request);

            //assert
            Assert.Equal(found, result != null);
        }
예제 #3
0
        public void IgnoreHeaders()
        {
            //arrange
            var matcher = new DefaultRequestMatcher {
                CompareHeaders = true
            };

            matcher.IgnoreHeaders.Add("Authorization");

            var recordedRequest = new HttpRequest
            {
                Uri     = "https://example.com",
                Method  = "GET",
                Headers = new Dictionary <string, List <string> > {
                    ["Authorization"] = new List <string> {
                        "Bearer Token1"
                    },
                    ["Accept"] = new List <string> {
                        "text/plain"
                    }
                }
            };
            var request = new HttpRequest
            {
                Uri     = "https://example.com",
                Method  = "GET",
                Headers = new Dictionary <string, List <string> >
                {
                    ["Authorization"] = new List <string> {
                        "Bearer Token2"
                    },
                    ["Accept"] = new List <string> {
                        "text/plain"
                    }
                }
            };

            //act
            var result = matcher.FindMatch(new[] { new HttpInteraction {
                                                       Request = recordedRequest
                                                   } }, request);

            //assert
            Assert.NotNull(result);
        }
예제 #4
0
        public void CompareHttpMethod(string recordedMethod, string method, bool found)
        {
            //arrange
            var matcher         = new DefaultRequestMatcher();
            var recordedRequest = new HttpRequest {
                Uri = "https://example.com", Method = recordedMethod
            };
            var request = new HttpRequest {
                Uri = "https://example.com", Method = method
            };

            //act
            var result = matcher.FindMatch(new[] { new HttpInteraction {
                                                       Request = recordedRequest
                                                   } }, request);

            //assert
            Assert.Equal(found, result != null);
        }
예제 #5
0
        public void CompareUri(string recordedUri, string uri, bool found)
        {
            //arrange
            var matcher         = new DefaultRequestMatcher();
            var recordedRequest = new HttpRequest {
                Uri = recordedUri
            };
            var request = new HttpRequest {
                Uri = uri
            };

            //act
            var result = matcher.FindMatch(new[] { new HttpInteraction {
                                                       Request = recordedRequest
                                                   } }, request);

            //assert
            Assert.Equal(found, result != null);
        }