Example #1
0
        public void TestIsDispose()
        {
            Stream s = new ClampedStream(new MemoryStream(), 0, long.MaxValue, false);

            s.Dispose();
            s.Seek(0, SeekOrigin.Begin);
            Assert.Fail();
        }
Example #2
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();
 }
Example #3
0
        public void TestSeek()
        {
            MemoryStream ms = new MemoryStream(SequencedBytes(100));

            using (Stream s = new ClampedStream(ms, 10, 80))
            {
                Assert.AreEqual(0, s.Seek(0, SeekOrigin.Begin));
                Assert.AreEqual(0, s.Position);
                Assert.AreEqual(10, s.Seek(10, SeekOrigin.Begin));
                Assert.AreEqual(10, s.Position);
                Assert.AreEqual(20, s.Seek(10, SeekOrigin.Current));
                Assert.AreEqual(20, s.Position);
                Assert.AreEqual(15, s.Seek(-5, SeekOrigin.Current));
                Assert.AreEqual(15, s.Position);
                Assert.AreEqual(70, s.Seek(-10, SeekOrigin.End));
                Assert.AreEqual(70, s.Position);
                Assert.AreEqual(80, s.Seek(0, SeekOrigin.End));
                Assert.AreEqual(80, s.Position);
            }
        }
Example #4
0
 public void TestInvalidSeekPastEnd()
 {
     using (Stream s = new ClampedStream(new MemoryStream(new byte[255]), 2, 10))
         s.Seek(1, SeekOrigin.End);
     Assert.Fail();
 }
Example #5
0
 public void TestInvalidSeekBeforeBegin()
 {
     using (Stream s = new ClampedStream(new MemoryStream(new byte[255]), 2, 10))
         s.Seek(-1, SeekOrigin.Begin);
     Assert.Fail();
 }