Class RecordedMessageAssertions

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

Fluently verifies one recorded message.

public sealed class RecordedMessageAssertions
Inheritance
RecordedMessageAssertions
Inherited Members
Extension Methods

Methods

HaveHeader(string)

Requires the message to contain the supplied header.

public RecordedMessageAssertions HaveHeader(string name)

Parameters

name string

The non-empty header name matched without regard to case.

Returns

RecordedMessageAssertions

This message assertion object so additional checks can be chained.

Exceptions

RecordedMessageVerificationException

The header is absent.

HaveHeader(string, string)

Requires the message to contain the supplied header value.

public RecordedMessageAssertions HaveHeader(string name, string expectedValue)

Parameters

name string

The non-empty header name matched without regard to case.

expectedValue string

The non-null value compared using ordinal, case-sensitive comparison. An empty value is accepted. Failed assertions include expected and actual values without redaction.

Returns

RecordedMessageAssertions

This message assertion object so additional checks can be chained.

Exceptions

RecordedMessageVerificationException

The header is absent or its value differs.

HavePayloadMatching<T>(Func<T?, bool>, JsonSerializerOptions?)

Requires the deserialized message payload to satisfy a predicate.

public RecordedMessageAssertions HavePayloadMatching<T>(Func<T?, bool> predicate, JsonSerializerOptions? options = null)

Parameters

predicate Func<T, bool>

The non-null, read-only predicate evaluated once against the deserialized payload, including null for a JSON null or a converter returning null.

options JsonSerializerOptions

Deserialization options, or null to use the bus's serializer options. Supplied options are read but not retained, owned, or mutated.

Returns

RecordedMessageAssertions

This message assertion object so additional checks can be chained.

Type Parameters

T

The target payload type; the recorded compile-time type name is not checked.

Remarks

Deserialization and predicate exceptions propagate unchanged. Failure messages include the unredacted payload.

Exceptions

RecordedMessageVerificationException

The payload does not satisfy the predicate.

HavePayload<T>(T, JsonSerializerOptions?)

Requires the message payload to structurally equal the supplied JSON value.

public RecordedMessageAssertions HavePayload<T>(T expected, JsonSerializerOptions? options = null)

Parameters

expected T

The value serialized immediately and compared structurally with the recorded JSON payload. It is not retained or owned and may be null.

options JsonSerializerOptions

Serialization options for expected, or null to use the recording bus's options. Supplied options are read but not owned, retained, or mutated.

Returns

RecordedMessageAssertions

This message assertion object so additional checks can be chained.

Type Parameters

T

The type of expected value serialized for comparison.

Exceptions

RecordedMessageVerificationException

The JSON values differ structurally. The exception message includes both payloads without automatic redaction.