public void TestIsMatchWithContentPattern(bool isMatchResult) { var contnetPatternMock = NewMock <IHttpRequestContentPattern>(); const string method = "post"; const string path = "/"; var contentBytes = new byte[0]; const string contentType = "application/json"; contnetPatternMock.Setup(x => x.IsMatch(contentBytes, contentType)).Returns(isMatchResult); var httpRequestMock = new HttpRequestMock { Method = MethodPattern.Standart(method), Path = PathPattern.Smart(path), Content = contnetPatternMock.Object, Query = QueryPattern.Any(), Headers = HeadersPattern.Any() }; var httpRequestPattern = new HttpRequestPattern(httpRequestMock); var httpRequestInfo = new HttpRequest { Method = method, Path = path, ContentBytes = contentBytes, ContentType = contentType }; httpRequestPattern.IsMatch(httpRequestInfo).ShouldBeEquivalentTo(isMatchResult); }
internal HttpRequestMockBuilder() { httpRequestMock = new HttpRequestMock { Method = MethodPattern.Any(), Path = PathPattern.Any(), Query = QueryPattern.Any(), Content = ContentPattern.Any(), Headers = HeadersPattern.Any() }; httpResponseMockBuilder = new HttpResponseMockBuilder(200); }
private static HttpRequestMock CreateMock(string method) { return(new HttpRequestMock { Method = MethodPattern.Standart(method), Path = PathPattern.Smart("/"), Query = QueryPattern.Any(), Content = ContentPattern.Any(), Headers = HeadersPattern.Any(), Response = new HttpResponseMock { RepeatCount = 1 } }); }
public void TestIsMatch(string method, string expectedMethod, bool expected) { const string pathPattern = "/"; var httpRequestMock = new HttpRequestMock { Method = MethodPattern.Standart(method), Path = PathPattern.Smart(pathPattern), Query = QueryPattern.Any(), Headers = HeadersPattern.Any(), Content = ContentPattern.Any() }; var httpRequestPattern = new HttpRequestPattern(httpRequestMock); var httpRequestInfo = new HttpRequest { Method = expectedMethod, Path = pathPattern }; httpRequestPattern.IsMatch(httpRequestInfo).ShouldBeEquivalentTo(expected); }