public override Task InitializeAsync() { var router = new RoutingMessageHandler(); _upstreamTestServer = new TestServer(UpstreamBuilder); _proxyPort = 81; var proxyBuilder = ProxyBuilder .UseSetting("port", _proxyPort.ToString()) .ConfigureTestServices(services => { services.AddProxy(c => { c.ConfigurePrimaryHttpMessageHandler(() => router); c.ConfigureHttpClient(client => client.Timeout = TimeSpan.FromSeconds(1)); }); }); _proxyTestServer = new TestServer(proxyBuilder); router.AddHandler(new Origin("localhost", _proxyPort), _upstreamTestServer.CreateHandler()); return(Task.CompletedTask); }