public void DisposeThenWrite_ThrowsObjectDisposedException()
 {
     var stream = new TransientMemoryWriteStream();
     stream.Dispose();
     Assert.Throws<ObjectDisposedException>(() => stream.Write(new byte[1], 0, 1));
 }
        public void Write_ToArrayAndClear()
        {
            var buffer = new byte[] { 1, 2, 3 };
            using (var stream = new TransientMemoryWriteStream())
            {
                stream.Write(buffer, offset: 0, count: buffer.Length);

                var actual1 = stream.ToArrayAndClear();
                CollectionAssert.AreEqual(buffer, actual1);

                var actual2 = stream.ToArrayAndClear();
                Assert.AreEqual(0, actual2.Length);
            }
        }