changes to add new feature to url routing (#186)

This commit is contained in:
Tom Pallister
2018-01-02 18:49:22 +00:00
committed by GitHub
parent f082f7318a
commit 931a115ffa
4 changed files with 106 additions and 3 deletions

View File

@ -121,6 +121,35 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_create_template_pattern_that_matches_to_end_of_string_when_slash_and_placeholder()
{
var fileReRoute = new FileReRoute
{
UpstreamPathTemplate = "/{url}"
};
this.Given(x => x.GivenTheFollowingFileReRoute(fileReRoute))
.When(x => x.WhenICreateTheTemplatePattern())
.Then(x => x.ThenTheFollowingIsReturned("^/.*"))
.BDDfy();
}
[Fact]
public void should_create_template_pattern_that_starts_with_placeholder_then_has_another_later()
{
var fileReRoute = new FileReRoute
{
UpstreamPathTemplate = "/{productId}/products/variants/{variantId}/",
ReRouteIsCaseSensitive = true
};
this.Given(x => x.GivenTheFollowingFileReRoute(fileReRoute))
.When(x => x.WhenICreateTheTemplatePattern())
.Then(x => x.ThenTheFollowingIsReturned("^/[0-9a-zA-Z].*/products/variants/[0-9a-zA-Z].*(/|)$"))
.BDDfy();
}
private void GivenTheFollowingFileReRoute(FileReRoute fileReRoute)
{
_fileReRoute = fileReRoute;