Parcourir la source

Fix unit tests for serializer

release/3.x.x
Israel Lot il y a 6 ans
Parent
révision
786fa53334
1 fichiers modifiés avec 13 ajouts et 2 suppressions
  1. +13
    -2
      Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs

+ 13
- 2
Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs Voir le fichier

@@ -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();
}
}
}

Chargement…
Annuler
Enregistrer