Interface IMqttTestingHelper
- Namespace
- Silverback.Testing
- Assembly
- Silverback.Integration.MQTT.Testing.dll
Exposes some helper methods and shortcuts to simplify testing.
public interface IMqttTestingHelper : ITestingHelper
- Inherited Members
Methods
GetClientSession(string)
Gets the IClientSession of the specified client.
IClientSession GetClientSession(string clientId)
Parameters
clientIdstringThe client id.
Returns
Remarks
This method works with the mocked MQTT broker only. See UseMockedMqtt(SilverbackBuilder, Action<IMockedMqttOptionsBuilder>?) or AddMockedMqtt(BrokerOptionsBuilder, Action<IMockedMqttOptionsBuilder>?).
Exceptions
- InvalidOperationException
No session (or more than one) exists for the specified client.
GetMessages(string)
Gets the messages that have been published to the specified topic.
IReadOnlyList<MqttApplicationMessage> GetMessages(string topic)
Parameters
topicstringThe topic.
Returns
- IReadOnlyList<MqttApplicationMessage>
The messages published to the topic.
Remarks
This method works with the mocked MQTT broker only. See UseMockedMqtt(SilverbackBuilder, Action<IMockedMqttOptionsBuilder>?) or AddMockedMqtt(BrokerOptionsBuilder, Action<IMockedMqttOptionsBuilder>?).
GetProducer(Action<MqttClientConfigurationBuilder>)
Gets a new producer with the specified configuration.
IProducer GetProducer(Action<MqttClientConfigurationBuilder> configurationBuilderAction)
Parameters
configurationBuilderActionAction<MqttClientConfigurationBuilder>An Action<T> that takes the MqttClientConfigurationBuilder and configures it.
Returns
Exceptions
- BrokerConfigurationException
The client configuration is not valid.
- InvalidOperationException
The MQTT integration hasn't been added (
AddMqtthasn't been called), the configuration doesn't define exactly one producer endpoint, or a producer endpoint with the same name has already been added.