Stubbery
Stubbery copied to clipboard
Throw exception if route cannot be parsed
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"));
}
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