コード例 #1
0
        public void CopyToTest()
        {
            DateTime date = DateTime.Now;

            MemoryBlock memory = new MemoryBlock(100);

            memory.Write(byte.MaxValue);
            memory.Write((short)short.MaxValue);
            memory.Write((ushort)ushort.MaxValue);
            memory.Write(int.MaxValue);
            memory.Write(uint.MaxValue);
            memory.Write(long.MaxValue);
            memory.Write(ulong.MaxValue);

            memory.Write(0.2f);
            memory.Write(0.2);

            memory.Write(date);
            memory.Write("WriteTest");

            memory.Position = 0;

            MemoryBlock memory2 = new MemoryBlock(100);

            memory.CopyTo(memory2, 0, 0, (int)memory.Length);

            Assert.IsTrue(memory2.ReadByte() == byte.MaxValue);
            Assert.IsTrue(memory2.ReadShort() == short.MaxValue);
            Assert.IsTrue(memory2.ReadUShort() == ushort.MaxValue);
            Assert.IsTrue(memory2.ReadInt() == int.MaxValue);
            Assert.IsTrue(memory2.ReadUInt() == uint.MaxValue);
            Assert.IsTrue(memory2.ReadLong() == long.MaxValue);
            Assert.IsTrue(memory2.ReadULong() == ulong.MaxValue);
            Assert.IsTrue(memory2.ReadFloat() == 0.2f);
            Assert.IsTrue(memory2.ReadDouble() == 0.2);
            Assert.IsTrue(memory2.ReadDateTime() == date);
            Assert.IsTrue(memory2.ReadString() == "WriteTest");
        }