예제 #1
0
        public void Seek()
        {
            using (RebasedStream stream = CreateRebasedStream(5))
            {
                Assert.AreEqual(0, stream.Seek(0, SeekOrigin.Begin));
                Assert.AreEqual(0, stream.Position);
                Assert.AreEqual(5, m_stream.Position);

                Assert.AreEqual(2, stream.Seek(2, SeekOrigin.Begin));
                Assert.AreEqual(2, stream.Position);
                Assert.AreEqual(7, m_stream.Position);

                Assert.AreEqual(4, stream.Seek(2, SeekOrigin.Current));
                Assert.AreEqual(4, stream.Position);
                Assert.AreEqual(9, m_stream.Position);

                Assert.AreEqual(6, stream.Seek(-1, SeekOrigin.End));
                Assert.AreEqual(6, stream.Position);
                Assert.AreEqual(11, m_stream.Position);
            }
        }
예제 #2
0
 public void Dispose()
 {
     using (RebasedStream stream = CreateRebasedStream(3))
     {
         stream.Dispose();
         Assert.Throws <ObjectDisposedException>(() => { long p = stream.Position; });
         Assert.Throws <ObjectDisposedException>(() => stream.Position = 3);
         Assert.Throws <ObjectDisposedException>(() => { long p = stream.Length; });
         Assert.Throws <ObjectDisposedException>(() => stream.SetLength(20));
         Assert.Throws <ObjectDisposedException>(() => stream.Seek(0, SeekOrigin.Begin));
     }
 }