public void TestIsDispose() { Stream s = new ClampedStream(new MemoryStream(), 0, long.MaxValue, false); s.Dispose(); s.Seek(0, SeekOrigin.Begin); Assert.Fail(); }
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(); }
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); } }
public void TestInvalidSeekPastEnd() { using (Stream s = new ClampedStream(new MemoryStream(new byte[255]), 2, 10)) s.Seek(1, SeekOrigin.End); Assert.Fail(); }
public void TestInvalidSeekBeforeBegin() { using (Stream s = new ClampedStream(new MemoryStream(new byte[255]), 2, 10)) s.Seek(-1, SeekOrigin.Begin); Assert.Fail(); }