Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handling template parse failure #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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