mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 19:58:57 +08:00
use streams
This commit is contained in:
@@ -391,6 +391,8 @@ namespace MQTTnet.Core.Tests
|
||||
{
|
||||
private readonly MemoryStream _stream = new MemoryStream();
|
||||
|
||||
public Stream Stream => _stream;
|
||||
|
||||
public bool IsConnected { get; } = true;
|
||||
|
||||
public TestChannel()
|
||||
@@ -413,26 +415,10 @@ namespace MQTTnet.Core.Tests
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
|
||||
public Task WriteAsync(byte[] buffer)
|
||||
{
|
||||
return _stream.WriteAsync(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
public async Task<ArraySegment<byte>> ReadAsync(int length, byte[] buffer)
|
||||
{
|
||||
await _stream.ReadAsync(buffer, 0, length);
|
||||
return new ArraySegment<byte>(buffer, 0, length);
|
||||
}
|
||||
|
||||
public byte[] ToArray()
|
||||
{
|
||||
return _stream.ToArray();
|
||||
}
|
||||
|
||||
public int Peek()
|
||||
{
|
||||
return (int)_stream.Length - (int)_stream.Position;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SerializeAndCompare(MqttBasePacket packet, string expectedBase64Value, MqttProtocolVersion protocolVersion = MqttProtocolVersion.V311)
|
||||
|
||||
Reference in New Issue
Block a user