Skip to content

Throw exception if route cannot be parsed#36

Open
jkone27 wants to merge 2 commits intomarkvincze:mainfrom
jkone27:throw-exception-if-route-cannot-be-parsed
Open

Throw exception if route cannot be parsed#36
jkone27 wants to merge 2 commits intomarkvincze:mainfrom
jkone27:throw-exception-if-route-cannot-be-parsed

Conversation

@jkone27
Copy link

@jkone27 jkone27 commented May 27, 2021

This throws if aspnet is unable to parse the route as a valid template,
i think this is acceptable as it signals the developer to fix the test setups.

just added a validation in the constructor here:

 public RouteCondition(string route)
        {
            this.route = route.TrimStart('/');
            TemplateParser.Parse(route);
        }

so this test can be green

        [Theory]
        [InlineData("/testget//two")]
        [InlineData(":hey/hello:8080?what")]
        public void MultipleSetups_OneHasWrongRoute_ThrowsException(string route)
        {
            using var sut = new ApiStub();

            Assert.Throws<ArgumentException>(() => sut.Get(route, 
                (req, args) => "doesn't match"));
        }

@jkone27
Copy link
Author

jkone27 commented May 28, 2021

I see this doesn't cover some cases e.g. with query parameters.. probably the regex need to be adapted to fit this scope.. maybe then the "ignore broken route" solution in the other PR for now is better as a "quick fix" while looking for a "better" solution for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant