-
-
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.
Allow to pass serialization and injection factories for web services
- Loading branch information
1 parent
f336b9c
commit 59315c3
Showing
2 changed files
with
86 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
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.Modules.Conversion; | ||
using GenHTTP.Modules.Layouting; | ||
using GenHTTP.Modules.Reflection; | ||
using GenHTTP.Modules.Webservices; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace GenHTTP.Testing.Acceptance.Modules.Webservices | ||
{ | ||
|
||
[TestClass] | ||
public sealed class ExtensionTests | ||
{ | ||
|
||
#region Supporting data structures | ||
|
||
public class TestService | ||
{ | ||
|
||
[ResourceMethod] | ||
public int DoWork() => 42; | ||
|
||
} | ||
|
||
#endregion | ||
|
||
#region Tests | ||
|
||
[TestMethod] | ||
public async Task TestConfiguration() | ||
{ | ||
var injectors = Injection.Default(); | ||
|
||
var formats = Serialization.Default(); | ||
|
||
var app = Layout.Create() | ||
.AddService<TestService>("by-type", injectors, formats) | ||
.AddService("by-instance", new TestService(), injectors, formats); | ||
|
||
using var host = TestHost.Run(app); | ||
|
||
using var r1 = await host.GetResponseAsync("/by-type"); | ||
|
||
await r1.AssertStatusAsync(HttpStatusCode.OK); | ||
|
||
using var r2 = await host.GetResponseAsync("/by-instance"); | ||
|
||
await r2.AssertStatusAsync(HttpStatusCode.OK); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |