public void TestSetLength()
        {
            using (var memory = new MemoryStream()) {
                var buffer = Encoding.ASCII.GetBytes("This is some text...");

                memory.Write(buffer, 0, buffer.Length);

                using (var bounded = new BoundStream(memory, 0, -1, true)) {
                    var buf = new byte[1024];

                    Assert.AreEqual(buffer.Length, bounded.Length);

                    bounded.Read(buf, 0, buf.Length);                      // read the text
                    bounded.Read(buf, 0, buf.Length);                      // cause eos to be true

                    Assert.AreEqual(buffer.Length, bounded.Length);

                    bounded.SetLength(500);

                    Assert.AreEqual(500, bounded.Length);
                    Assert.AreEqual(500, memory.Length);
                }
            }

            using (var memory = new MemoryStream()) {
                var buffer = Encoding.ASCII.GetBytes("This is some text...");

                memory.Write(buffer, 0, buffer.Length);

                using (var bounded = new BoundStream(memory, 0, buffer.Length, true)) {
                    Assert.AreEqual(buffer.Length, bounded.Length);

                    bounded.SetLength(500);

                    Assert.AreEqual(500, bounded.Length);
                    Assert.AreEqual(500, memory.Length);
                }
            }

            using (var memory = new MemoryStream()) {
                var buffer = Encoding.ASCII.GetBytes("This is some text...");

                memory.Write(buffer, 0, buffer.Length);

                using (var bounded = new BoundStream(memory, 0, buffer.Length, true)) {
                    Assert.AreEqual(buffer.Length, bounded.Length);

                    bounded.SetLength(5);

                    Assert.AreEqual(5, bounded.Length);
                    Assert.AreEqual(buffer.Length, memory.Length);
                }
            }
        }