Refactor package object model.

This commit is contained in:
Christian Kratky
2020-10-28 23:11:12 +01:00
parent adce5662eb
commit b7fb0c1002
71 changed files with 761 additions and 582 deletions
@@ -6,7 +6,9 @@ using MQTTnet.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.LowLevelClient;
namespace MQTTnet.Tests.Mockups
{
@@ -100,6 +102,25 @@ namespace MQTTnet.Tests.Mockups
return ConnectClientAsync(new MqttClientOptionsBuilder());
}
public Task<ILowLevelMqttClient> ConnectLowLevelClientAsync()
{
return ConnectLowLevelClientAsync(o => {});
}
public async Task<ILowLevelMqttClient> ConnectLowLevelClientAsync(Action<MqttClientOptionsBuilder> optionsBuilder)
{
if (optionsBuilder == null) throw new ArgumentNullException(nameof(optionsBuilder));
var options = new MqttClientOptionsBuilder();
options = options.WithTcpServer("127.0.0.1", ServerPort);
optionsBuilder.Invoke(options);
var client = new MqttFactory().CreateLowLevelMqttClient();
await client.ConnectAsync(options.Build(), CancellationToken.None).ConfigureAwait(false);
return client;
}
public async Task<IMqttClient> ConnectClientAsync(MqttClientOptionsBuilder options)
{
if (options == null) throw new ArgumentNullException(nameof(options));
@@ -111,7 +132,7 @@ namespace MQTTnet.Tests.Mockups
return client;
}
public async Task<IMqttClient> ConnectClientAsync(IMqttClientOptions options)
{
if (options == null) throw new ArgumentNullException(nameof(options));
@@ -11,7 +11,7 @@ namespace MQTTnet.Tests.Mockups
{
public class TestMqttCommunicationAdapter : IMqttChannelAdapter
{
private readonly BlockingCollection<MqttBasePacket> _incomingPackets = new BlockingCollection<MqttBasePacket>();
readonly BlockingCollection<MqttBasePacket> _incomingPackets = new BlockingCollection<MqttBasePacket>();
public TestMqttCommunicationAdapter Partner { get; set; }
@@ -26,8 +26,7 @@ namespace MQTTnet.Tests.Mockups
public long BytesSent { get; }
public long BytesReceived { get; }
public Action ReadingPacketStartedCallback { get; set; }
public Action ReadingPacketCompletedCallback { get; set; }
public bool IsReadingPacket { get; }
public void Dispose()
{