public virtual void TestWrite() { MarshallingBuffer buffer = new MarshallingBuffer(); buffer.WriteInt(Data1); buffer.WriteByte(Data2); ByteArrayBuffer content = InspectContent(buffer); Assert.AreEqual(Data1, content.ReadInt()); Assert.AreEqual(Data2, content.ReadByte()); }
public virtual void TestTransferLastWrite() { MarshallingBuffer buffer = new MarshallingBuffer(); buffer.WriteInt(Data1); int lastOffset = Offset(buffer); buffer.WriteByte(Data2); MarshallingBuffer other = new MarshallingBuffer(); buffer.TransferLastWriteTo(other, true); Assert.AreEqual(lastOffset, Offset(buffer)); ByteArrayBuffer content = InspectContent(other); Assert.AreEqual(Data2, content.ReadByte()); }
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()); }
public virtual void TestLinkOffset() { int linkOffset = 7; MarshallingBuffer buffer = new MarshallingBuffer(); buffer.WriteInt(Data1); buffer.WriteByte(Data2); MarshallingBuffer child = buffer.AddChild(); child.WriteInt(Data3); child.WriteInt(Data4); MarshallingBuffer grandChild = child.AddChild(); grandChild.WriteInt(Data5); buffer.MergeChildren(null, 0, linkOffset); ByteArrayBuffer content = InspectContent(buffer); ByteArrayBuffer 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()); int 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 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()); }