Skip to content

handling template parse failure#35

Open
jkone27 wants to merge 1 commit intomarkvincze:mainfrom
jkone27:fix-template-parse-failure-ignore
Open

handling template parse failure#35
jkone27 wants to merge 1 commit intomarkvincze:mainfrom
jkone27:fix-template-parse-failure-ignore

Conversation

@jkone27
Copy link

@jkone27 jkone27 commented May 27, 2021

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('/');
        }

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