Interface IMqttTestingHelper
Exposes some helper methods and shortcuts to simplify testing.
Inherited Members
Namespace: Silverback.Testing
Assembly: Silverback.Integration.MQTT.Testing.dll
Syntax
public interface IMqttTestingHelper : ITestingHelper
Methods
GetClientSession(string)
Gets the IClientSession of the specified client.
Declaration
IClientSession GetClientSession(string clientId)
Parameters
| Type | Name | Description |
|---|---|---|
| string | clientId | The client id. |
Returns
| Type | Description |
|---|---|
| IClientSession | The IClientSession. |
Remarks
This method works with the mocked MQTT broker only. See UseMockedMqtt(SilverbackBuilder, Action<IMockedMqttOptionsBuilder>?) or AddMockedMqtt(BrokerOptionsBuilder, Action<IMockedMqttOptionsBuilder>?).
GetMessages(string)
Gets the messages that have been published to the specified topic.
Declaration
IReadOnlyList<MqttApplicationMessage> GetMessages(string topic)
Parameters
| Type | Name | Description |
|---|---|---|
| string | topic | The topic. |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
IProducer GetProducer(Action<MqttClientConfigurationBuilder> configurationBuilderAction)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<MqttClientConfigurationBuilder> | configurationBuilderAction | An Action<T> that takes the MqttClientConfigurationBuilder and configures it. |
Returns
| Type | Description |
|---|---|
| IProducer | The IProducer. |