mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using MQTTnet.Formatter;
|
|
|
|
namespace MQTTnet.Tests
|
|
{
|
|
[TestClass]
|
|
public class Protocol_Tests
|
|
{
|
|
[TestMethod]
|
|
public void Encode_Four_Byte_Integer()
|
|
{
|
|
var writer = new MqttBufferWriter(4, 4);
|
|
|
|
for (uint value = 0; value < 268435455; value++)
|
|
{
|
|
writer.WriteVariableByteInteger(value);
|
|
|
|
var buffer = writer.GetBuffer();
|
|
|
|
var reader = new MqttBufferReader();
|
|
reader.SetBuffer(buffer, 0, writer.Length);
|
|
var checkValue = reader.ReadVariableByteInteger();
|
|
|
|
Assert.AreEqual(value, checkValue);
|
|
|
|
writer.Reset(0);
|
|
}
|
|
}
|
|
}
|
|
}
|