Class MockEndpoint

Assembly: redb.Route.dll

Mock endpoint. Captures received exchanges for testing.

public class MockEndpoint : EndpointBase<MockEndpointOptions>, IEndpoint, IEndpointStatistics

Inheritance

Object→MockEndpointOptions}→MockEndpoint

Implements

Properties

ExpectedMessageCount

Gets the expected message count (from options).

public int ExpectedMessageCount { get; }

ReceivedCount

Gets the number of received exchanges.

public int ReceivedCount { get; }

ReceivedExchanges

Gets all received exchanges in order.

public IReadOnlyList<IExchange> ReceivedExchanges { get; }

Methods

AssertIsNotSatisfiedAsync(TimeSpan, CancellationToken)

Waits the full timeout, then throws if the expectations turned out to be satisfied.

public Task AssertIsNotSatisfiedAsync(TimeSpan timeout, CancellationToken ct = default)

AssertIsSatisfiedAsync(TimeSpan, CancellationToken)

Waits up to timeout for every expectation to hold, then throws

public Task AssertIsSatisfiedAsync(TimeSpan timeout, CancellationToken ct = default)

CreateConsumer(IProcessor)

Creates a consumer for receiving messages from this endpoint.

public override IConsumer CreateConsumer(IProcessor processor)

CreateProducer()

Creates a producer for sending messages to this endpoint.

public override IProducer CreateProducer()

Expect(Func<IExchange, bool>, string?)

Expects predicate to hold on every message.

public MockEndpoint Expect(Func<IExchange, bool> predicate, string? description = null)

Expect(IPredicate, string?)

Expects predicate to hold on every message (awaited, so async predicates work).

public MockEndpoint Expect(IPredicate predicate, string? description = null)

Expect(string)

Expects the route-language condition ("header.priority == 'high' and body.total > 100")

public MockEndpoint Expect(string condition)

ExpectBodies(params object?[])

Expects exactly these bodies, in this order (numbers compare across CLR types).

public MockEndpoint ExpectBodies(params object?[] bodies)

ExpectBodiesInAnyOrder(params object?[])

Expects exactly these bodies, in any order.

public MockEndpoint ExpectBodiesInAnyOrder(params object?[] bodies)

ExpectHeader(string, object?)

Expects every message to carry header name equal to value.

public MockEndpoint ExpectHeader(string name, object? value)

ExpectHeaderReceived(string, object?)

Expects at least one message to carry header name equal to value.

public MockEndpoint ExpectHeaderReceived(string name, object? value)

ExpectMessageCount(int)

Expects exactly count messages.

public MockEndpoint ExpectMessageCount(int count)

ExpectMinimumMessageCount(int)

Expects at least count messages.

public MockEndpoint ExpectMinimumMessageCount(int count)

ExpectProperty(string, object?)

Expects every message to carry exchange property key equal to value.

public MockEndpoint ExpectProperty(string key, object? value)

IsSatisfiedAsync()

Returns true when every expectation currently holds (no waiting).

public Task<bool> IsSatisfiedAsync()

Reset()

Resets all captured exchanges, the latch counter, expectations and scripted responses.

public void Reset()

WaitForSatisfied(TimeSpan, CancellationToken)

Waits until the expected number of messages are received, or until timeout.

public Task<bool> WaitForSatisfied(TimeSpan timeout, CancellationToken ct = default)

Whenever(int)

Scripts what happens to the messageNumber-th message (1-based): reply body, delay, exception.

public MockResponse Whenever(int messageNumber)

WheneverAny()

Scripts what happens to every message.

public MockResponse WheneverAny()

Constructors