public void Close_DisconnectsStreamAsync() { var pipeName = Guid.NewGuid().ToString(); var readStream = new NamedPipeServerStream(pipeName, PipeDirection.In, NamedPipeServerStream.MaxAllowedServerInstances, PipeTransmissionMode.Byte, PipeOptions.WriteThrough | PipeOptions.Asynchronous); var writeStream = new NamedPipeClientStream(".", pipeName, PipeDirection.Out, PipeOptions.WriteThrough | PipeOptions.Asynchronous); new StreamingRequestHandler(new Microsoft.Bot.Streaming.UnitTests.Mocks.MockBot(), new BotFrameworkHttpAdapter(), pipeName); var reader = new NamedPipeClient(pipeName); var writer = new NamedPipeServer(pipeName, new StreamingRequestHandler(new MockBot(), new BotFrameworkHttpAdapter(), pipeName)); try { reader.ConnectAsync(); writer.StartAsync(); readStream.WaitForConnectionAsync().ConfigureAwait(false); writeStream.ConnectAsync(500).ConfigureAwait(false); writer.Disconnect(); reader.Disconnect(); } finally { readStream.Dispose(); writeStream.Dispose(); } Assert.False(reader.IsConnected); }