예제 #1
0
 public void Seek_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws <NotSupportedException>(() => stream.Seek(0, SeekOrigin.Begin));
     }
 }
예제 #2
0
 public void Read_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws <NotSupportedException>(() => stream.Read(new byte[1], 0, 1));
     }
 }
예제 #3
0
 public void CanSeek_ReturnsFalse()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.IsFalse(stream.CanSeek);
     }
 }
예제 #4
0
        public void DisposeThenWrite_ThrowsObjectDisposedException()
        {
            var stream = new TransientMemoryWriteStream();

            stream.Dispose();
            Assert.Throws <ObjectDisposedException>(() => stream.Write(new byte[1], 0, 1));
        }
예제 #5
0
 public void CanWrite_ReturnsTrue()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.IsTrue(stream.CanWrite);
     }
 }
예제 #6
0
 public void SetLength_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws <NotSupportedException>(() => { stream.SetLength(0); });
     }
 }
예제 #7
0
 public void LengthnGet_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws <NotSupportedException>(() => { var temp = stream.Length; });
     }
 }
예제 #8
0
 public void PositionSet_ThrowsNotSupportedException()
 {
     using (var stream = new TransientMemoryWriteStream())
     {
         Assert.Throws <NotSupportedException>(() => { stream.Position = 0; });
     }
 }
예제 #9
0
 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();
     }
 }
예제 #10
0
        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);
            }
        }