Stubbery icon indicating copy to clipboard operation
Stubbery copied to clipboard

Throw exception if route cannot be parsed

Open jkone27 opened this issue 4 years ago • 1 comments

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 avatar May 27 '21 12:05 jkone27

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

jkone27 avatar May 28 '21 07:05 jkone27