Last active
May 3, 2018 10:14
-
-
Save bazwilliams/8696075134a967377878e93f7a27c96c to your computer and use it in GitHub Desktop.
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
namespace Integration.Tests | |
{ | |
using System; | |
using System.Net.Http; | |
using Carter; | |
using Microsoft.AspNetCore; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.TestHost; | |
using Microsoft.Extensions.DependencyInjection; | |
public static class TestClient | |
{ | |
public static HttpClient With(Action<IServiceCollection> addDependencies) | |
{ | |
var server = new TestServer( | |
WebHost.CreateDefaultBuilder() | |
.ConfigureServices( | |
services => | |
{ | |
addDependencies(services); | |
services.AddCarter(); | |
}) | |
.Configure(app => | |
{ | |
app.UseCarter(); | |
})); | |
var client = server.CreateClient(); | |
return client; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment