Skip to content

Commit

Permalink
More Test & Client Validations (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
pglombardo authored Mar 26, 2024
1 parent 163dcbc commit c4a82ac
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Tests/HiveMQtt.Test/HiveMQClient/ConnectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ namespace HiveMQtt.Test.HiveMQClient;
using System.Threading.Tasks;
using HiveMQtt.Client;
using HiveMQtt.Client.Events;
using HiveMQtt.Client.Exceptions;
using HiveMQtt.Client.Options;
using HiveMQtt.MQTT5.ReasonCodes;
using Xunit;

public class ConnectTest
{
[Fact]
public async Task Basic_Connect_And_Disconnect_Async()
public async Task BasicConnectAndDisconnectAsync()
{
var client = new HiveMQClient();
Assert.NotNull(client);
Expand All @@ -30,7 +31,20 @@ public async Task Basic_Connect_And_Disconnect_Async()
}

[Fact]
public async Task Test_Connect_Events_Async()
public async Task RaiseOnFailureToConnectAsync()
{
// Bad port number
var clientOptions = new HiveMQClientOptionsBuilder().WithPort(0).Build();
var client = new HiveMQClient(clientOptions);

await Assert.ThrowsAsync<HiveMQttClientException>(async () =>

Check warning on line 40 in Tests/HiveMQtt.Test/HiveMQClient/ConnectTest.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Lambda expression can be removed (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0200)

Check warning on line 40 in Tests/HiveMQtt.Test/HiveMQClient/ConnectTest.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Lambda expression can be removed (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0200)

Check warning on line 40 in Tests/HiveMQtt.Test/HiveMQClient/ConnectTest.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Lambda expression can be removed (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0200)

Check warning on line 40 in Tests/HiveMQtt.Test/HiveMQClient/ConnectTest.cs

View workflow job for this annotation

GitHub Actions / Build-ubuntu-latest

Lambda expression can be removed (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0200)
{
await client.ConnectAsync().ConfigureAwait(false);
}).ConfigureAwait(false);
}

[Fact]
public async Task TestConnectEventsAsync()
{
var client = new HiveMQClient();

Expand Down

0 comments on commit c4a82ac

Please sign in to comment.