Ejemplo n.º 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");
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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]);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }