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]
|
[Fact]
|
||||||
public void SyntaxWithArgumentShouldMatch()
|
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]
|
[Fact]
|
||||||
@ -64,6 +75,18 @@ namespace MontoyaTech.Rest.Net.Tests
|
|||||||
RouteMatcher.Matches("http://localhost/1/2/3", "/1/*/3", out _).Should().BeTrue();
|
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]
|
[Fact]
|
||||||
public void SyntaxWithOrShouldMatch()
|
public void SyntaxWithOrShouldMatch()
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
||||||
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<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>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json">
|
<PackageReference Include="Newtonsoft.Json">
|
||||||
|
@ -133,7 +133,7 @@ namespace MontoyaTech.Rest.Net
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (condition == urlSegment)
|
else if (condition == urlSegment && condition != "&" && condition != "|")
|
||||||
{
|
{
|
||||||
match = true;
|
match = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user