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
namestringThe 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
namestringThe non-empty header name matched without regard to case.
expectedValuestringThe 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
predicateFunc<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.
optionsJsonSerializerOptionsDeserialization 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
TThe 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
expectedTThe value serialized immediately and compared structurally with the recorded JSON payload. It is not retained or owned and may be null.
optionsJsonSerializerOptionsSerialization 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
TThe type of expected value serialized for comparison.
Exceptions
- RecordedMessageVerificationException
The JSON values differ structurally. The exception message includes both payloads without automatic redaction.