Example #1
0
        public void TestBuffer()
        {
            for (int i = 0; i < buffer.Size; i++)
            {
                buffer.WriteByte((byte)r.Next(byte.MaxValue));
            }

            bigBuffer.Write(buffer);
            bigBuffer.Reset();
            buffer.Reset();

            Assert.AreEqual(buffer.Count, bigBuffer.Count);

            int i2 = 0;

            while (bigBuffer.Count > 0)
            {
                Assert.AreEqual(buffer.PeekByte(i2), bigBuffer.ReadByte());
                i2++;
            }

            bigBuffer.Wipe();
            buffer.Reset();

            for (int i = 0; i < 10; i++)
            {
                buffer.ReadByte();
            }

            bigBuffer.Write(buffer, false);
            bigBuffer.Reset();

            Assert.AreEqual(10, buffer.Position);
            Assert.AreEqual(buffer.Count, bigBuffer.Count);

            while (bigBuffer.Count > 0)
            {
                Assert.AreEqual(buffer.ReadByte(), bigBuffer.ReadByte());
            }

            buffer.Wipe();
            bigBuffer.Wipe();
        }
Example #2
0
        public void TestClear()
        {
            byte[] expected = new byte[buffer.Size];

            for (int i = 0; i < expected.Length; i++)
            {
                expected[i] = (byte)r.Next(byte.MaxValue);
                buffer.WriteByte(expected[i]);
            }

            Assert.AreEqual(expected.Length, buffer.Count);

            buffer.Reset();
            Assert.AreEqual(0, buffer.Position);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], buffer.Data[i]);
            }

            buffer.Wipe();
            Assert.AreEqual(0, buffer.Count);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(0, buffer.Data[i]);
            }
        }