示例#1
0
        public void GivenPath_RootSegmentsContainFirstPartOfPath()
        {
            var routes = new List <RequestBuilder>
            {
                new RequestBuilder(HttpMethod.Get, "/api/foo/bar", null)
            };

            var dictionary = RouteDictionary.From(routes);

            dictionary
            .RootSegments
            .Should()
            .ContainKey("api");
        }
示例#2
0
        public void GivenPathForSingleDocumentAtRoot_RootSegmentContainsRequestBuilder()
        {
            var requestBuilder = new RequestBuilder(HttpMethod.Post, "/index.php", null);

            var routes = new List <RequestBuilder>
            {
                requestBuilder
            };

            var dictionary = RouteDictionary.From(routes);

            dictionary
            .RootSegments["index.php"]
            .RequestBuilders[HttpMethod.Post]
            .Should()
            .Be(requestBuilder);
        }
示例#3
0
        public void GivenRouteWithParameterAndQueryStringWithoutSeparatorX_RequestBuilderIsReturned()
        {
            var routes = new List <RequestBuilder>
            {
                new RequestBuilder(HttpMethod.Get, "/api/foos/{id}?blah=baz", null),
                new RequestBuilder(HttpMethod.Get, "/api/foos/{id}?blah=qux", null)
            };

            var dictionary = RouteDictionary.From(routes);

            dictionary
            .Match(
                HttpMethod.Get,
                "/api/foos/1234?blah=qux")
            .Should()
            .Be(routes[1]);
        }
示例#4
0
        public void GivenRouteWithParameterAndQueryString_RequestBuilderIsReturned()
        {
            var requestBuilder = new RequestBuilder(HttpMethod.Get, "/api/foos/{id}/?blah=baz", null);

            var routes = new List <RequestBuilder>
            {
                requestBuilder
            };

            var dictionary = RouteDictionary.From(routes);

            dictionary
            .Match(
                HttpMethod.Get,
                "/api/foos/1234/?blah=baz")
            .Should()
            .Be(requestBuilder);
        }
示例#5
0
        public void GivenNonConfigured_NoResultIsReturned()
        {
            var requestBuilder = new RequestBuilder(HttpMethod.Get, "/api/foo/bar?blah=blurb", null);

            var routes = new List <RequestBuilder>
            {
                requestBuilder
            };

            var dictionary = RouteDictionary.From(routes);

            dictionary
            .Match(
                HttpMethod.Get,
                "/api/baz")
            .Should()
            .BeNull();
        }
示例#6
0
        public void GivenPathWithQueryParameters_ReturnedRequestBuilderMatches()
        {
            var requestBuilder = new RequestBuilder(HttpMethod.Get, "/api/foo/bar?blah=blurb", null);

            var routes = new List <RequestBuilder>
            {
                requestBuilder
            };

            var dictionary = RouteDictionary.From(routes);

            dictionary
            .Match(
                HttpMethod.Get,
                "/api/foo/bar?blah=blurb")
            .Should()
            .Be(requestBuilder);
        }
示例#7
0
        public void GivenPathWithQueryParameters_TailSegmentContainsRequestBuilder()
        {
            var requestBuilder = new RequestBuilder(HttpMethod.Get, "/api/foo/bar?blah=blurb", null);

            var routes = new List <RequestBuilder>
            {
                requestBuilder
            };

            var dictionary = RouteDictionary.From(routes);

            dictionary
            .RootSegments["api"]
            .Segments["foo"]
            .Segments["bar?blah=blurb"]
            .RequestBuilders[HttpMethod.Get]
            .Should()
            .Be(requestBuilder);
        }