Added more unit tests for the route matcher. Published 1.0.9 nuget package.
This commit is contained in:
parent
da8184f152
commit
836aea0da7
@ -55,7 +55,18 @@ namespace MontoyaTech.Rest.Net.Tests
|
||||
[Fact]
|
||||
public void SyntaxWithArgumentShouldMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/test1", "/{a}", out _).Should().BeTrue();
|
||||
RouteMatcher.Matches("http://localhost/test1", "/{a}", out string[] arguments).Should().BeTrue();
|
||||
arguments.Length.Should().Be(1);
|
||||
arguments[0].Should().Be("test1");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxWithArgumentsShouldMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/a/1/2/d", "/a/{b}/{c}/d", out string[] arguments).Should().BeTrue();
|
||||
arguments.Length.Should().Be(2);
|
||||
arguments[0].Should().Be("1");
|
||||
arguments[1].Should().Be("2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -64,6 +75,18 @@ namespace MontoyaTech.Rest.Net.Tests
|
||||
RouteMatcher.Matches("http://localhost/1/2/3", "/1/*/3", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxWithWildcardShouldNotMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/1/2/3", "/1/*", out _).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxWithCatchallShouldMatch()
|
||||
{
|
||||
RouteMatcher.Matches("http://localhost/1/2/3", "/1/**", out _).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SyntaxWithOrShouldMatch()
|
||||
{
|
||||
|
@ -14,7 +14,8 @@
|
||||
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
||||
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<Version>1.0.8</Version>
|
||||
<Version>1.0.9</Version>
|
||||
<PackageReleaseNotes>Optimized and fixed bugs within the route matcher. Changed argument matching to support segments after the argument for more complex routes.</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json">
|
||||
|
@ -133,7 +133,7 @@ namespace MontoyaTech.Rest.Net
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (condition == urlSegment)
|
||||
else if (condition == urlSegment && condition != "&" && condition != "|")
|
||||
{
|
||||
match = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user