MQTTnet
MQTTnet copied to clipboard
V4: Mock Raise DisconnectedAsync
Hi,
I want to raise an event from Mock<IMqttClient>. With this example I'm getting System.Reflection.TargetParameterCountException: 'Parameter count mismatch.' What is the right way to configure Raises() for DisconnectedAsync?
mockClient
.Setup(c => c.DisconnectAsync(
It.IsAny<MqttClientDisconnectOptions>(),
CancellationToken.None))
.Returns(Task.FromResult(new MqttClientConnectResult()))
.Raises(x => x.DisconnectedAsync += null, new MqttClientDisconnectedEventArgs());
Thanks!