Show / Hide Table of Contents

    Class TestingHelper<TBroker>

    Exposes some helper methods and shortcuts to simplify testing.

    Inheritance
    object
    TestingHelper<TBroker>
    KafkaTestingHelper
    MqttTestingHelper
    Implements
    ITestingHelper<TBroker>
    Inherited Members
    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.Testing.dll
    Syntax
    public abstract class TestingHelper<TBroker> : ITestingHelper<TBroker> where TBroker : IBroker
    Type Parameters
    Name Description
    TBroker

    The IBroker implementation.

    Constructors

    | Improve this doc View source

    TestingHelper(IServiceProvider, ILogger<TestingHelper<TBroker>>)

    Initializes a new instance of the TestingHelper<TBroker> class.

    Declaration
    protected TestingHelper(IServiceProvider serviceProvider, ILogger<TestingHelper<TBroker>> logger)
    Parameters
    Type Name Description
    IServiceProvider serviceProvider

    The IServiceProvider.

    ILogger<TestingHelper<TBroker>> logger

    The ILogger<TCategoryName>.

    Properties

    | Improve this doc View source

    Broker

    Gets the current IBroker instance.

    Declaration
    public TBroker Broker { get; }
    Property Value
    Type Description
    TBroker
    | Improve this doc View source

    Spy

    Gets the IIntegrationSpy.

    Declaration
    public IIntegrationSpy Spy { get; }
    Property Value
    Type Description
    IIntegrationSpy
    Remarks

    The IIntegrationSpy must be enabled calling AddIntegrationSpy or AddIntegrationSpyAndSubscriber.

    Methods

    | Improve this doc View source

    IsOutboxEmptyAsync()

    Checks whether the outbox (table) is empty.

    Declaration
    public Task<bool> IsOutboxEmptyAsync()
    Returns
    Type Description
    Task<bool>

    A Task<TResult> representing the asynchronous operation. The task result contains true if the outbox is empty, otherwise false.

    | 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 abstract 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.

    Remarks

    This method works with the mocked brokers only.

    | Improve this doc View source

    WaitUntilAllMessagesAreConsumedAsync(TimeSpan?)

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

    Declaration
    public Task WaitUntilAllMessagesAreConsumedAsync(TimeSpan? timeout = null)
    Parameters
    Type Name Description
    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.

    Remarks

    This method works with the mocked brokers only.

    | Improve this doc View source

    WaitUntilConnectedAsync(bool, TimeSpan?)

    Returns a Task that completes when all consumers are connected and ready.

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

    A value specifying whether a TimeoutException has to be thrown when the connection isn't established before the timeout expires.

    TimeSpan? timeout

    The time to wait for the consumers to connect. The default is 30 seconds.

    Returns
    Type Description
    Task

    A Task that completes when all consumers are successfully connected and ready.

    | Improve this doc View source

    WaitUntilConnectedAsync(TimeSpan?)

    Returns a Task that completes when all consumers are connected and ready.

    Declaration
    public Task WaitUntilConnectedAsync(TimeSpan? timeout = null)
    Parameters
    Type Name Description
    TimeSpan? timeout

    The time to wait for the consumers to connect. The default is 30 seconds.

    Returns
    Type Description
    Task

    A Task that completes when all consumers are successfully connected and ready.

    | Improve this doc View source

    WaitUntilOutboxIsEmptyAsync(CancellationToken)

    Returns a Task that completes when all messages stored in the outbox have been produced.

    Declaration
    public Task WaitUntilOutboxIsEmptyAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A CancellationToken to observe while waiting for the task to complete.

    Returns
    Type Description
    Task

    A Task that completes when the outbox is empty.

    Implements

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