public void SetLength_SetPosition() { var stream = new MemoryStream(); using (var writer = new BitStreamWriter(stream, true)) { Assert.AreEqual(false, writer.CanRead); Assert.AreEqual(true, writer.CanWrite); Assert.AreEqual(true, writer.CanSeek); Assert.AreEqual(0, writer.Length); Assert.AreEqual(0, writer.BitLength); Assert.AreEqual(0, writer.BitPosition); Assert.AreEqual(0, writer.Position); writer.SetLength(10); writer.Write(true); writer.Position = 5; writer.Write(true); Assert.AreEqual(10, writer.Length); Assert.AreEqual(80, writer.BitLength); Assert.AreEqual(41, writer.BitPosition); Assert.AreEqual(5, writer.Position); } Assert.AreEqual(10, stream.Length); Assert.AreEqual(6, stream.Position); Assert.AreEqual(0x80, stream.GetBuffer()[0]); Assert.AreEqual(0x80, stream.GetBuffer()[5]); }