Improved RouteMatcher and added more unit tests to cover some edge cases. Cleaned up code. Bumped package version to 1.7.0
This commit is contained in:
@ -22,6 +22,12 @@ namespace MontoyaTech.Rest.Net.Tests
|
||||
RouteMatcher.Matches("http://localhost/", "/", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxWithRootNoSlashShouldMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost", "/", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxWithRootCatchAllShouldMatch()
|
||||
{
|
||||
@ -29,9 +35,33 @@ namespace MontoyaTech.Rest.Net.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxCatchAllEmptyShouldMatch()
|
||||
public void SyntaxNonSlashShouldNotMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/test1", "/test1/**", out _).Should().BeTrue();
|
||||
RouteMatcher.Matches("http://localhost/test1/", "/test1", out _).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxSlashShouldMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/test1/", "/test1/", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxSlashExtraRouteShouldNotMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/test1/test2", "/test1/", out _).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxSlashCatchAllEmptyShouldMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/test1/", "/test1/**", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxSlashCatchAllEmptyNoSlashShouldNotMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/test1", "/test1/**", out _).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -43,7 +73,7 @@ namespace MontoyaTech.Rest.Net.Tests
|
||||
[Fact]
|
||||
public void SyntaxWildCardEmptyShouldMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/test1", "/test1/*", out _).Should().BeTrue();
|
||||
RouteMatcher.Matches("http://localhost/test1/", "/test1/*", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -117,6 +147,7 @@ namespace MontoyaTech.Rest.Net.Tests
|
||||
public void SyntaxWithOrShouldMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/a/b", "/a/b|c", out _).Should().BeTrue();
|
||||
|
||||
RouteMatcher.Matches("http://localhost/a/c", "/a/b|c", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user