Table of Contents

Interface ITestingHelper

Namespace
Silverback.Testing
Assembly
Silverback.Integration.Testing.dll

Exposes some helper methods and shortcuts to simplify testing.

public interface ITestingHelper

Properties

Spy

Gets the IIntegrationSpy.

IIntegrationSpy Spy { get; }

Property Value

IIntegrationSpy

Remarks

The IIntegrationSpy must be enabled calling AddIntegrationSpy or AddIntegrationSpyAndSubscriber.

Methods

GetConsumer(string)

Gets the consumer with the specified name.

IConsumer GetConsumer(string name)

Parameters

name string

The consumer name.

Returns

IConsumer

The IConsumer with the specified name.

GetConsumerForEndpoint(string)

Gets the existing consumer connected to specified endpoint.

IConsumer GetConsumerForEndpoint(string endpointName)

Parameters

endpointName string

The endpoint name. It could be either the topic/queue name or the friendly name.

Returns

IConsumer

The IProducer.

GetProducerForEndpoint(string)

Gets a producer for the specified endpoint.

IProducer GetProducerForEndpoint(string endpointName)

Parameters

endpointName string

The endpoint name. It could be either the topic/queue name or the friendly name.

Returns

IProducer

The IProducer.

IsOutboxEmptyAsync()

Checks whether the outbox (table) is empty.

ValueTask<bool> IsOutboxEmptyAsync()

Returns

ValueTask<bool>

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

WaitUntilAllMessagesAreConsumedAsync(bool, TimeSpan?)

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

ValueTask WaitUntilAllMessagesAreConsumedAsync(bool throwTimeoutException, TimeSpan? timeout = null)

Parameters

throwTimeoutException bool
A value specifying whether a <xref href="System.TimeoutException" data-throw-if-not-resolved="false"></xref> has to be thrown when the messages aren't consumed before the

timeout elapses.

timeout TimeSpan?

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

Returns

ValueTask

A ValueTask that completes when all messages have been processed.

Remarks

This method works with the mocked brokers only.

WaitUntilAllMessagesAreConsumedAsync(bool, TimeSpan?, params string[])

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

ValueTask WaitUntilAllMessagesAreConsumedAsync(bool throwTimeoutException, TimeSpan? timeout, params string[] endpointNames)

Parameters

throwTimeoutException bool
A value specifying whether a <xref href="System.TimeoutException" data-throw-if-not-resolved="false"></xref> has to be thrown when the messages aren't consumed before the

timeout elapses.

timeout TimeSpan?

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

endpointNames string[]

The names of the endpoints to wait for. If not specified, all endpoints are considered.

Returns

ValueTask

A ValueTask that completes when all messages have been processed.

Remarks

This method works with the mocked brokers only.

WaitUntilAllMessagesAreConsumedAsync(bool, params string[])

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

ValueTask WaitUntilAllMessagesAreConsumedAsync(bool throwTimeoutException, params string[] endpointNames)

Parameters

throwTimeoutException bool
A value specifying whether a <xref href="System.TimeoutException" data-throw-if-not-resolved="false"></xref> has to be thrown when the messages aren't consumed before the

timeout elapses.

endpointNames string[]

The names of the endpoints to wait for. If not specified, all endpoints are considered.

Returns

ValueTask

A ValueTask that completes when all messages have been processed.

Remarks

This method works with the mocked brokers only.

WaitUntilAllMessagesAreConsumedAsync(bool, CancellationToken, params string[])

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

ValueTask WaitUntilAllMessagesAreConsumedAsync(bool throwTimeoutException, CancellationToken cancellationToken, params string[] endpointNames)

Parameters

throwTimeoutException bool

A value specifying whether a TimeoutException has to be thrown when the messages aren't consumed before the CancellationToken is canceled.

cancellationToken CancellationToken

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

endpointNames string[]

The names of the endpoints to wait for. If not specified, all endpoints are considered.

Returns

ValueTask

A ValueTask that completes when all messages have been processed.

Remarks

This method works with the mocked brokers only.

WaitUntilAllMessagesAreConsumedAsync(TimeSpan?, params string[])

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

ValueTask WaitUntilAllMessagesAreConsumedAsync(TimeSpan? timeout, params string[] endpointNames)

Parameters

timeout TimeSpan?

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

endpointNames string[]

The names of the endpoints to wait for. If not specified, all endpoints are considered.

Returns

ValueTask

A ValueTask that completes when all messages have been processed.

Remarks

This method works with the mocked brokers only.

WaitUntilAllMessagesAreConsumedAsync(params string[])

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

ValueTask WaitUntilAllMessagesAreConsumedAsync(params string[] endpointNames)

Parameters

endpointNames string[]

The names of the endpoints to wait for. If not specified, all endpoints are considered.

Returns

ValueTask

A ValueTask that completes when all messages have been processed.

Remarks

This method works with the mocked brokers only.

WaitUntilAllMessagesAreConsumedAsync(CancellationToken, params string[])

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

ValueTask WaitUntilAllMessagesAreConsumedAsync(CancellationToken cancellationToken, params string[] endpointNames)

Parameters

cancellationToken CancellationToken

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

endpointNames string[]

The names of the endpoints to wait for. If not specified, all endpoints are considered.

Returns

ValueTask

A ValueTask that completes when all messages have been processed.

Remarks

This method works with the mocked brokers only.

WaitUntilConnectedAsync(bool, TimeSpan?)

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

ValueTask WaitUntilConnectedAsync(bool throwTimeoutException, TimeSpan? timeout = null)

Parameters

throwTimeoutException bool

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

timeout TimeSpan?

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

Returns

ValueTask

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

WaitUntilConnectedAsync(bool, CancellationToken)

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

ValueTask WaitUntilConnectedAsync(bool throwTimeoutException, CancellationToken cancellationToken)

Parameters

throwTimeoutException bool
A value specifying whether a <xref href="System.TimeoutException" data-throw-if-not-resolved="false"></xref> has to be thrown when the connection isn't established before the

CancellationToken is canceled.

cancellationToken CancellationToken

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

Returns

ValueTask

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

WaitUntilConnectedAsync(TimeSpan?)

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

ValueTask WaitUntilConnectedAsync(TimeSpan? timeout = null)

Parameters

timeout TimeSpan?

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

Returns

ValueTask

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

WaitUntilConnectedAsync(CancellationToken)

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

ValueTask WaitUntilConnectedAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

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

Returns

ValueTask

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

WaitUntilOutboxIsEmptyAsync(TimeSpan?)

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

ValueTask WaitUntilOutboxIsEmptyAsync(TimeSpan? timeout = null)

Parameters

timeout TimeSpan?

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

Returns

ValueTask

A ValueTask that completes when the outbox is empty.

WaitUntilOutboxIsEmptyAsync(CancellationToken)

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

ValueTask WaitUntilOutboxIsEmptyAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

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

Returns

ValueTask

A ValueTask that completes when the outbox is empty.