Procházet zdrojové kódy

Fix unit tests for serializer

release/3.x.x
Israel Lot před 6 roky
rodič
revize
786fa53334
1 změnil soubory, kde provedl 13 přidání a 2 odebrání
  1. +13
    -2
      Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs

+ 13
- 2
Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs Zobrazit soubor

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

Načítá se…
Zrušit
Uložit