Skip to content

Instantly share code, notes, and snippets.

@bazwilliams
Last active May 3, 2018 10:14
Show Gist options
  • Save bazwilliams/8696075134a967377878e93f7a27c96c to your computer and use it in GitHub Desktop.
Save bazwilliams/8696075134a967377878e93f7a27c96c to your computer and use it in GitHub Desktop.
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