public async Task ConnectionCanReadAndWrite() { var engine = new KestrelEngine(LibraryManager, new ShutdownNotImplemented()); engine.Start(1); var started = engine.CreateServer("http", "localhost", 54321, App); Console.WriteLine("Started"); var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(new IPEndPoint(IPAddress.Loopback, 54321)); socket.Send(Encoding.ASCII.GetBytes("POST / HTTP/1.0\r\n\r\nHello World")); socket.Shutdown(SocketShutdown.Send); var buffer = new byte[8192]; for (; ;) { var length = socket.Receive(buffer); if (length == 0) { break; } var text = Encoding.ASCII.GetString(buffer, 0, length); } started.Dispose(); engine.Dispose(); }
public async Task EngineCanStartAndStop() { var engine = new KestrelEngine(LibraryManager, new ShutdownNotImplemented()); engine.Start(1); engine.Dispose(); }
public void EngineCanStartAndStop(ServiceContext testContext) { var engine = new KestrelEngine(testContext); engine.Start(1); engine.Dispose(); }
public async Task EngineCanStartAndStop() { var engine = new KestrelEngine(LibraryManager); engine.Start(1); engine.Dispose(); }
public void ConnectionCanReadAndWrite(TestServiceContext testContext) { var port = TestServer.GetNextPort(); testContext.App = App; var engine = new KestrelEngine(testContext); engine.Start(1); var address = ServerAddress.FromUrl($"http://localhost:{port}/"); var started = engine.CreateServer(address); var socket = TestConnection.CreateConnectedLoopbackSocket(port); socket.Send(Encoding.ASCII.GetBytes("POST / HTTP/1.0\r\n\r\nHello World")); socket.Shutdown(SocketShutdown.Send); var buffer = new byte[8192]; while (true) { var length = socket.Receive(buffer); if (length == 0) { break; } var text = Encoding.ASCII.GetString(buffer, 0, length); } started.Dispose(); engine.Dispose(); }
public void ConnectionCanReadAndWrite(TestServiceContext testContext) { testContext.App = App; var engine = new KestrelEngine(testContext); engine.Start(1); var address = ServerAddress.FromUrl("http://localhost:54321/"); var started = engine.CreateServer(address); Console.WriteLine("Started"); var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(new IPEndPoint(IPAddress.Loopback, 54321)); socket.Send(Encoding.ASCII.GetBytes("POST / HTTP/1.0\r\n\r\nHello World")); socket.Shutdown(SocketShutdown.Send); var buffer = new byte[8192]; while (true) { var length = socket.Receive(buffer); if (length == 0) { break; } var text = Encoding.ASCII.GetString(buffer, 0, length); } started.Dispose(); engine.Dispose(); }
public void EngineCanStartAndStop() { var engine = new KestrelEngine(LibraryManager, new TestServiceContext()); engine.Start(1); engine.Dispose(); }
public async Task ListenerCanCreateAndDispose() { var engine = new KestrelEngine(LibraryManager, new ShutdownNotImplemented()); engine.Start(1); var started = engine.CreateServer("http", "localhost", 54321, App); started.Dispose(); engine.Dispose(); }
public void ListenerCanCreateAndDispose() { var engine = new KestrelEngine(LibraryManager, new TestServiceContext()); engine.Start(1); var started = engine.CreateServer("http", "localhost", 54321, App); started.Dispose(); engine.Dispose(); }
public void ListenerCanCreateAndDispose(ServiceContext testContext) { var engine = new KestrelEngine(testContext); engine.Start(1); var address = ServerAddress.FromUrl("http://localhost:54321/"); var started = engine.CreateServer(address, App); started.Dispose(); engine.Dispose(); }
public void ListenerCanCreateAndDispose(TestServiceContext testContext) { testContext.App = App; var engine = new KestrelEngine(testContext); engine.Start(1); var address = ServerAddress.FromUrl($"http://localhost:{TestServer.GetNextPort()}/"); var started = engine.CreateServer(address); started.Dispose(); engine.Dispose(); }
public void ListenerCanCreateAndDispose(TestServiceContext testContext) { testContext.App = App; var engine = new KestrelEngine(testContext); engine.Start(1); var address = ServerAddress.FromUrl("http://127.0.0.1:0/"); var started = engine.CreateServer(address); started.Dispose(); engine.Dispose(); }
public TestServer(RequestDelegate app, ServiceContext context, string serverAddress) { context.FrameFactory = connectionContext => { return(new Frame <HttpContext>(new DummyApplication(app), connectionContext)); }; try { _engine = new KestrelEngine(context); _engine.Start(1); _address = ServerAddress.FromUrl(serverAddress); _server = _engine.CreateServer(_address); } catch { _server?.Dispose(); _engine?.Dispose(); throw; } }
public void Dispose() { _server.Dispose(); _engine.Dispose(); }