Class TestingHelper<TBroker>
Exposes some helper methods and shortcuts to simplify testing.
Implements
Inherited Members
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 sourceTestingHelper(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 |
Properties
| Improve this doc View sourceBroker
Gets the current IBroker instance.
Declaration
public TBroker Broker { get; }
Property Value
Type | Description |
---|---|
TBroker |
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 sourceIsOutboxEmptyAsync()
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
|
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.
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.
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. |
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. |
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. |