Table of Contents

Class SseEventIdsAssertion

Namespace
SseAssertions.TUnit
Assembly
SseAssertions.TUnit.dll

Fluent TUnit assertion that every Server-Sent Events frame in a wire-format string carries an id:, and, with StrictlyIncreasing() or Sequential(), that the ids are integers in that order (the property a Last-Event-ID reconnection relies on). Until(eventName) ends the window at a named event. The failure lists the ids seen. Constructed by the TUnit source generator from the HasSseEventIds extension on string.

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

Remarks

The receiver is parsed with Parse(string); the check stops at the first violation, as the streaming chains do, so every receiver gives the same verdict.

Constructors

SseEventIdsAssertion(AssertionContext<string>)

Initializes the assertion. Called by the TUnit source generator.

public SseEventIdsAssertion(AssertionContext<string> context)

Parameters

context AssertionContext<string>

The assertion context supplied by TUnit.

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

Sequential()

Requires the ids to be integers, each one more than the one before, from any first id.

public SseEventIdsAssertion Sequential()

Returns

SseEventIdsAssertion

This assertion for chaining.

Sequential(long)

Requires the ids to be integers, each one more than the one before, starting at startingAt.

public SseEventIdsAssertion Sequential(long startingAt)

Parameters

startingAt long

The id of the first event.

Returns

SseEventIdsAssertion

This assertion for chaining.

StrictlyIncreasing()

Requires the ids to be integers, each greater than the one before.

public SseEventIdsAssertion StrictlyIncreasing()

Returns

SseEventIdsAssertion

This assertion for chaining.

Until(string)

Ends the observation window after the first event of type eventName: only the events up to and including it are checked. When the body has no such event, the whole body is the window.

public SseEventIdsAssertion Until(string eventName)

Parameters

eventName string

The event-type name that ends the window. Matched case-sensitively.

Returns

SseEventIdsAssertion

This assertion for chaining.

Exceptions

ArgumentNullException

eventName is null.