Table of Contents

Class SseFailureMessage

Namespace
SseAssertions
Assembly
SseAssertions.dll

Curated factory methods for SSE assertion failure messages. Exposed as the v0.1.0+ extension point for consumer-authored typed SSE assertions: a consumer who writes their own [GenerateAssertion]-tagged extension can compose these factories to produce failure messages whose shape matches the shipped chain terminators.

public static class SseFailureMessage
Inheritance
SseFailureMessage
Inherited Members

Remarks

All factories return culture-invariant strings using InvariantCulture for any numeric formatting. Truncation rules are consistent across factories: per-event Data fields are truncated at 80 characters with a trailing (U+2026 HORIZONTAL ELLIPSIS); body-context excerpts in ParseFailure(string) and the partialBodyExcerpt argument of CancellationCutRead(int, int, string) are truncated at 256 characters with the same suffix.

The factories mirror the JsonAssertions.JsonFailureMessage and MathAssertions.MathFailureMessage patterns in sibling family packages.

Methods

CancellationCutRead(int, int, string)

Produces the failure message for a cancelled read whose partial buffer did not satisfy the chain.

public static string CancellationCutRead(int bytesReceived, int eventsParsed, string partialBodyExcerpt)

Parameters

bytesReceived int

The number of bytes received before cancellation fired.

eventsParsed int

The number of fully-terminated events the parser recovered from the partial buffer.

partialBodyExcerpt string

The first 256 characters of the partial buffer (truncated with a trailing when longer).

Returns

string

A failure message describing the cancellation-bounded read result.

Exceptions

ArgumentNullException

partialBodyExcerpt is null.

DataDeserializationFailed(string, string, Exception)

Produces the failure message for an exception thrown by the data deserializer.

public static string DataDeserializationFailed(string eventName, string data, Exception inner)

Parameters

eventName string

The event-type name the chain asked for.

data string

The raw Data value the deserializer was applied to (truncated at 80 characters).

inner Exception

The exception the deserializer threw.

Returns

string

A failure message including the exception type, message, and the offending (truncated) data value.

Exceptions

ArgumentNullException

Any of eventName, data, or inner is null.

DataPredicateNotMatched(string, IReadOnlyList<string>)

Produces the failure message for "data predicate did not match any event".

public static string DataPredicateNotMatched(string eventName, IReadOnlyList<string> dataValues)

Parameters

eventName string

The event-type name the chain asked for.

dataValues IReadOnlyList<string>

The Data values of every event of the requested type observed in the stream (each rendered truncated at 80 characters).

Returns

string

A failure message listing every observed Data value so the consumer can see why the predicate did not match.

Exceptions

ArgumentNullException

eventName or dataValues is null.

EventCountMismatch(string, int, int, SseCountComparison)

Produces the failure message for an event-count terminator failure.

public static string EventCountMismatch(string eventName, int expected, int actual, SseCountComparison comparison)

Parameters

eventName string

The event-type name the chain asked for.

expected int

The expected count (the value passed to the terminator).

actual int

The actual matching-event count observed.

comparison SseCountComparison

The comparison label the chain used.

Returns

string

A failure message describing the count mismatch.

Exceptions

ArgumentNullException

eventName is null.

EventNotFound(string, IReadOnlyList<SseEvent>)

Produces the failure message for "no event of the requested name was found".

public static string EventNotFound(string eventName, IReadOnlyList<SseEvent> available)

Parameters

eventName string

The event-type name the chain asked for.

available IReadOnlyList<SseEvent>

The full list of events observed in the stream (rendered for diagnosis; per-event Data truncated at 80 characters).

Returns

string

A failure message listing every observed event so the consumer can see why the requested event was not found.

Exceptions

ArgumentNullException

eventName or available is null.

IdNotMatched(string, string, IReadOnlyList<string?>)

Produces the failure message for "no event of the requested type carried the expected id:".

public static string IdNotMatched(string eventName, string expectedId, IReadOnlyList<string?> idValues)

Parameters

eventName string

The event-type name the chain asked for.

expectedId string

The id: value the chain required.

idValues IReadOnlyList<string>

The Id values of every event of the requested type observed in the stream (null entries represent frames without an id: directive).

Returns

string

A failure message listing every observed Id value so the consumer can see why none carried the expected id.

Exceptions

ArgumentNullException

eventName, expectedId, or idValues is null.

ParseFailure(string)

Produces the failure message for an SSE body that could not be parsed.

public static string ParseFailure(string body)

Parameters

body string

The body that failed to parse. Embedded in the message, truncated at 256 characters with a trailing .

Returns

string

A failure message describing the parse failure with the truncated body excerpt.

Exceptions

ArgumentNullException

body is null.

RetryMillisPredicateNotMatched(string, IReadOnlyList<int?>)

Produces the failure message for a retry-millis predicate failure.

public static string RetryMillisPredicateNotMatched(string eventName, IReadOnlyList<int?> retryValues)

Parameters

eventName string

The event-type name the chain asked for.

retryValues IReadOnlyList<int?>

The RetryMillis values observed on every event of the requested type (null entries represent frames without a retry: directive).

Returns

string

A failure message listing every observed retry value so the consumer can see why the predicate did not match.

Exceptions

ArgumentNullException

eventName or retryValues is null.

UncleanCancellation(Exception)

Produces the failure message for a stream that did not tear down cleanly when its read was cancelled: a transport exception surfaced instead of cooperative cancellation.

public static string UncleanCancellation(Exception exception)

Parameters

exception Exception

The exception that surfaced from the cancelled read.

Returns

string

A failure message naming the exception type and message.

Exceptions

ArgumentNullException

exception is null.

UnexpectedContentType(string?)

Produces the failure message for an HTTP response whose Content-Type was not text/event-stream.

public static string UnexpectedContentType(string? actualContentType)

Parameters

actualContentType string

The actual Content-Type media type observed on the response, or null when no Content-Type header was present.

Returns

string

A failure message naming the expected SSE content type and the actual response content type.