-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Package Spec & Reduced Warnings (#168)
- Loading branch information
1 parent
88db36e
commit 16cbddb
Showing
5 changed files
with
33 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
namespace HiveMQtt.Test.HiveMQClient; | ||
|
||
using System.Text; | ||
using System.Threading.Tasks; | ||
using HiveMQtt.Client; | ||
using HiveMQtt.MQTT5.ReasonCodes; | ||
|
@@ -9,6 +8,9 @@ namespace HiveMQtt.Test.HiveMQClient; | |
|
||
public class PublishBuilderTest | ||
{ | ||
Check warning on line 10 in Tests/HiveMQtt.Test/HiveMQClient/PublishBuilderTest.cs GitHub Actions / pipeline-ubuntu-latest-dotnet-6.0.x
Check warning on line 10 in Tests/HiveMQtt.Test/HiveMQClient/PublishBuilderTest.cs GitHub Actions / pipeline-ubuntu-latest-dotnet-7.0.x
Check warning on line 10 in Tests/HiveMQtt.Test/HiveMQClient/PublishBuilderTest.cs GitHub Actions / pipeline-ubuntu-latest-dotnet-8.0.x
|
||
|
||
private readonly byte[] payload = { 0x01, 0x02, 0x03 }; | ||
|
||
[Fact] | ||
public async Task MostBasicPublishWithQoS0Async() | ||
{ | ||
|
@@ -18,15 +20,15 @@ public async Task MostBasicPublishWithQoS0Async() | |
|
||
var message = new PublishMessageBuilder() | ||
.WithTopic("tests/MostBasicPublishWithQoS0Async") | ||
.WithPayload(new byte[] { 0x01, 0x02, 0x03 }) | ||
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery) | ||
.WithPayload(this.payload) | ||
.WithQualityOfService(QualityOfService.AtMostOnceDelivery) | ||
.Build(); | ||
|
||
var result = await client.PublishAsync(message).ConfigureAwait(false); | ||
Assert.IsType<Client.Results.PublishResult>(result); | ||
Assert.Null(result.QoS1ReasonCode); | ||
Assert.Null(result.QoS2ReasonCode); | ||
Assert.Equal(MQTT5.Types.QualityOfService.AtMostOnceDelivery, result.Message.QoS); | ||
Assert.Equal(QualityOfService.AtMostOnceDelivery, result.Message.QoS); | ||
|
||
var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false); | ||
Assert.True(disconnectResult); | ||
|
@@ -41,14 +43,14 @@ public async Task MostBasicPublishWithQoS1Async() | |
|
||
var message = new PublishMessageBuilder() | ||
.WithTopic("tests/MostBasicPublishWithQoS1Async") | ||
.WithPayload(new byte[] { 0x01, 0x02, 0x03 }) | ||
.WithQualityOfService(MQTT5.Types.QualityOfService.AtLeastOnceDelivery) | ||
.WithPayload(this.payload) | ||
.WithQualityOfService(QualityOfService.AtLeastOnceDelivery) | ||
.Build(); | ||
var result = await client.PublishAsync(message).ConfigureAwait(false); | ||
Assert.IsType<Client.Results.PublishResult>(result); | ||
Assert.NotNull(result.QoS1ReasonCode); | ||
Assert.Null(result.QoS2ReasonCode); | ||
Assert.Equal(MQTT5.Types.QualityOfService.AtLeastOnceDelivery, result.Message.QoS); | ||
Assert.Equal(QualityOfService.AtLeastOnceDelivery, result.Message.QoS); | ||
|
||
var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false); | ||
Assert.True(disconnectResult); | ||
|
@@ -63,14 +65,14 @@ public async Task MostBasicPublishWithQoS2Async() | |
|
||
var message = new PublishMessageBuilder() | ||
.WithTopic("tests/MostBasicPublishWithQoS1Async") | ||
.WithPayload(new byte[] { 0x01, 0x02, 0x03 }) | ||
.WithQualityOfService(MQTT5.Types.QualityOfService.ExactlyOnceDelivery) | ||
.WithPayload(this.payload) | ||
.WithQualityOfService(QualityOfService.ExactlyOnceDelivery) | ||
.Build(); | ||
var result = await client.PublishAsync(message).ConfigureAwait(false); | ||
Assert.IsType<Client.Results.PublishResult>(result); | ||
Assert.NotNull(result.QoS2ReasonCode); | ||
Assert.Null(result.QoS1ReasonCode); | ||
Assert.Equal(MQTT5.Types.QualityOfService.ExactlyOnceDelivery, result.Message.QoS); | ||
Assert.Equal(QualityOfService.ExactlyOnceDelivery, result.Message.QoS); | ||
|
||
var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false); | ||
Assert.True(disconnectResult); | ||
|
@@ -85,8 +87,8 @@ public async Task MultiPublishWithQoS0Async() | |
|
||
var message = new PublishMessageBuilder() | ||
.WithTopic("tests/MultiPublishWithQoS0Async") | ||
.WithPayload(new byte[] { 0x01, 0x02, 0x03 }) | ||
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery) | ||
.WithPayload(this.payload) | ||
.WithQualityOfService(QualityOfService.AtMostOnceDelivery) | ||
.Build(); | ||
|
||
Client.Results.PublishResult result; | ||
|
@@ -97,7 +99,7 @@ public async Task MultiPublishWithQoS0Async() | |
Assert.IsType<Client.Results.PublishResult>(result); | ||
Assert.Null(result.QoS1ReasonCode); | ||
Assert.Null(result.QoS2ReasonCode); | ||
Assert.Equal(MQTT5.Types.QualityOfService.AtMostOnceDelivery, result.Message.QoS); | ||
Assert.Equal(QualityOfService.AtMostOnceDelivery, result.Message.QoS); | ||
} | ||
|
||
var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false); | ||
|
@@ -113,8 +115,8 @@ public async Task MultiPublishWithQoS1Async() | |
|
||
var message = new PublishMessageBuilder() | ||
.WithTopic("tests/MultiPublishWithQoS1Async") | ||
.WithPayload(new byte[] { 0x01, 0x02, 0x03 }) | ||
.WithQualityOfService(MQTT5.Types.QualityOfService.AtLeastOnceDelivery) | ||
.WithPayload(this.payload) | ||
.WithQualityOfService(QualityOfService.AtLeastOnceDelivery) | ||
.Build(); | ||
Client.Results.PublishResult result; | ||
|
||
|
@@ -139,8 +141,8 @@ public async Task MultiPublishWithQoS2Async() | |
|
||
var message = new PublishMessageBuilder() | ||
.WithTopic("tests/MultiPublishWithQoS2Async") | ||
.WithPayload(new byte[] { 0x01, 0x02, 0x03 }) | ||
.WithQualityOfService(MQTT5.Types.QualityOfService.ExactlyOnceDelivery) | ||
.WithPayload(this.payload) | ||
.WithQualityOfService(QualityOfService.ExactlyOnceDelivery) | ||
.Build(); | ||
Client.Results.PublishResult result; | ||
|
||
|
@@ -164,8 +166,8 @@ public async Task PublishWithOptionsAsync() | |
|
||
var message = new PublishMessageBuilder() | ||
.WithTopic("tests/PublishWithOptionsAsync") | ||
.WithPayload(new byte[] { 0x01, 0x02, 0x03 }) | ||
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery) | ||
.WithPayload(this.payload) | ||
.WithQualityOfService(QualityOfService.AtMostOnceDelivery) | ||
.WithUserProperty("test", "test") | ||
.Build(); | ||
|
||
|
@@ -189,8 +191,8 @@ public async Task PublishPayloadFormatIndicatorAsync() | |
|
||
var message = new PublishMessageBuilder() | ||
.WithTopic("tests/PublishPayloadFormatIndicatorAsync") | ||
.WithPayload(new byte[] { 0x01, 0x02, 0x03 }) | ||
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery) | ||
.WithPayload(this.payload) | ||
.WithQualityOfService(QualityOfService.AtMostOnceDelivery) | ||
.WithPayloadFormatIndicator(MQTT5PayloadFormatIndicator.UTF8Encoded) | ||
.Build(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters