public void Write_And_Read_Multiple_Times() { var writer = new MqttBufferWriter(4096, 65535); writer.WriteString("A relative short string."); writer.WriteBinaryData(new byte[1234]); writer.WriteByte(0x01); writer.WriteByte(0x02); writer.WriteVariableByteInteger(5647382); writer.WriteString("A relative short string."); writer.WriteVariableByteInteger(8574489); writer.WriteBinaryData(new byte[48]); writer.WriteByte(2); writer.WriteByte(0x02); writer.WriteString("fjgffiogfhgfhoihgoireghreghreguhreguireoghreouighreouighreughreguiorehreuiohruiorehreuioghreug"); writer.WriteBinaryData(new byte[3]); var readPayload = new ArraySegment <byte>(writer.GetBuffer(), 0, writer.Length).ToArray(); var reader = new MqttBufferReader(); reader.SetBuffer(readPayload, 0, readPayload.Length); for (var i = 0; i < 100000; i++) { reader.Seek(0); reader.ReadString(); reader.ReadBinaryData(); reader.ReadByte(); reader.ReadByte(); reader.ReadVariableByteInteger(); reader.ReadString(); reader.ReadVariableByteInteger(); reader.ReadBinaryData(); reader.ReadByte(); reader.ReadByte(); reader.ReadString(); reader.ReadBinaryData(); } }
public void Read_100_000_Messages() { var reader = new MqttBufferReader(); reader.SetBuffer(_readPayload, 0, _readPayload.Length); for (var i = 0; i < 100000; i++) { reader.Seek(0); reader.ReadString(); reader.ReadBinaryData(); reader.ReadByte(); reader.ReadByte(); reader.ReadVariableByteInteger(); reader.ReadString(); reader.ReadVariableByteInteger(); reader.ReadBinaryData(); reader.ReadByte(); reader.ReadByte(); reader.ReadString(); reader.ReadBinaryData(); } }