public void TestSetLength() { using (SegmentedMemoryStream ms = new SegmentedMemoryStream()) { Assert.AreEqual(0L, ms.Length); Assert.AreEqual(0L, ms.Position); ms.SetLength(10); Assert.AreEqual(0L, ms.Position); Assert.AreEqual(10L, ms.Length); Assert.AreEqual(10L, ms.Seek(0, System.IO.SeekOrigin.End)); ms.SetLength(100); Assert.AreEqual(10L, ms.Position); Assert.AreEqual(100L, ms.Length); Assert.AreEqual(100L, ms.Seek(0, System.IO.SeekOrigin.End)); ms.SetLength(1); Assert.AreEqual(100L, ms.Position); Assert.AreEqual(1L, ms.Length); Assert.AreEqual(1L, ms.Seek(0, System.IO.SeekOrigin.End)); } }
public void TestSeek() { using (SegmentedMemoryStream ms = new SegmentedMemoryStream()) { Assert.AreEqual(0L, ms.Length); Assert.AreEqual(0L, ms.Position); Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin)); Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current)); Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.End)); ms.Position = 42L; Assert.AreEqual(42L, ms.Length); Assert.AreEqual(42L, ms.Position); Assert.AreEqual(42L, ms.Seek(42, System.IO.SeekOrigin.Begin)); Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.Current)); Assert.AreEqual(42L, ms.Seek(0, System.IO.SeekOrigin.End)); ms.Position = 0; Assert.AreEqual(0L, ms.Position); Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Begin)); Assert.AreEqual(0L, ms.Seek(0, System.IO.SeekOrigin.Current)); Assert.AreEqual(0L, ms.Seek(-42, System.IO.SeekOrigin.End)); } }