Interface IProtoMessageConsumer
One test's view of a broker, created by CreateConsumerAsync(CancellationToken) during setup and disposed with the test's teardown. A consumer belongs to exactly one test: it must never be shared, and its disposal removes whatever the adapter declared for the test (queues, in RabbitMQ's case), so parallel tests on the same destination cannot steal each other's messages.
public interface IProtoMessageConsumer : IAsyncDisposable
- Inherited Members
- Extension Methods
Methods
AwaitAsync(string, Func<ProtoMessage, bool>, TimeSpan, CancellationToken)
Waits for the first message on destination matching predicate
within timeout. Only messages that reach this consumer count, so another test's
traffic on a shared broker can never satisfy the await.
ValueTask<ProtoMessage> AwaitAsync(string destination, Func<ProtoMessage, bool> predicate, TimeSpan timeout, CancellationToken cancellationToken = default)
Parameters
destinationstringpredicateFunc<ProtoMessage, bool>timeoutTimeSpancancellationTokenCancellationToken
Returns
PrepareAsync(IReadOnlyCollection<string>, CancellationToken)
Prepares the destinations this test intends to await before the system under test publishes, so a message published after this call is not missed. Adapters that keep history may treat it as a no-op.
ValueTask PrepareAsync(IReadOnlyCollection<string> destinations, CancellationToken cancellationToken = default)
Parameters
destinationsIReadOnlyCollection<string>cancellationTokenCancellationToken