Last active
August 5, 2020 00:07
-
-
Save bronumski/730a129c64c4b603aa33698b1031ae3b to your computer and use it in GitHub Desktop.
TestServer
This file contains hidden or 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
private TestServer CreateTestServer() => | |
new TestServer(new WebHostBuilder() | |
.UseStartup<FakeStartup>()); | |
class FakeStartup | |
{ | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
app.Run(async ctx => | |
{ | |
if (ctx.Request.Path.Value.StartsWith("/expected")) | |
await ctx.Response.WriteAsync("Hello World"); | |
else | |
ctx.Response.StatusCode = StatusCodes.Status404NotFound; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment