Ejemplo n.º 1
0
        public void TestInt()
        {
            int maxInts       = buffer.Size / sizeof(int);
            int expectedCount = maxInts * sizeof(int);

            int[] expected = new int[maxInts];

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

            if (expectedCount == buffer.Size)
            {
                Assert.IsTrue(buffer.IsFull);
            }

            Assert.AreEqual(expectedCount, buffer.Count);

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

            foreach (int i in expected)
            {
                Assert.AreEqual(i, buffer.ReadInt());
            }

            Assert.AreEqual(0, buffer.Count);
            Assert.AreEqual(expectedCount, buffer.Position);

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