public PacketFrame(byte opcode, PacketLength size, int writeHead, BlobPlaceholder?placeholder = null) { Opcode = opcode; Size = size; Placeholder = placeholder; AtWriteHead = writeHead; }
public PacketSizeDoesNotMatchWrittenSizeException( byte opcode, PacketLength size, int writtenSize) { Opcode = opcode; Size = size; WrittenSize = writtenSize; }
public void TestLastOctetNonZero() { var octets = new byte[] { 0xff, 0x02 }; int octetsUsed = 0; var value = PacketLength.Convert(octets, 0, out octetsUsed); Assert.That(2, Is.EqualTo(octetsUsed)); Assert.That(255 + 2 * 256, Is.EqualTo(value)); }
public void TestThreeOctetsLastShouldBeIgnored() { var octets = new byte[] { 0x80, 0x01, 0x30 }; int octetsUsed = 0; var value = PacketLength.Convert(octets, 0, out octetsUsed); Assert.That(2, Is.EqualTo(octetsUsed)); Assert.That(384, Is.EqualTo(value)); }
public void Test16bit() { var octets = new byte[] { 0x80, 0x01 }; int octetsUsed = 0; var value = PacketLength.Convert(octets, 0, out octetsUsed); Assert.That(2, Is.EqualTo(octetsUsed)); Assert.That(384, Is.EqualTo(value)); }
public void TestLower() { var octets = new byte[] { 0x73 }; int octetsUsed = 0; var value = PacketLength.Convert(octets, 0, out octetsUsed); Assert.That(1, Is.EqualTo(octetsUsed)); Assert.That(7 * 16 + 3, Is.EqualTo(value)); }
protected override BaseBlock ConvertToBaseBlock(bool reverseByteOrder, Action <Exception> ActionOnException) { List <byte> body = new List <byte>(); body.AddRange(BitConverter.GetBytes(InterfaceID.ReverseByteOrder(reverseByteOrder))); body.AddRange(Timestamp.ConvertToByte(reverseByteOrder)); body.AddRange(BitConverter.GetBytes(Data.Length.ReverseByteOrder(reverseByteOrder))); body.AddRange(BitConverter.GetBytes(PacketLength.ReverseByteOrder(reverseByteOrder))); body.AddRange(Data); int remainderLength = (BaseBlock.AlignmentBoundary - Data.Length % BaseBlock.AlignmentBoundary) % BaseBlock.AlignmentBoundary; for (int i = 0; i < remainderLength; i++) { body.Add(0); } body.AddRange(Options.ConvertToByte(reverseByteOrder, ActionOnException)); BaseBlock baseBlock = new BaseBlock(this.BlockType, body.ToArray(), reverseByteOrder, 0); return(baseBlock); }