Example #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());
        }
Example #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());
        }
        public virtual void CreateChildBuffer(bool storeLengthInLink)
        {
            MarshallingBuffer childBuffer = _currentBuffer.AddChild(false, storeLengthInLink);

            _currentBuffer.ReserveChildLinkSpace(storeLengthInLink);
            _currentBuffer = childBuffer;
        }
Example #4
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());
        }