mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-30 10:42:48 +08:00
Update nugets (#2210)
* Upate nugets, fix breaking changes * Fix CI build
This commit is contained in:
@@ -180,41 +180,45 @@ public sealed class MqttTopicTemplate_Tests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(MqttProtocolViolationException))]
|
||||
public void RejectsEmptyTemplate()
|
||||
{
|
||||
_ = new MqttTopicTemplate("");
|
||||
Assert.ThrowsExactly<MqttProtocolViolationException>(() => _ = new MqttTopicTemplate(""));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void RejectsNullTemplate()
|
||||
{
|
||||
_ = new MqttTopicTemplate(null);
|
||||
Assert.ThrowsExactly<ArgumentNullException>(() => _ = new MqttTopicTemplate(null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void RejectsReservedChars1()
|
||||
{
|
||||
var template = new MqttTopicTemplate("A/B/{foo}/D");
|
||||
template.WithParameter("foo", "a#");
|
||||
Assert.ThrowsExactly<ArgumentException>(() =>
|
||||
{
|
||||
var template = new MqttTopicTemplate("A/B/{foo}/D");
|
||||
template.WithParameter("foo", "a#");
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void RejectsReservedChars2()
|
||||
{
|
||||
var template = new MqttTopicTemplate("A/B/{foo}/D");
|
||||
template.WithParameter("foo", "a+b");
|
||||
Assert.ThrowsExactly<ArgumentException>(() =>
|
||||
{
|
||||
var template = new MqttTopicTemplate("A/B/{foo}/D");
|
||||
template.WithParameter("foo", "a+b");
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void RejectsReservedChars3()
|
||||
{
|
||||
var template = new MqttTopicTemplate("A/B/{foo}/D");
|
||||
template.WithParameter("foo", "a/b");
|
||||
Assert.ThrowsExactly<ArgumentException>(() =>
|
||||
{
|
||||
var template = new MqttTopicTemplate("A/B/{foo}/D");
|
||||
template.WithParameter("foo", "a/b");
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -237,7 +241,7 @@ public sealed class MqttTopicTemplate_Tests
|
||||
public void SendAndSubscribeSupport2()
|
||||
{
|
||||
var template = new MqttTopicTemplate("App/v1/{sender}/message");
|
||||
Assert.ThrowsException<ArgumentException>(() => template.BuildMessage());
|
||||
Assert.ThrowsExactly<ArgumentException>(() => template.BuildMessage());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -122,49 +122,55 @@ public sealed class Rpc_Tests : BaseTestClass
|
||||
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(MqttCommunicationTimedOutException))]
|
||||
public async Task Execute_Timeout()
|
||||
public Task Execute_Timeout()
|
||||
{
|
||||
using var testEnvironment = CreateTestEnvironment();
|
||||
await testEnvironment.StartServer();
|
||||
|
||||
var requestSender = await testEnvironment.ConnectClient();
|
||||
|
||||
var rpcClient = new MqttRpcClient(requestSender, new MqttRpcClientOptionsBuilder().Build());
|
||||
await rpcClient.ExecuteAsync(TimeSpan.FromSeconds(2), "ping", "", MqttQualityOfServiceLevel.AtMostOnce);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(MqttCommunicationTimedOutException))]
|
||||
public async Task Execute_Timeout_MQTT_V5_Mixed_Clients()
|
||||
{
|
||||
using var testEnvironment = new TestEnvironment(TestContext);
|
||||
await testEnvironment.StartServer();
|
||||
var responseSender = await testEnvironment.ConnectClient();
|
||||
await responseSender.SubscribeAsync("MQTTnet.RPC/+/ping");
|
||||
|
||||
responseSender.ApplicationMessageReceivedAsync += e =>
|
||||
return Assert.ThrowsExactlyAsync<MqttCommunicationTimedOutException>(async () =>
|
||||
{
|
||||
Assert.IsNull(e.ApplicationMessage.ResponseTopic);
|
||||
return CompletedTask.Instance;
|
||||
};
|
||||
using var testEnvironment = CreateTestEnvironment();
|
||||
await testEnvironment.StartServer();
|
||||
|
||||
var requestSender = await testEnvironment.ConnectClient(new MqttClientOptionsBuilder().WithProtocolVersion(MqttProtocolVersion.V500));
|
||||
var requestSender = await testEnvironment.ConnectClient();
|
||||
|
||||
using var rpcClient = new MqttRpcClient(requestSender, new MqttRpcClientOptionsBuilder().Build());
|
||||
await rpcClient.ExecuteAsync(TimeSpan.FromSeconds(2), "ping", "", MqttQualityOfServiceLevel.AtMostOnce);
|
||||
var rpcClient = new MqttRpcClient(requestSender, new MqttRpcClientOptionsBuilder().Build());
|
||||
await rpcClient.ExecuteAsync(TimeSpan.FromSeconds(2), "ping", "", MqttQualityOfServiceLevel.AtMostOnce);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(MqttCommunicationTimedOutException))]
|
||||
public async Task Execute_With_Custom_Topic_Names()
|
||||
public Task Execute_Timeout_MQTT_V5_Mixed_Clients()
|
||||
{
|
||||
using var testEnvironment = CreateTestEnvironment();
|
||||
await testEnvironment.StartServer();
|
||||
return Assert.ThrowsExactlyAsync<MqttCommunicationTimedOutException>(async () =>
|
||||
{
|
||||
using var testEnvironment = new TestEnvironment(TestContext);
|
||||
await testEnvironment.StartServer();
|
||||
var responseSender = await testEnvironment.ConnectClient();
|
||||
await responseSender.SubscribeAsync("MQTTnet.RPC/+/ping");
|
||||
|
||||
var rpcClient = await testEnvironment.ConnectRpcClient(new MqttRpcClientOptionsBuilder().WithTopicGenerationStrategy(new TestTopicStrategy()).Build());
|
||||
responseSender.ApplicationMessageReceivedAsync += e =>
|
||||
{
|
||||
Assert.IsNull(e.ApplicationMessage.ResponseTopic);
|
||||
return CompletedTask.Instance;
|
||||
};
|
||||
|
||||
await rpcClient.ExecuteAsync(TimeSpan.FromSeconds(2), "ping", "", MqttQualityOfServiceLevel.AtMostOnce);
|
||||
var requestSender = await testEnvironment.ConnectClient(new MqttClientOptionsBuilder().WithProtocolVersion(MqttProtocolVersion.V500));
|
||||
|
||||
using var rpcClient = new MqttRpcClient(requestSender, new MqttRpcClientOptionsBuilder().Build());
|
||||
await rpcClient.ExecuteAsync(TimeSpan.FromSeconds(2), "ping", "", MqttQualityOfServiceLevel.AtMostOnce);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public Task Execute_With_Custom_Topic_Names()
|
||||
{
|
||||
return Assert.ThrowsExactlyAsync<MqttCommunicationTimedOutException>(async () =>
|
||||
{
|
||||
using var testEnvironment = CreateTestEnvironment();
|
||||
await testEnvironment.StartServer();
|
||||
|
||||
var rpcClient = await testEnvironment.ConnectRpcClient(new MqttRpcClientOptionsBuilder().WithTopicGenerationStrategy(new TestTopicStrategy()).Build());
|
||||
|
||||
await rpcClient.ExecuteAsync(TimeSpan.FromSeconds(2), "ping", "", MqttQualityOfServiceLevel.AtMostOnce);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
Reference in New Issue
Block a user