Show / Hide Table of Contents

    Class MqttTestingHelper

    Exposes some helper methods and shortcuts to simplify testing.

    Inheritance
    object
    TestingHelper<MqttBroker>
    MqttTestingHelper
    Implements
    IMqttTestingHelper
    ITestingHelper<MqttBroker>
    Inherited Members
    TestingHelper<MqttBroker>.Broker
    TestingHelper<MqttBroker>.Spy
    TestingHelper<MqttBroker>.WaitUntilConnectedAsync(TimeSpan?)
    TestingHelper<MqttBroker>.WaitUntilConnectedAsync(bool, TimeSpan?)
    TestingHelper<MqttBroker>.WaitUntilAllMessagesAreConsumedAsync(TimeSpan?)
    TestingHelper<MqttBroker>.WaitUntilOutboxIsEmptyAsync(CancellationToken)
    TestingHelper<MqttBroker>.IsOutboxEmptyAsync()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Silverback.Testing
    Assembly: Silverback.Integration.MQTT.Testing.dll
    Syntax
    public class MqttTestingHelper : TestingHelper<MqttBroker>, IMqttTestingHelper, ITestingHelper<MqttBroker>

    Constructors

    | Improve this doc View source

    MqttTestingHelper(IServiceProvider, ILogger<MqttTestingHelper>)

    Initializes a new instance of the MqttTestingHelper class.

    Declaration
    public MqttTestingHelper(IServiceProvider serviceProvider, ILogger<MqttTestingHelper> logger)
    Parameters
    Type Name Description
    IServiceProvider serviceProvider

    The IServiceProvider.

    ILogger<MqttTestingHelper> logger

    The ISilverbackLogger.

    Methods

    | Improve this doc View source

    GetClientSession(string)

    Gets the IClientSession of the specified client.

    Declaration
    public 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(ISilverbackBuilder, Action<IMockedMqttOptionsBuilder>?) or AddMockedMqtt(IBrokerOptionsBuilder, Action<IMockedMqttOptionsBuilder>?).

    | Improve this doc View source

    GetMessages(string)

    Gets the messages that have been published to the specified topic.

    Declaration
    public IReadOnlyList<MqttApplicationMessage> GetMessages(string topic)
    Parameters
    Type Name Description
    string topic

    The name of 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(ISilverbackBuilder, Action<IMockedMqttOptionsBuilder>?) or AddMockedMqtt(IBrokerOptionsBuilder, Action<IMockedMqttOptionsBuilder>?).

    | Improve this doc View source

    WaitUntilAllMessagesAreConsumedAsync(bool, TimeSpan?)

    Returns a Task that completes when all messages routed to the consumers have been processed and committed.

    Declaration
    public override Task WaitUntilAllMessagesAreConsumedAsync(bool throwTimeoutException, TimeSpan? timeout = null)
    Parameters
    Type Name Description
    bool throwTimeoutException

    A value specifying whether a TimeoutException has to be thrown when the messages aren't consumed before the timeout expires.

    TimeSpan? timeout

    The time to wait for the messages to be consumed and processed. The default is 30 seconds.

    Returns
    Type Description
    Task

    A Task that completes when all messages have been processed.

    Overrides
    TestingHelper<MqttBroker>.WaitUntilAllMessagesAreConsumedAsync(bool, TimeSpan?)
    Remarks

    This method works with the mocked brokers only.

    Implements

    IMqttTestingHelper
    ITestingHelper<TBroker>
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini