-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer non-wildcard routes over wildcard ones if multiple routes match (
#491)
- Loading branch information
1 parent
206e033
commit 081797a
Showing
5 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
|
||
using GenHTTP.Api.Content; | ||
|
||
using GenHTTP.Modules.IO; | ||
using GenHTTP.Modules.Layouting; | ||
using GenHTTP.Modules.Webservices; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GenHTTP.Testing.Acceptance.Modules.Webservices | ||
{ | ||
|
||
[TestClass] | ||
public sealed class AmbiguityTests | ||
{ | ||
|
||
#region Supporting data structures | ||
|
||
public sealed class TestService | ||
{ | ||
|
||
[ResourceMethod] | ||
public IHandlerBuilder Wildcard() | ||
{ | ||
return Content.From(Resource.FromString("Wildcard")); | ||
} | ||
|
||
[ResourceMethod(path: "/my.txt")] | ||
public string Specific() => "Specific"; | ||
|
||
} | ||
|
||
#endregion | ||
|
||
#region Tests | ||
|
||
[TestMethod] | ||
public async Task TestSpecificPreferred() | ||
{ | ||
var app = Layout.Create() | ||
.AddService<TestService>("c"); | ||
|
||
using var host = TestHost.Run(app); | ||
|
||
using var response = await host.GetResponseAsync("/c/my.txt"); | ||
|
||
await response.AssertStatusAsync(HttpStatusCode.OK); | ||
|
||
Assert.AreEqual("Specific", await response.GetContentAsync()); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |