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);
        }
        public override void SetUp()
        {
            base.SetUp();

            httpRequestMockBuilder = new HttpRequestMockBuilder();
            httpRequestMockBuilder.Method(MethodPattern.Standart("GET"));
            httpRequestMockBuilder.Path(PathPattern.Smart("/"));
        }
Exemple #3
0
 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);
        }
Exemple #5
0
 private IHttpRequestPathPattern Convert(string path)
 {
     return(path == null
         ? PathPattern.Any() as IHttpRequestPathPattern
         : PathPattern.Smart(path));
 }
 public static IHttpRequestMock WhenRequestPost(this IHttpMock httpMock, string path)
 {
     return(httpMock.WhenRequestPost(PathPattern.Smart(path)));
 }
 public static IHttpRequestMock Path(this IHttpRequestMock httpRequestMock, string path)
 {
     return(httpRequestMock.Path(PathPattern.Smart(path)));
 }