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:
2023-07-09 11:14:33 -07:00
parent 8c44d56ab4
commit 69a1d9c3a8
6 changed files with 66 additions and 16 deletions

View File

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