-
-
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.
- Loading branch information
1 parent
7363c49
commit c8062f7
Showing
3 changed files
with
54 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace GenHTTP.Modules.Reflection | ||
{ | ||
|
||
[AttributeUsage(AttributeTargets.Parameter)] | ||
public sealed class FromBodyAttribute : Attribute | ||
{ | ||
|
||
} | ||
|
||
} |
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,40 @@ | ||
using GenHTTP.Modules.Functional; | ||
using GenHTTP.Modules.Reflection; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace GenHTTP.Testing.Acceptance.Modules.Reflection | ||
{ | ||
|
||
[TestClass] | ||
public sealed class ParameterTests | ||
{ | ||
|
||
#region Tests | ||
[TestMethod] | ||
public async Task TestCanReadSimpleTypesFromBody() | ||
{ | ||
var inline = Inline.Create() | ||
.Post(([FromBody] string body) => body); | ||
|
||
using var runner = TestHost.Run(inline); | ||
|
||
var request = runner.GetRequest(); | ||
|
||
request.Method = HttpMethod.Post; | ||
request.Content = new StringContent("my body", null, "text/plain"); | ||
|
||
using var response = await runner.GetResponseAsync(request); | ||
|
||
await response.AssertStatusAsync(HttpStatusCode.OK); | ||
|
||
Assert.AreEqual("my body", await response.GetContentAsync()); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |