This ignores invalid routes passed to stubs, so allows this new test to pass (before was red, as one failing parse fails all others after it)
[Fact]
public async Task MultipleSetups_OneHasWrongRoute_OthersStillMatch()
{
using var sut = new ApiStub();
sut.Get("/testget/one", (req, args) => "testresponse1");
sut.Get("/testget//two", (req, args) => "doesn't match"); /////// THIS ONE HERE would let last one fail without this fix
sut.Get("/testget/three", (req, args) => "testresponse3");
sut.Start();
var result3 = await httpClient.GetAsync(new UriBuilder(new Uri(sut.Address))
{
Path = "/testget/three"
}.Uri);
Assert.Equal(HttpStatusCode.OK, result3.StatusCode);
var resultString = await result3.Content.ReadAsStringAsync();
Assert.Equal("testresponse3", resultString);
}
a future improvement could be to add validation at route condition setup,
so that a validation exception is thrown there...
but this require some other changes here and there i suppose
public RouteCondition(string route)
{
this.route = route.TrimStart('/');
}
This ignores invalid routes passed to stubs, so allows this new test to pass (before was red, as one failing parse fails all others after it)
a future improvement could be to add validation at route condition setup, so that a validation exception is thrown there...
but this require some other changes here and there i suppose