Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasMH committed Oct 10, 2023
1 parent f63d52e commit eda51cf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public async Task ShouldSetConnectionsToOne()
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10));

// Act
_clientStub.IsConnected = true;
await _sut.StartAsync(cancellationTokenSource.Token);
await _clientStub.CallConnectedAsync(new MqttClientConnectedEventArgs(new MqttClientConnectResult()));
await _clientStub.CallConnectionStateChangedAsync(new MqttClientConnectedEventArgs(new MqttClientConnectResult()));

// Assert
listener.RecordObservableInstruments();
Expand Down Expand Up @@ -87,7 +88,7 @@ public async Task ShouldIncreaseMessagesSent()
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10));

await _sut.StartAsync(cancellationTokenSource.Token);
await _clientStub.CallConnectedAsync(new MqttClientConnectedEventArgs(new MqttClientConnectResult()));
await _clientStub.CallConnectionStateChangedAsync(new MqttClientConnectedEventArgs(new MqttClientConnectResult()));

var message = new MqttApplicationMessageBuilder()
.WithTopic("my-topic")
Expand All @@ -106,7 +107,7 @@ public class MqttClientStub : IManagedMqttClient
{
public IMqttClient InternalClient => throw new NotImplementedException();

public bool IsConnected => throw new NotImplementedException();
public bool IsConnected { get; set; }

public bool IsStarted => throw new NotImplementedException();

Expand All @@ -126,6 +127,10 @@ public Task CallConnectedAsync(MqttClientConnectedEventArgs args)

public event Func<ConnectingFailedEventArgs, Task> ConnectingFailedAsync = null!;

Check warning on line 128 in test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs

View workflow job for this annotation

GitHub Actions / build

The field 'MqttClientStub.ConnectingFailedAsync' is assigned but its value is never used

Check warning on line 128 in test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs

View workflow job for this annotation

GitHub Actions / build

The field 'MqttClientStub.ConnectingFailedAsync' is assigned but its value is never used

Check warning on line 128 in test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs

View workflow job for this annotation

GitHub Actions / build

The field 'MqttClientStub.ConnectingFailedAsync' is assigned but its value is never used

Check warning on line 128 in test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs

View workflow job for this annotation

GitHub Actions / build

The field 'MqttClientStub.ConnectingFailedAsync' is assigned but its value is never used
public event Func<EventArgs, Task> ConnectionStateChangedAsync = null!;
public Task CallConnectionStateChangedAsync(EventArgs args)
{
return ConnectionStateChangedAsync.Invoke(args);
}
public event Func<MqttClientDisconnectedEventArgs, Task> DisconnectedAsync = null!;
public Task CallDisconnectedAsync(MqttClientDisconnectedEventArgs args)
{
Expand Down

0 comments on commit eda51cf

Please sign in to comment.