public void PositionGet_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws<NotSupportedException>(() => { var temp = stream.Position; });
     }
 }
 public void CanWrite_ReturnsTrue()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.IsTrue(stream.CanWrite);
     }
 }
 public void CanSeek_ReturnsFalse()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.IsFalse(stream.CanSeek);
     }
 }
 public void Flush_DoesNothing()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         // Just to make sure this doesn't throw an exception or anything like that.
         stream.Flush();
     }
 }
 public void Read_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws<NotSupportedException>(() => stream.Read(new byte[1], 0, 1));
     }
 }
 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);
            }
        }
 public void SetLength_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws<NotSupportedException>(() => { stream.SetLength(0); });
     }
 }
 public void Seek_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws<NotSupportedException>(() => stream.Seek(0, SeekOrigin.Begin));
     }
 }