Table of Contents

Class SseEventsInOrderAssertion

Namespace
SseAssertions.TUnit
Assembly
SseAssertions.TUnit.dll

Fluent TUnit assertion that verifies a Server-Sent Events stream contains a named sequence of events in order. Constructed by the TUnit source generator from the HasSseEventsInOrder(params string[]) extension on string; the WithStrictOrdering() chain method tightens the assertion to require the named events to appear contiguously.

[AssertionExtension("HasSseEventsInOrder")]
public sealed class SseEventsInOrderAssertion : Assertion<string>, IAssertion
Inheritance
Assertion<string>
SseEventsInOrderAssertion
Implements
IAssertion
Inherited Members
Assertion<string>.AssertAsync()
Assertion<string>.GetAwaiter()
Assertion<string>.And
Assertion<string>.Or

Remarks

Default (non-strict) mode: each named event must appear in the given order; other events may appear between them. Strict mode: the named events must appear contiguously with no other events between them. An empty eventNames array trivially passes; callers should pass at least one name for the assertion to be meaningful.

Constructors

SseEventsInOrderAssertion(AssertionContext<string>, string[])

Initialises the assertion. Called by the TUnit source generator.

[SuppressMessage("Performance", "MA0109:Consider adding an overload with a Span<T> or Memory<T>", Justification = "Public assertion constructor consumed by TUnit's source-generated chain extension. Allocation per assertion-build is negligible.")]
public SseEventsInOrderAssertion(AssertionContext<string> context, string[] eventNames)

Parameters

context AssertionContext<string>

The assertion context supplied by TUnit.

eventNames string[]

The event-type names expected in order. Matched case-sensitively against EventName.

Exceptions

ArgumentNullException

eventNames is null.

Methods

CheckAsync(EvaluationMetadata<string>)

Implements the specific check logic for this assertion. Called after the context has been evaluated. Override this method if your assertion uses the default AssertAsync() flow. If you override AssertAsync() with custom logic (like AndAssertion/OrAssertion), you don't need to implement this.

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<string> metadata)

Parameters

metadata EvaluationMetadata<string>

Metadata about the evaluation including value, exception, and timing information

Returns

Task<AssertionResult>

The result of the assertion check

GetExpectation()

Gets a human-readable description of what this assertion expects. Used in error messages.

protected override string GetExpectation()

Returns

string

WithStrictOrdering()

Tightens the assertion to require the named events to appear contiguously, with no other events between them.

public SseEventsInOrderAssertion WithStrictOrdering()

Returns

SseEventsInOrderAssertion

This assertion for chaining.