Exemplo n.º 1
0
        public void TestDouble()
        {
            int maxDoubles    = buffer.Size / sizeof(double);
            int expectedCount = maxDoubles * sizeof(double);

            double[] expected = new double[maxDoubles];

            for (int i = 0; i < maxDoubles; i++)
            {
                expected[i] = r.NextDouble() * double.MaxValue;
                buffer.WriteDouble(expected[i]);
            }

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

            Assert.AreEqual(expectedCount, buffer.Count);

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

            foreach (double d in expected)
            {
                Assert.AreEqual(d, buffer.ReadDouble());
            }

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

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