public void TestToBytes()
        {
            var data0 = RandomBytes(7101, -0x02F0B4EF);

            using (var bb = new TestByteBuffer(data0))
            {
                var dst = bb.ToBytes();
                Assert.AreEqual(7101, dst.Length, "ToBytes() - length");
                Assert.AreEqual(0, bb.StreamPosition, "ToBytes() - StreamPosition");
                AssertAreEqual(data0, dst, "ToBytes()");

                bb.InitializeStream();
                dst = bb.ToBytes();
                Assert.AreEqual(7101, dst.Length, "ToBytes() - length - after Stream initialized");
                Assert.AreEqual(0, bb.StreamPosition, "ToBytes() - StreamPosition - after Stream initialized");
                AssertAreEqual(data0, dst, "ToBytes() - after Stream initialized");
            }

            using (var bb = new TestByteBuffer(data0))
            {
                var dst = bb.ToBytes(389, 5803);
                Assert.AreEqual(5803, dst.Length, "ToBytes(int,int) - length");
                Assert.AreEqual(0, bb.StreamPosition, "ToBytes(int,int) - StreamPosition");
                AssertAreEqual(data0, 389, dst, 0, 5803, "ToBytes(int,int)");

                bb.InitializeStream();
                dst = bb.ToBytes(389, 5803);
                Assert.AreEqual(5803, dst.Length, "ToBytes(int,int) - length - after Stream initialized");
                Assert.AreEqual(0, bb.StreamPosition, "ToBytes(int,int) - StreamPosition - after Stream initialized");
                AssertAreEqual(data0, 389, dst, 0, 5803, "ToBytes(int,int) - after Stream initialized");
            }
        }
        public void TestToBytes()
        {
            var data0 = RandomBytes(10000000, 0);
            var stats = TestByteBufferStatistics.Empty;

            using (var bb = new TestByteBuffer(data0))
            {
                bb.ToBytes();
                stats += bb.LastStatistics;

                bb.ToBytes();
                stats += bb.LastStatistics;

                bb.ToBytes();
                stats += bb.LastStatistics;

                bb.ToBytes();
                stats += bb.LastStatistics;

                bb.ToBytes();
                stats += bb.LastStatistics;
            }

            using (var bb = new TestByteBuffer(data0))
            {
                bb.InitializeStream();
                bb.ToBytes();
                stats += bb.LastStatistics;

                bb.ToBytes();
                stats += bb.LastStatistics;

                bb.ToBytes();
                stats += bb.LastStatistics;

                bb.ToBytes();
                stats += bb.LastStatistics;

                bb.ToBytes();
                stats += bb.LastStatistics;
            }

            Console.WriteLine(stats);
        }