Skip to content

Commit

Permalink
Add test szenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaliumhexacyanoferrat committed Jan 10, 2024
1 parent 7363c49 commit c8062f7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
12 changes: 12 additions & 0 deletions Modules/Reflection/FromBodyAttribute.cs
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
{

}

}
6 changes: 2 additions & 4 deletions Testing/Acceptance/Modules/Controllers/ActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Net;
using System.IO;
using System.Net.Http.Headers;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand All @@ -12,8 +12,6 @@
using GenHTTP.Modules.Controllers;
using GenHTTP.Modules.IO;
using GenHTTP.Modules.Layouting;
using System.Collections.Generic;
using System.Net.Http.Headers;

namespace GenHTTP.Testing.Acceptance.Modules.Controllers
{
Expand Down
40 changes: 40 additions & 0 deletions Testing/Acceptance/Modules/Reflection/ParameterTests.cs
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

}

}

0 comments on commit c8062f7

Please sign in to comment.