Quellcode durchsuchen

Fix unit tests for serializer

release/3.x.x
Israel Lot vor 6 Jahren
Ursprung
Commit
786fa53334
1 geänderte Dateien mit 13 neuen und 2 gelöschten Zeilen
  1. +13
    -2
      Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs

+ 13
- 2
Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs Datei anzeigen

@@ -403,9 +403,9 @@ namespace MQTTnet.Core.Tests
private static void SerializeAndCompare(MqttBasePacket packet, string expectedBase64Value, MqttProtocolVersion protocolVersion = MqttProtocolVersion.V311)
{
var serializer = new MqttPacketSerializer { ProtocolVersion = protocolVersion };
var chunks = serializer.Serialize(packet);
var data = serializer.Serialize(packet);
Assert.AreEqual(expectedBase64Value, Convert.ToBase64String(Join(chunks)));
Assert.AreEqual(expectedBase64Value, Convert.ToBase64String(Join(data)));
}

private static void DeserializeAndCompare(MqttBasePacket packet, string expectedBase64Value, MqttProtocolVersion protocolVersion = MqttProtocolVersion.V311)
@@ -438,5 +438,16 @@ namespace MQTTnet.Core.Tests

return buffer.ToArray();
}

private static byte[] Join(params ArraySegment<byte>[] chunks)
{
var buffer = new MemoryStream();
foreach (var chunk in chunks)
{
buffer.Write(chunk.Array, chunk.Offset, chunk.Count);
}

return buffer.ToArray();
}
}
}

Laden…
Abbrechen
Speichern