diff --git a/test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs b/test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs index 13ecbb1..7ef2e95 100644 --- a/test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs +++ b/test/ToMqttNet.Test.Unit/MqttConnectionServiceTests.cs @@ -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(); @@ -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") @@ -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(); @@ -126,6 +127,10 @@ public Task CallConnectedAsync(MqttClientConnectedEventArgs args) public event Func ConnectingFailedAsync = null!; public event Func ConnectionStateChangedAsync = null!; + public Task CallConnectionStateChangedAsync(EventArgs args) + { + return ConnectionStateChangedAsync.Invoke(args); + } public event Func DisconnectedAsync = null!; public Task CallDisconnectedAsync(MqttClientDisconnectedEventArgs args) {