コード例 #1
0
        public void TestBoolean()
        {
            bool[] expectedBools = new bool[buffer.Size];
            byte[] expectedBytes = new byte[buffer.Size];

            for (int i = 0; i < buffer.Size; i++)
            {
                expectedBools[i] = r.Next(2) == 1;
                expectedBytes[i] = (byte)(expectedBools[i] ? 1 : 0);
                buffer.WriteBoolean(expectedBools[i]);
            }

            Assert.IsTrue(buffer.IsFull);
            Assert.AreEqual(Mithril.Buffer.DEFAULT_SIZE, buffer.Count);

            for (int i = 0; i < buffer.Size; i++)
            {
                Assert.AreEqual(expectedBytes[i], buffer.Data[i]);
            }

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

            foreach (bool expected in expectedBools)
            {
                Assert.AreEqual(expected, buffer.ReadBoolean());
            }

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

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