コード例 #1
0
        public virtual void TestGrandChildren()
        {
            var buffer = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            buffer.WriteByte(Data2);
            var child = buffer.AddChild();

            child.WriteInt(Data3);
            child.WriteInt(Data4);
            var grandChild = child.AddChild();

            grandChild.WriteInt(Data5);
            buffer.MergeChildren(null, 0, 0);
            var content = InspectContent(buffer);

            Assert.AreEqual(Data1, content.ReadInt());
            Assert.AreEqual(Data2, content.ReadByte());
            var address = content.ReadInt();

            content.Seek(address);
            Assert.AreEqual(Data3, content.ReadInt());
            Assert.AreEqual(Data4, content.ReadInt());
            address = content.ReadInt();
            content.Seek(address);
            Assert.AreEqual(Data5, content.ReadInt());
        }
コード例 #2
0
        public virtual void TestLinkOffset()
        {
            var linkOffset = 7;
            var buffer     = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            buffer.WriteByte(Data2);
            var child = buffer.AddChild();

            child.WriteInt(Data3);
            child.WriteInt(Data4);
            var grandChild = child.AddChild();

            grandChild.WriteInt(Data5);
            buffer.MergeChildren(null, 0, linkOffset);
            var content        = InspectContent(buffer);
            var extendedBuffer = new ByteArrayBuffer(content.Length() + linkOffset
                                                     );

            content.CopyTo(extendedBuffer, 0, linkOffset, content.Length());
            extendedBuffer.Seek(linkOffset);
            Assert.AreEqual(Data1, extendedBuffer.ReadInt());
            Assert.AreEqual(Data2, extendedBuffer.ReadByte());
            var address = extendedBuffer.ReadInt();

            extendedBuffer.Seek(address);
            Assert.AreEqual(Data3, extendedBuffer.ReadInt());
            Assert.AreEqual(Data4, extendedBuffer.ReadInt());
            address = extendedBuffer.ReadInt();
            extendedBuffer.Seek(address);
            Assert.AreEqual(Data5, extendedBuffer.ReadInt());
        }
コード例 #3
0
        public virtual void TestWrite()
        {
            var buffer = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            buffer.WriteByte(Data2);
            var content = InspectContent(buffer);

            Assert.AreEqual(Data1, content.ReadInt());
            Assert.AreEqual(Data2, content.ReadByte());
        }
コード例 #4
0
        public virtual void TestTransferLastWrite()
        {
            var buffer = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            var lastOffset = Offset(buffer);

            buffer.WriteByte(Data2);
            var other = new MarshallingBuffer();

            buffer.TransferLastWriteTo(other, true);
            Assert.AreEqual(lastOffset, Offset(buffer));
            var content = InspectContent(other);

            Assert.AreEqual(Data2, content.ReadByte());
        }
コード例 #5
0
        public virtual void TestChildren()
        {
            MarshallingBuffer buffer = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            buffer.WriteByte(Data2);
            MarshallingBuffer child = buffer.AddChild();

            child.WriteInt(Data3);
            child.WriteInt(Data4);
            buffer.MergeChildren(null, 0, 0);
            ByteArrayBuffer content = InspectContent(buffer);

            Assert.AreEqual(Data1, content.ReadInt());
            Assert.AreEqual(Data2, content.ReadByte());
            int address = content.ReadInt();

            content.Seek(address);
            Assert.AreEqual(Data3, content.ReadInt());
            Assert.AreEqual(Data4, content.ReadInt());
        }
コード例 #6
0
 public virtual void WriteByte(byte b)
 {
     PreWrite();
     _currentBuffer.WriteByte(b);
     PostWrite();
 }