Skip to content

Query string requests don't seem to be matched #25

@jertje260

Description

@jertje260

Requests with querystrings don't seem to be matched properly.

Created a repro test case, which fails:

        [Fact]
        public void GivenRouteWithParameterAndQueryStringUsingTheBuilder_RequestBuilderIsReturned()
        {
            var requestBuilder = (RequestBuilder)new RequestBuilder().Get().ForUrl("/api/foos/{id}").WithQueryStringParameter("blah").HavingAnyValue();

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

            var dictionary = ConfiguredRequests.FromRequestBuilders(routes);

            dictionary
                .Match(
                    HttpMethod.Get,
                    "/api/foos/1234?blah=baz",
                    null)
                .Should()
                .Be(requestBuilder);
        }

I don't have a fix for this yet, but working on it.

Looks like it fails in the matching, because the query string like this is not added to the _queryParameters in the RequestQueryNode. Therefore the count matching fails, therefore doesn't return it.

When using the old api for the builder, it does work, so using:

_testableMessageHandler.RespondTo(HttpMethod.Get, "/api/foos/{id}").WithQueryStringParameter("blah").HavingAnyValue()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions