Class ProtoShapeAssertion

Namespace
ProtoTest.Json
Assembly
ProtoTest.Json.dll

The one traced shape assertion REST, GraphQL, gRPC and messaging share. It records the assert.json.shape operation with the expected and actual JSON, the matched properties or every mismatch, captures the expected shape when the protocol asks for it, and fails the operation before rethrowing, so the evidence is in the trace even when the test fails.

public static class ProtoShapeAssertion
Inheritance
ProtoShapeAssertion
Inherited Members

Methods

Assert(ProtoShapeAssertionContext, string?, object?, JsonSerializerOptions?, JsonDiagnosticOptions?, Func<IReadOnlyList<string>, ProtoObservation?>?)

Matches actualJson against expectedShape and records the assertion on Execution. A null execution still matches and throws, untraced. A null expectedShape expects JSON null, matching the matcher's documented null expectations. On success observation builds the protocol's observation from the matched properties; returning null records none. A mismatch fails the operation and rethrows the shape exception. Returns the matched property paths.

public static IReadOnlyList<string> Assert(ProtoShapeAssertionContext context, string? actualJson, object? expectedShape, JsonSerializerOptions? options = null, JsonDiagnosticOptions? diagnosticOptions = null, Func<IReadOnlyList<string>, ProtoObservation?>? observation = null)

Parameters

context ProtoShapeAssertionContext
actualJson string
expectedShape object
options JsonSerializerOptions
diagnosticOptions JsonDiagnosticOptions
observation Func<IReadOnlyList<string>, ProtoObservation>

Returns

IReadOnlyList<string>