Example #1
0
        public void TestIntArray()
        {
            int[] expectedValues = new int[byte.MaxValue - 1];

            for (int i = 0; i < expectedValues.Length; i++)
            {
                expectedValues[i] = r.Next(int.MaxValue);
            }

            buffer.WriteIntArray(expectedValues);

            Assert.IsFalse(buffer.IsFull);
            Assert.AreEqual(expectedValues.Length * sizeof(int) + 1, buffer.Count);

            buffer.Reset();
            Assert.AreEqual(0, buffer.Position);

            int[] actualValues = buffer.ReadIntArray();

            Assert.AreEqual(expectedValues.Length, actualValues.Length);

            for (int i = 0; i < expectedValues.Length; i++)
            {
                Assert.AreEqual(expectedValues[i], actualValues[i]);
            }

            buffer.Wipe();
            Assert.AreEqual(0, buffer.Count);
        }