Show / Hide Table of Contents

    Class MockedMqttClient

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Inheritance
    object
    MockedMqttClient
    Implements
    IMqttClient
    IDisposable
    Inherited Members
    object.GetType()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: Silverback.Messaging.Broker.Mqtt.Mocks
    Assembly: Silverback.Integration.MQTT.Testing.dll
    Syntax
    public sealed class MockedMqttClient : IMqttClient, IDisposable

    Constructors

    MockedMqttClient(IInMemoryMqttBroker, IMockedMqttOptions)

    Initializes a new instance of the MockedMqttClient class.

    Declaration
    public MockedMqttClient(IInMemoryMqttBroker broker, IMockedMqttOptions mockOptions)
    Parameters
    Type Name Description
    IInMemoryMqttBroker broker

    The IInMemoryMqttBroker.

    IMockedMqttOptions mockOptions

    The IMockedMqttOptions.

    Properties

    IsConnected

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public bool IsConnected { get; }
    Property Value
    Type Description
    bool

    Options

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public MqttClientOptions? Options { get; }
    Property Value
    Type Description
    MqttClientOptions

    Methods

    ConnectAsync(MqttClientOptions, CancellationToken)

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public Task<MqttClientConnectResult> ConnectAsync(MqttClientOptions options, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    MqttClientOptions options
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<MqttClientConnectResult>

    DisconnectAsync(MqttClientDisconnectOptions, CancellationToken)

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public Task DisconnectAsync(MqttClientDisconnectOptions options, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    MqttClientDisconnectOptions options
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Dispose()

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public void Dispose()

    PingAsync(CancellationToken)

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public Task PingAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    PublishAsync(MqttApplicationMessage, CancellationToken)

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public Task<MqttClientPublishResult> PublishAsync(MqttApplicationMessage applicationMessage, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    MqttApplicationMessage applicationMessage
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<MqttClientPublishResult>

    SendEnhancedAuthenticationExchangeDataAsync(MqttEnhancedAuthenticationExchangeData, CancellationToken)

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public Task SendEnhancedAuthenticationExchangeDataAsync(MqttEnhancedAuthenticationExchangeData data, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    MqttEnhancedAuthenticationExchangeData data
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    SubscribeAsync(MqttClientSubscribeOptions, CancellationToken)

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public Task<MqttClientSubscribeResult> SubscribeAsync(MqttClientSubscribeOptions options, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    MqttClientSubscribeOptions options
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<MqttClientSubscribeResult>

    UnsubscribeAsync(MqttClientUnsubscribeOptions, CancellationToken)

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public Task<MqttClientUnsubscribeResult> UnsubscribeAsync(MqttClientUnsubscribeOptions options, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    MqttClientUnsubscribeOptions options
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<MqttClientUnsubscribeResult>

    Events

    ApplicationMessageReceivedAsync

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public event Func<MqttApplicationMessageReceivedEventArgs, Task>? ApplicationMessageReceivedAsync
    Event Type
    Type Description
    Func<MqttApplicationMessageReceivedEventArgs, Task>

    ConnectedAsync

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public event Func<MqttClientConnectedEventArgs, Task>? ConnectedAsync
    Event Type
    Type Description
    Func<MqttClientConnectedEventArgs, Task>

    ConnectingAsync

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public event Func<MqttClientConnectingEventArgs, Task>? ConnectingAsync
    Event Type
    Type Description
    Func<MqttClientConnectingEventArgs, Task>

    DisconnectedAsync

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public event Func<MqttClientDisconnectedEventArgs, Task>? DisconnectedAsync
    Event Type
    Type Description
    Func<MqttClientDisconnectedEventArgs, Task>

    InspectPacketAsync

    A mocked implementation of MQTTnet.IMqttClient from MQTTnet that connects with an in-memory broker.

    Declaration
    public event Func<InspectMqttPacketEventArgs, Task>? InspectPacketAsync
    Event Type
    Type Description
    Func<InspectMqttPacketEventArgs, Task>

    Implements

    MQTTnet.IMqttClient
    IDisposable
    GitHub E-Mail
    ↑ Back to top © 2026 Sergio Aquilini