public void EmptyMemoryStream_CanBeReused()
        {
            using (var reader = new StreamReader(EmptyMemoryStream.Get()))
            {
                reader.ReadToEnd();
            }

            using (var reader = new StreamReader(EmptyMemoryStream.Get()))
            {
                reader.ReadToEnd();
            }
        }
        public static MemoryStream Serialize(Dictionary <string, string> headers)
        {
            Require.NotNull(headers, "headers");

            if (headers.Count == 0)
            {
                return(EmptyMemoryStream.Get());
            }

            using (var stream = new MemoryStream())
                using (var writer = new StreamWriter(stream))
                {
                    foreach (var eventHeader in headers)
                    {
                        writer.WriteLine("{0}: {1}", eventHeader.Key, eventHeader.Value);
                    }

                    writer.Flush();

                    return(new MemoryStream(stream.GetBuffer(), 0, (int)stream.Length, false));
                }
        }
 public void EmptyMemoryStream_NoWritable()
 {
     Assert.False(EmptyMemoryStream.Get().CanWrite);
 }