public virtual void TestGrandChildren() { 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, 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()); address = content.ReadInt(); content.Seek(address); Assert.AreEqual(Data5, 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 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()); }
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()); }
public virtual void TestChildren() { var buffer = new MarshallingBuffer(); buffer.WriteInt(Data1); buffer.WriteByte(Data2); var child = buffer.AddChild(); child.WriteInt(Data3); child.WriteInt(Data4); 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()); }
public virtual void WriteDeclaredAspectCount(int count) { _writeBuffer.WriteInt(count); }
public virtual void WriteInt(int i) { PreWrite(); _currentBuffer.WriteInt(i); PostWrite(); }