Skip to content

Instantly share code, notes, and snippets.

@bronumski
Last active August 5, 2020 00:07
Show Gist options
  • Save bronumski/730a129c64c4b603aa33698b1031ae3b to your computer and use it in GitHub Desktop.
Save bronumski/730a129c64c4b603aa33698b1031ae3b to your computer and use it in GitHub Desktop.
TestServer
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