Beispiel #1
0
        public void TestLong()
        {
            int maxLongs      = buffer.Size / sizeof(long);
            int expectedCount = maxLongs * sizeof(long);

            long[] expected = new long[maxLongs];

            for (int i = 0; i < maxLongs; i++)
            {
                expected[i] = (long)(r.NextDouble() * long.MaxValue);
                buffer.WriteLong(expected[i]);
            }

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

            Assert.AreEqual(expectedCount, buffer.Count);

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

            foreach (long l in expected)
            {
                Assert.AreEqual(l, buffer.ReadLong());
            }

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

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