public void ListensToAnyPath() { var port = new AwaitedPort(new TestPort()).Value(); var clients = new AspNetCoreClients(); var requests = 0; using (var server = new HttpMock(port, new FkWire(req => { requests++; return(new Response.Of(200, "OK")); }) ).Value() ) { Task.WaitAll( new AspNetCoreWire(clients, new TimeSpan(0, 1, 0)).Response( new Get($"http://localhost:{port}") ), new AspNetCoreWire(clients, new TimeSpan(0, 1, 0)).Response( new Get($"http://localhost:{port}/path") ), new AspNetCoreWire(clients, new TimeSpan(0, 1, 0)).Response( new Get($"http://localhost:{port}/another/path") ) ); } Assert.Equal( 3, requests ); }
public void RoutesToPath() { var port = new AwaitedPort(new TestPort()).Value(); var clients = new AspNetCoreClients(); var result = 0; using (var server = new HttpMock(port, new KvpOf <IWire>("", new FkWire(req => { result += 1; return(new Response.Of(200, "OK")); }) ), new KvpOf <IWire>("path", new FkWire(req => { result += 2; return(new Response.Of(200, "OK")); }) ), new KvpOf <IWire>("another/path", new FkWire(req => { result += 4; return(new Response.Of(200, "OK")); }) ) ).Value() ) { Task.WaitAll( new AspNetCoreWire(clients, new TimeSpan(0, 1, 0)).Response( new Get($"http://localhost:{port}") ), new AspNetCoreWire(clients, new TimeSpan(0, 1, 0)).Response( new Get($"http://localhost:{port}/path") ), new AspNetCoreWire(clients, new TimeSpan(0, 1, 0)).Response( new Get($"http://localhost:{port}/another/path") ) ); } Assert.Equal( 7, result ); }
public void ReusesClients() { var clients = new AspNetCoreClients(); var first = clients.Client( new TimeSpan(0, 1, 0) ); first.BaseAddress = new Uri("http://localhost/this/is/a/test"); var second = clients.Client( new TimeSpan(0, 1, 0) // same timeout should return same client ); Assert.Equal( first.BaseAddress, second.BaseAddress ); }
public void ReturnsDifferentClients() { var clients = new AspNetCoreClients(); var first = clients.Client( new TimeSpan(0, 1, 1) ); first.BaseAddress = new Uri("http://localhost/this/is/a/test"); var second = clients.Client( new TimeSpan(0, 2, 1) // different timeout should return new client ); Assert.NotEqual( first.BaseAddress, second.BaseAddress ); }