Class RecordedMessageBusAssertions

Namespace
XBullet.EasyTesting.Messaging
Assembly
XBullet.EasyTesting.Messaging.dll

Fluently verifies messages captured by a recording bus.

public sealed class RecordedMessageBusAssertions
Inheritance
RecordedMessageBusAssertions
Inherited Members
Extension Methods

Remarks

Each assertion takes a new point-in-time snapshot. Predicates run outside the recorder lock; their exceptions propagate unchanged. Chained assertions may observe different snapshots.

Methods

Contain(Func<RecordedMessage, bool>)

Requires at least one recorded message to satisfy a predicate.

public RecordedMessageBusAssertions Contain(Func<RecordedMessage, bool> predicate)

Parameters

predicate Func<RecordedMessage, bool>

The non-null, read-only predicate evaluated in append order until a match is found.

Returns

RecordedMessageBusAssertions

This bus assertion object so additional checks can be chained.

Exceptions

RecordedMessageVerificationException

No message satisfies the predicate.

ContainSingle(Func<RecordedMessage, bool>)

Requires exactly one recorded message to satisfy a predicate.

public RecordedMessageAssertions ContainSingle(Func<RecordedMessage, bool> predicate)

Parameters

predicate Func<RecordedMessage, bool>

The non-null, read-only predicate evaluated once per message in append order.

Returns

RecordedMessageAssertions

A new assertion object bound to the matching message and the bus's serializer options.

Exceptions

RecordedMessageVerificationException

Zero or multiple messages satisfy the predicate.

ContainSingle(string, string)

Requires exactly one message for the supplied transport and destination.

public RecordedMessageAssertions ContainSingle(string transport, string destination)

Parameters

transport string

The non-empty transport identifier matched without regard to case.

destination string

The non-empty destination matched using ordinal, case-sensitive comparison.

Returns

RecordedMessageAssertions

A new assertion object bound to the single matching message and the bus's serializer options.

Exceptions

RecordedMessageVerificationException

The point-in-time message snapshot contains zero or multiple matches.

HaveCount(int)

Requires exactly the supplied number of recorded messages.

public RecordedMessageBusAssertions HaveCount(int expected)

Parameters

expected int

The non-negative message count required at assertion time.

Returns

RecordedMessageBusAssertions

This bus assertion object so additional checks can be chained.

Exceptions

RecordedMessageVerificationException

The current message count does not equal expected.

HaveCount(string, string, int)

Requires exactly the supplied number of messages for one route.

public RecordedMessageBusAssertions HaveCount(string transport, string destination, int expected)

Parameters

transport string

The non-empty transport identifier matched without regard to case.

destination string

The non-empty destination matched using ordinal, case-sensitive comparison.

expected int

The non-negative count of matching messages required.

Returns

RecordedMessageBusAssertions

This bus assertion object so additional checks can be chained.

Exceptions

RecordedMessageVerificationException

The route count differs from the expected count.

HaveSequence(params Func<RecordedMessage, bool>[])

Requires the entire recorded collection to match an exact ordered sequence of predicates.

public RecordedMessageBusAssertions HaveSequence(params Func<RecordedMessage, bool>[] expectations)

Parameters

expectations Func<RecordedMessage, bool>[]

Non-null predicates, one per expected message in append order. The array is copied before evaluation. An empty sequence requires an empty recorder.

Returns

RecordedMessageBusAssertions

This bus assertion object so additional checks can be chained.

Remarks

Order reflects completed recording, not concurrent publish-call start order or broker delivery order.

Exceptions

RecordedMessageVerificationException

The count or a positional predicate does not match.

HaveSequence(string, string, params Func<RecordedMessage, bool>[])

Requires one route's messages to match an exact ordered sequence of predicates.

public RecordedMessageBusAssertions HaveSequence(string transport, string destination, params Func<RecordedMessage, bool>[] expectations)

Parameters

transport string

The non-empty transport identifier matched without regard to case.

destination string

The non-empty destination matched using ordinal, case-sensitive comparison.

expectations Func<RecordedMessage, bool>[]

Non-null predicates, one per expected route message in append order. The array is copied before evaluation. An empty sequence requires no messages for the route.

Returns

RecordedMessageBusAssertions

This bus assertion object so additional checks can be chained.

Remarks

Other routes are ignored. Order reflects completed recording, not broker delivery order.

Exceptions

RecordedMessageVerificationException

The route count or a positional predicate does not match.

NotContain(Func<RecordedMessage, bool>)

Requires no recorded message to satisfy a predicate.

public RecordedMessageBusAssertions NotContain(Func<RecordedMessage, bool> predicate)

Parameters

predicate Func<RecordedMessage, bool>

The non-null, read-only predicate evaluated in append order until a match is found.

Returns

RecordedMessageBusAssertions

This bus assertion object so additional checks can be chained.

Remarks

Only the current snapshot is checked. Wait for known background-work completion before asserting absence.

Exceptions

RecordedMessageVerificationException

A message satisfies the predicate.

NotContain(string, string)

Requires no recorded messages for one route.

public RecordedMessageBusAssertions NotContain(string transport, string destination)

Parameters

transport string

The non-empty transport identifier matched without regard to case.

destination string

The non-empty destination matched using ordinal, case-sensitive comparison.

Returns

RecordedMessageBusAssertions

This bus assertion object so additional checks can be chained.

Remarks

Only the current snapshot is checked. Wait for known background-work completion before asserting absence.

Exceptions

RecordedMessageVerificationException

At least one message exists for the route.