Пример #1
0
        public void TestShortArray()
        {
            short[] expectedValues = new short[byte.MaxValue - 1];

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

            buffer.WriteShortArray(expectedValues);

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

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

            short[] actualValues = buffer.ReadShortArray();

            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);
        }