mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 09:13:02 +08:00
Add low level client.
This commit is contained in:
@@ -10,7 +10,7 @@ namespace MQTTnet.Benchmarks
|
||||
public class LoggerBenchmark
|
||||
{
|
||||
private IMqttNetLogger _logger;
|
||||
private IMqttNetChildLogger _childLogger;
|
||||
private IMqttNetLogger _childLogger;
|
||||
private bool _useHandler;
|
||||
|
||||
[GlobalSetup]
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MQTTnet.Benchmarks
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine($"MQTTnet - BenchmarkApp.{TargetFrameworkInfoProvider.TargetFramework}");
|
||||
Console.WriteLine($"MQTTnet - BenchmarkApp.{TargetFrameworkProvider.TargetFramework}");
|
||||
Console.WriteLine("1 = MessageProcessingBenchmark");
|
||||
Console.WriteLine("2 = SerializerBenchmark");
|
||||
Console.WriteLine("3 = LoggerBenchmark");
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MQTTnet.Client.Options;
|
||||
using MQTTnet.LowLevelClient;
|
||||
using MQTTnet.Packets;
|
||||
using MQTTnet.Protocol;
|
||||
using MQTTnet.Tests.Mockups;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MQTTnet.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class LowLevelMqttClient_Tests
|
||||
{
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
[TestMethod]
|
||||
public async Task Connect_And_Disconnect()
|
||||
{
|
||||
using (var testEnvironment = new TestEnvironment(TestContext))
|
||||
{
|
||||
var server = await testEnvironment.StartServerAsync();
|
||||
|
||||
var factory = new MqttFactory();
|
||||
var lowLevelClient = factory.CreateLowLevelMqttClient();
|
||||
|
||||
await lowLevelClient.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("127.0.0.1", testEnvironment.ServerPort).Build(), CancellationToken.None);
|
||||
|
||||
await lowLevelClient.DisconnectAsync(CancellationToken.None);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Authenticate()
|
||||
{
|
||||
using (var testEnvironment = new TestEnvironment(TestContext))
|
||||
{
|
||||
var server = await testEnvironment.StartServerAsync();
|
||||
|
||||
var factory = new MqttFactory();
|
||||
var lowLevelClient = factory.CreateLowLevelMqttClient();
|
||||
|
||||
await lowLevelClient.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("127.0.0.1", testEnvironment.ServerPort).Build(), CancellationToken.None);
|
||||
|
||||
var receivedPacket = await Authenticate(lowLevelClient).ConfigureAwait(false);
|
||||
|
||||
await lowLevelClient.DisconnectAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.IsNotNull(receivedPacket);
|
||||
Assert.AreEqual(MqttConnectReturnCode.ConnectionAccepted, receivedPacket.ReturnCode);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Subscribe()
|
||||
{
|
||||
using (var testEnvironment = new TestEnvironment(TestContext))
|
||||
{
|
||||
var server = await testEnvironment.StartServerAsync();
|
||||
|
||||
var factory = new MqttFactory();
|
||||
var lowLevelClient = factory.CreateLowLevelMqttClient();
|
||||
|
||||
await lowLevelClient.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("127.0.0.1", testEnvironment.ServerPort).Build(), CancellationToken.None);
|
||||
|
||||
await Authenticate(lowLevelClient).ConfigureAwait(false);
|
||||
|
||||
var receivedPacket = await Subscribe(lowLevelClient, "a").ConfigureAwait(false);
|
||||
|
||||
await lowLevelClient.DisconnectAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.IsNotNull(receivedPacket);
|
||||
Assert.AreEqual(MqttSubscribeReturnCode.SuccessMaximumQoS0, receivedPacket.ReturnCodes[0]);
|
||||
}
|
||||
}
|
||||
|
||||
async Task<MqttConnAckPacket> Authenticate(ILowLevelMqttClient client)
|
||||
{
|
||||
await client.SendAsync(new MqttConnectPacket()
|
||||
{
|
||||
CleanSession = true,
|
||||
ClientId = TestContext.TestName,
|
||||
Username = "user",
|
||||
Password = Encoding.UTF8.GetBytes("pass")
|
||||
},
|
||||
CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
return await client.ReceiveAsync(CancellationToken.None).ConfigureAwait(false) as MqttConnAckPacket;
|
||||
}
|
||||
|
||||
async Task<MqttSubAckPacket> Subscribe(ILowLevelMqttClient client, string topic)
|
||||
{
|
||||
await client.SendAsync(new MqttSubscribePacket
|
||||
{
|
||||
PacketIdentifier = 1,
|
||||
TopicFilters = new List<TopicFilter>
|
||||
{
|
||||
new TopicFilter
|
||||
{
|
||||
Topic = topic
|
||||
}
|
||||
}
|
||||
},
|
||||
CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
return await client.ReceiveAsync(CancellationToken.None).ConfigureAwait(false) as MqttSubAckPacket;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MQTTnet.Client;
|
||||
using MQTTnet.Client.Connecting;
|
||||
using MQTTnet.Client.Disconnecting;
|
||||
@@ -10,10 +8,12 @@ using MQTTnet.Client.Publishing;
|
||||
using MQTTnet.Client.Receiving;
|
||||
using MQTTnet.Client.Subscribing;
|
||||
using MQTTnet.Client.Unsubscribing;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MQTTnet.Tests.Mockups
|
||||
{
|
||||
public class TestClientWrapper : IMqttClient
|
||||
public sealed class TestClientWrapper : IMqttClient
|
||||
{
|
||||
public TestClientWrapper(IMqttClient implementation, TestContext testContext)
|
||||
{
|
||||
@@ -22,6 +22,7 @@ namespace MQTTnet.Tests.Mockups
|
||||
}
|
||||
|
||||
public IMqttClient Implementation { get; }
|
||||
|
||||
public TestContext TestContext { get; }
|
||||
|
||||
public bool IsConnected => Implementation.IsConnected;
|
||||
@@ -34,28 +35,32 @@ namespace MQTTnet.Tests.Mockups
|
||||
|
||||
public Task<MqttClientAuthenticateResult> ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
switch (options)
|
||||
if (TestContext != null)
|
||||
{
|
||||
case MqttClientOptionsBuilder builder:
|
||||
{
|
||||
var existingClientId = builder.Build().ClientId;
|
||||
if (existingClientId != null && !existingClientId.StartsWith(TestContext.TestName))
|
||||
switch (options)
|
||||
{
|
||||
case MqttClientOptionsBuilder builder:
|
||||
{
|
||||
builder.WithClientId(TestContext.TestName + existingClientId);
|
||||
var existingClientId = builder.Build().ClientId;
|
||||
if (existingClientId != null && !existingClientId.StartsWith(TestContext.TestName))
|
||||
{
|
||||
builder.WithClientId(TestContext.TestName + existingClientId);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MqttClientOptions op:
|
||||
{
|
||||
var existingClientId = op.ClientId;
|
||||
if (existingClientId != null && !existingClientId.StartsWith(TestContext.TestName))
|
||||
|
||||
case MqttClientOptions op:
|
||||
{
|
||||
op.ClientId = TestContext.TestName + existingClientId;
|
||||
var existingClientId = op.ClientId;
|
||||
if (existingClientId != null && !existingClientId.StartsWith(TestContext.TestName))
|
||||
{
|
||||
op.ClientId = TestContext.TestName + existingClientId;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Implementation.ConnectAsync(options, cancellationToken);
|
||||
@@ -81,7 +86,7 @@ namespace MQTTnet.Tests.Mockups
|
||||
return Implementation.SendExtendedAuthenticationExchangeDataAsync(data, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<Client.Subscribing.MqttClientSubscribeResult> SubscribeAsync(MqttClientSubscribeOptions options, CancellationToken cancellationToken)
|
||||
public Task<MqttClientSubscribeResult> SubscribeAsync(MqttClientSubscribeOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
return Implementation.SubscribeAsync(options, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MQTTnet.Client;
|
||||
using MQTTnet.Client.Options;
|
||||
using MQTTnet.Diagnostics;
|
||||
using MQTTnet.Internal;
|
||||
using MQTTnet.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MQTTnet.Tests.Mockups
|
||||
{
|
||||
public class TestEnvironment : Disposable
|
||||
public sealed class TestEnvironment : Disposable
|
||||
{
|
||||
private readonly MqttFactory _mqttFactory = new MqttFactory();
|
||||
private readonly List<IMqttClient> _clients = new List<IMqttClient>();
|
||||
private readonly IMqttNetLogger _serverLogger = new MqttNetLogger("server");
|
||||
private readonly IMqttNetLogger _clientLogger = new MqttNetLogger("client");
|
||||
readonly MqttFactory _mqttFactory = new MqttFactory();
|
||||
readonly List<IMqttClient> _clients = new List<IMqttClient>();
|
||||
readonly IMqttNetLogger _serverLogger = new MqttNetLogger("server");
|
||||
readonly IMqttNetLogger _clientLogger = new MqttNetLogger("client");
|
||||
|
||||
private readonly List<string> _serverErrors = new List<string>();
|
||||
private readonly List<string> _clientErrors = new List<string>();
|
||||
readonly List<string> _serverErrors = new List<string>();
|
||||
readonly List<string> _clientErrors = new List<string>();
|
||||
|
||||
private readonly List<Exception> _exceptions = new List<Exception>();
|
||||
readonly List<Exception> _exceptions = new List<Exception>();
|
||||
|
||||
public IMqttServer Server { get; private set; }
|
||||
|
||||
@@ -37,36 +37,42 @@ namespace MQTTnet.Tests.Mockups
|
||||
|
||||
public TestContext TestContext { get; }
|
||||
|
||||
public TestEnvironment() : this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public TestEnvironment(TestContext testContext)
|
||||
{
|
||||
TestContext = testContext;
|
||||
|
||||
_serverLogger.LogMessagePublished += (s, e) =>
|
||||
{
|
||||
if (e.TraceMessage.Level == MqttNetLogLevel.Error)
|
||||
if (e.LogMessage.Level == MqttNetLogLevel.Error)
|
||||
{
|
||||
lock (_serverErrors)
|
||||
{
|
||||
_serverErrors.Add(e.TraceMessage.ToString());
|
||||
_serverErrors.Add(e.LogMessage.ToString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_clientLogger.LogMessagePublished += (s, e) =>
|
||||
{
|
||||
lock (_clientErrors)
|
||||
if (e.LogMessage.Level == MqttNetLogLevel.Error)
|
||||
{
|
||||
if (e.TraceMessage.Level == MqttNetLogLevel.Error)
|
||||
lock (_clientErrors)
|
||||
{
|
||||
_clientErrors.Add(e.TraceMessage.ToString());
|
||||
_clientErrors.Add(e.LogMessage.ToString());
|
||||
}
|
||||
}
|
||||
};
|
||||
TestContext = testContext;
|
||||
}
|
||||
|
||||
public IMqttClient CreateClient()
|
||||
{
|
||||
var client = _mqttFactory.CreateMqttClient(_clientLogger);
|
||||
_clients.Add(client);
|
||||
|
||||
return new TestClientWrapper(client, TestContext);
|
||||
}
|
||||
|
||||
@@ -90,15 +96,17 @@ namespace MQTTnet.Tests.Mockups
|
||||
|
||||
public Task<IMqttClient> ConnectClientAsync()
|
||||
{
|
||||
return ConnectClientAsync(new MqttClientOptionsBuilder() );
|
||||
return ConnectClientAsync(new MqttClientOptionsBuilder());
|
||||
}
|
||||
|
||||
public async Task<IMqttClient> ConnectClientAsync(MqttClientOptionsBuilder options)
|
||||
{
|
||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||
|
||||
options = options.WithTcpServer("localhost", ServerPort);
|
||||
|
||||
var client = CreateClient();
|
||||
await client.ConnectAsync(options.WithTcpServer("localhost", ServerPort).Build());
|
||||
await client.ConnectAsync(options.Build());
|
||||
|
||||
return client;
|
||||
}
|
||||
@@ -150,6 +158,7 @@ namespace MQTTnet.Tests.Mockups
|
||||
throw new Exception($"{_exceptions.Count} exceptions tracked.\r\n" + string.Join(Environment.NewLine, _exceptions));
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
using System;
|
||||
using MQTTnet.Diagnostics;
|
||||
using MQTTnet.Diagnostics;
|
||||
using System;
|
||||
|
||||
namespace MQTTnet.Tests.Mockups
|
||||
{
|
||||
public class TestLogger : IMqttNetLogger, IMqttNetChildLogger
|
||||
public class TestLogger : IMqttNetLogger
|
||||
{
|
||||
public event EventHandler<MqttNetLogMessagePublishedEventArgs> LogMessagePublished;
|
||||
|
||||
IMqttNetChildLogger IMqttNetLogger.CreateChildLogger(string source)
|
||||
public IMqttNetLogger CreateChildLogger(string source = null)
|
||||
{
|
||||
return new MqttNetChildLogger(this, source);
|
||||
}
|
||||
|
||||
IMqttNetChildLogger IMqttNetChildLogger.CreateChildLogger(string source)
|
||||
{
|
||||
return new MqttNetChildLogger(this, source);
|
||||
return new TestLogger();
|
||||
}
|
||||
|
||||
public void Verbose(string message, params object[] parameters)
|
||||
@@ -36,5 +31,10 @@ namespace MQTTnet.Tests.Mockups
|
||||
public void Publish(MqttNetLogLevel logLevel, string source, string message, object[] parameters, Exception exception)
|
||||
{
|
||||
}
|
||||
|
||||
public void Publish(MqttNetLogLevel logLevel, string message, object[] parameters, Exception exception)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace MQTTnet.Tests.Mockups
|
||||
{
|
||||
_adapter = adapter;
|
||||
}
|
||||
|
||||
public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options, IMqttNetChildLogger logger)
|
||||
|
||||
public IMqttChannelAdapter CreateClientAdapter(IMqttClientOptions options, IMqttNetLogger logger)
|
||||
{
|
||||
return _adapter;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MQTTnet.Client.Publishing;
|
||||
using MQTTnet.Client.Receiving;
|
||||
using MQTTnet.Server;
|
||||
using MQTTnet.Server.Status;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MQTTnet.Tests.Mockups
|
||||
{
|
||||
public class TestServerWrapper : IMqttServer
|
||||
public sealed class TestServerWrapper : IMqttServer
|
||||
{
|
||||
public TestServerWrapper(IMqttServer implementation, TestContext testContext, TestEnvironment testEnvironment)
|
||||
{
|
||||
@@ -60,22 +60,29 @@ namespace MQTTnet.Tests.Mockups
|
||||
|
||||
public Task StartAsync(IMqttServerOptions options)
|
||||
{
|
||||
switch (options)
|
||||
if (TestContext != null)
|
||||
{
|
||||
case MqttServerOptionsBuilder builder:
|
||||
if (builder.Build().ConnectionValidator == null)
|
||||
{
|
||||
builder.WithConnectionValidator(ConnectionValidator);
|
||||
}
|
||||
break;
|
||||
case MqttServerOptions op:
|
||||
if (op.ConnectionValidator == null)
|
||||
{
|
||||
op.ConnectionValidator = new MqttServerConnectionValidatorDelegate(ConnectionValidator);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (options)
|
||||
{
|
||||
case MqttServerOptionsBuilder builder:
|
||||
{
|
||||
if (builder.Build().ConnectionValidator == null)
|
||||
{
|
||||
builder.WithConnectionValidator(ConnectionValidator);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case MqttServerOptions op:
|
||||
{
|
||||
if (op.ConnectionValidator == null)
|
||||
{
|
||||
op.ConnectionValidator = new MqttServerConnectionValidatorDelegate(ConnectionValidator);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Implementation.StartAsync(options);
|
||||
|
||||
@@ -17,22 +17,23 @@ namespace MQTTnet.Tests
|
||||
|
||||
//This test compares
|
||||
//1. correct logID
|
||||
string logId = "logId";
|
||||
var logId = "logId";
|
||||
string invalidLogId = null;
|
||||
|
||||
//2. if the total log calls are the same for global and local
|
||||
int globalLogCount = 0;
|
||||
int localLogCount = 0;
|
||||
var globalLogCount = 0;
|
||||
var localLogCount = 0;
|
||||
|
||||
MqttNetLogger logger = new MqttNetLogger(logId);
|
||||
var logger = new MqttNetLogger(logId);
|
||||
|
||||
//we have a theoretical bug here if a concurrent test is also logging
|
||||
var globalLog = new EventHandler<MqttNetLogMessagePublishedEventArgs>((s, e) =>
|
||||
{
|
||||
if (logId != e.TraceMessage.LogId)
|
||||
if (logId != e.LogMessage.LogId)
|
||||
{
|
||||
invalidLogId = e.TraceMessage.LogId;
|
||||
invalidLogId = e.LogMessage.LogId;
|
||||
}
|
||||
|
||||
Interlocked.Increment(ref globalLogCount);
|
||||
});
|
||||
|
||||
@@ -40,10 +41,11 @@ namespace MQTTnet.Tests
|
||||
|
||||
logger.LogMessagePublished += (s, e) =>
|
||||
{
|
||||
if (logId != e.TraceMessage.LogId)
|
||||
if (logId != e.LogMessage.LogId)
|
||||
{
|
||||
invalidLogId = e.TraceMessage.LogId;
|
||||
invalidLogId = e.LogMessage.LogId;
|
||||
}
|
||||
|
||||
Interlocked.Increment(ref localLogCount);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MQTTnet.Adapter;
|
||||
using MQTTnet.Client;
|
||||
using MQTTnet.Client.Connecting;
|
||||
@@ -17,6 +10,13 @@ using MQTTnet.Implementations;
|
||||
using MQTTnet.Protocol;
|
||||
using MQTTnet.Server;
|
||||
using MQTTnet.Tests.Mockups;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MQTTnet.Tests
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace MQTTnet.Tests
|
||||
MqttQualityOfServiceLevel.AtMostOnce,
|
||||
"A/B/C",
|
||||
MqttQualityOfServiceLevel.AtMostOnce,
|
||||
1,
|
||||
1,
|
||||
TestContext);
|
||||
}
|
||||
|
||||
@@ -1016,7 +1016,7 @@ namespace MQTTnet.Tests
|
||||
[TestMethod]
|
||||
public async Task Same_Client_Id_Connect_Disconnect_Event_Order()
|
||||
{
|
||||
using (var testEnvironment = new TestEnvironment(TestContext))
|
||||
using (var testEnvironment = new TestEnvironment())
|
||||
{
|
||||
var server = await testEnvironment.StartServerAsync(new MqttServerOptionsBuilder());
|
||||
|
||||
@@ -1038,11 +1038,11 @@ namespace MQTTnet.Tests
|
||||
}
|
||||
});
|
||||
|
||||
var clientOptions = new MqttClientOptionsBuilder()
|
||||
.WithClientId("same_id");
|
||||
var clientOptionsBuilder = new MqttClientOptionsBuilder()
|
||||
.WithClientId(Guid.NewGuid().ToString());
|
||||
|
||||
// c
|
||||
var c1 = await testEnvironment.ConnectClientAsync(clientOptions);
|
||||
var c1 = await testEnvironment.ConnectClientAsync(clientOptionsBuilder);
|
||||
|
||||
await Task.Delay(500);
|
||||
|
||||
@@ -1050,7 +1050,7 @@ namespace MQTTnet.Tests
|
||||
Assert.AreEqual("c", flow);
|
||||
|
||||
// dc
|
||||
var c2 = await testEnvironment.ConnectClientAsync(clientOptions);
|
||||
var c2 = await testEnvironment.ConnectClientAsync(clientOptionsBuilder);
|
||||
|
||||
c2.UseApplicationMessageReceivedHandler(_ =>
|
||||
{
|
||||
@@ -1058,8 +1058,8 @@ namespace MQTTnet.Tests
|
||||
{
|
||||
events.Add("r");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
c2.SubscribeAsync("topic").Wait();
|
||||
|
||||
await Task.Delay(500);
|
||||
@@ -1080,7 +1080,7 @@ namespace MQTTnet.Tests
|
||||
|
||||
Assert.AreEqual(false, c1.IsConnected);
|
||||
await c1.DisconnectAsync();
|
||||
Assert.AreEqual (false, c1.IsConnected);
|
||||
Assert.AreEqual(false, c1.IsConnected);
|
||||
|
||||
await Task.Delay(500);
|
||||
|
||||
@@ -1141,7 +1141,7 @@ namespace MQTTnet.Tests
|
||||
await testEnvironment.ConnectClientAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public async Task Close_Idle_Connection()
|
||||
{
|
||||
@@ -1182,7 +1182,7 @@ namespace MQTTnet.Tests
|
||||
// forever. This is security related.
|
||||
var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
await PlatformAbstractionLayer.ConnectAsync(client, "localhost", testEnvironment.ServerPort);
|
||||
|
||||
|
||||
var buffer = Encoding.UTF8.GetBytes("Garbage");
|
||||
client.Send(buffer, buffer.Length, SocketFlags.None);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace MQTTnet.TestApp.NetCore
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
Console.WriteLine($"MQTTnet - TestApp.{TargetFrameworkInfoProvider.TargetFramework}");
|
||||
Console.WriteLine($"MQTTnet - TestApp.{TargetFrameworkProvider.TargetFramework}");
|
||||
Console.WriteLine("1 = Start client");
|
||||
Console.WriteLine("2 = Start server");
|
||||
Console.WriteLine("3 = Start performance test");
|
||||
|
||||
Reference in New Issue
Block a user