Skip to content

Commit 1b7edc9

Browse files
Coverage for controllers
1 parent 3db6870 commit 1b7edc9

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.Net;
2+
using GenHTTP.Api.Protocol;
3+
using GenHTTP.Modules.Controllers;
4+
using GenHTTP.Modules.Layouting;
5+
using GenHTTP.Testing.Acceptance.Utilities;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
8+
namespace GenHTTP.Testing.Acceptance.Modules.Controllers;
9+
10+
[TestClass]
11+
public class IntegrationTests
12+
{
13+
14+
#region Supporting data structures
15+
16+
public class TestController
17+
{
18+
19+
[ControllerAction(RequestMethod.Get)]
20+
public string DoWork() => "Work done";
21+
22+
}
23+
24+
#endregion
25+
26+
[TestMethod]
27+
[MultiEngineTest]
28+
public async Task TestInstance(TestEngine engine)
29+
{
30+
var app = Layout.Create()
31+
.Add(Controller.From(new TestController()));
32+
33+
await using var host = await TestHost.RunAsync(app, engine: engine);
34+
35+
using var response = await host.GetResponseAsync("/do-work/");
36+
37+
await response.AssertStatusAsync(HttpStatusCode.OK);
38+
39+
Assert.AreEqual("Work done", await response.GetContentAsync());
40+
}
41+
42+
[TestMethod]
43+
public void TestChaining()
44+
{
45+
Chain.Works(Controller.From<TestController>());
46+
}
47+
48+
}

0 commit comments

Comments
 (0)