Пример #1
0
 public void TestWritePastEndByte()
 {
     using (Stream s = new ClampedStream(new MemoryStream(new byte[255]), 2, 10))
     {
         s.Seek(0, SeekOrigin.End);
         s.WriteByte(1);
     }
     Assert.Fail();
 }
Пример #2
0
        public void TestClampedFlush()
        {
            MemoryStream   ms = new MemoryStream();
            BufferedStream bs = new BufferedStream(ms, 1024);

            using (Stream s = new ClampedStream(bs, 0, long.MaxValue, false))
            {
                s.WriteByte(1);
                Assert.AreEqual(0, ms.Position);
                s.Flush();
                Assert.AreEqual(1, ms.Position);
                ms.Position = 0;
                Assert.AreEqual(1, ms.ReadByte());
            }
        }