public void RequestStream()
        {
            using (var host = new ProtoHost<ServerService>(new IPEndPoint(IPAddress.Loopback, 0)))
            using (var client = new ClientService(host.LocalEndPoint))
            {
                var response = client.StreamRequest(new StreamRequest());

                var stream = client.EndGetStream(client.BeginGetStream((int)response.StreamId, null, null));

                using (var reader = new StreamReader(stream.Stream))
                {
                    Console.WriteLine(reader.ReadToEnd());
                }
            }
        }
        public void ExpectMemoryStream()
        {
            var configuration = new ProtoClientConfiguration
            {
                StreamManager = new HybridStreamManager(Path.GetTempPath(), 50)
            };

            using (var host = new ProtoHost<ServerService>(new IPEndPoint(IPAddress.Loopback, 0)))
            using (var client = new ClientService(host.LocalEndPoint, configuration))
            {
                var response = client.StreamRequest(new StreamRequest { Length = 10 });

                using (var stream = client.EndGetStream(client.BeginGetStream((int)response.StreamId, null, null)))
                {
                    Assert.That(stream.Stream, Is.InstanceOf<MemoryStream>());
                }
            }
        }
        public void RequestStream(StreamDisposition disposition)
        {
            using (var host = new ProtoHost<ServerService>(new IPEndPoint(IPAddress.Loopback, 0)))
            using (var client = new ClientService(host.LocalEndPoint))
            {
                var response = client.StreamRequest(new StreamRequest
                {
                    Attachment = disposition == StreamDisposition.Attachment
                });

                using (var protoStream = client.EndGetStream(client.BeginGetStream((int)response.StreamId, null, null)))
                {
                    Assert.AreEqual(protoStream.Disposition, disposition);

                    using (var stream = protoStream.DetachStream())
                    using (var reader = new StreamReader(stream))
                    {
                        Console.WriteLine(reader.ReadToEnd());
                    }
                }
            }
        }
        public void StreamTooLong()
        {
            var configuration = new ProtoClientConfiguration
            {
                StreamManager = new HybridStreamManager(Path.GetTempPath(), 50, 100)
            };

            using (var host = new ProtoHost<ServerService>(new IPEndPoint(IPAddress.Loopback, 0)))
            using (var client = new ClientService(host.LocalEndPoint, configuration))
            {
                // TODO: Communicating that the stream was rejected isn't yet
                // communicated clearly.

                var response = client.StreamRequest(new StreamRequest { Length = 200 });

                using (client.EndGetStream(client.BeginGetStream((int)response.StreamId, null, null)))
                {
                }
            }
        }