Table of Contents

Namespace JsonAssertions.TUnit

Classes

HasJsonTypeInfoForAssertion<T>

The assertion produced by HasJsonTypeInfoFor<T>(IJsonContextAssertionSource). Holds the type whose registration is checked as a method-level generic and resolves to passed when GetTypeInfo(Type) returns a non-null JsonTypeInfo<T>.

HttpResponseMessageAssertions

Fluent TUnit entry points that apply the JSON assertions directly to an HttpResponseMessage: the response body is read as text and the assertion runs against it, so a test can write await Assert.That(response).HasJsonProperty("user.name", ct) without a separate read-and-parse step. This is the assertion family's first-class HTTP entry point; reading an HTTP response body is the dominant way JSON reaches a test.

JsonContainsAssertions

Fluent TUnit entry points for asserting that a JSON document contains an expected subset: every property in the expected document must be present in the actual document with an equivalent value (recursively), while the actual document may carry additional properties. This is the subset counterpart of IsEquivalentJsonTo(string, string) (full equality); it collapses a block of per-property HasJsonProperty / HasJsonValue checks into one declarative assertion whose failure lists every field that is missing or wrong. Matching is independent of object-property order and of the lexical form of numbers (1, 1.0, and 1e0 are equal); an expected array asserts a positional prefix (the actual array may be longer) unless IgnoreArrayOrder() is enabled through the configure callback, and any path registered with IgnorePath(string) is excluded. Each method is generated into a TUnit assertion chain via the [GenerateAssertion] source generator and delegates to ContainsAll(JsonElement, JsonElement, JsonEquivalenceOptions) in the framework-agnostic core. Both a JSON string and a JsonElement are accepted as the asserted value; the expected subset is supplied as a JSON string.

JsonContextAssertions

Fluent TUnit entry points for asserting the registration state of a JsonSerializerContext. AOT-clean (the context's own type registry is the authoritative source; no reflection over the asserted type needed) and STJ-shaped.

JsonEquivalenceAssertions

Fluent TUnit entry points for asserting that a JSON document is structurally equivalent to an expected one. Equivalence is independent of object-property order and of the lexical form of numbers (1, 1.0, and 1e0 are equal); arrays are position-sensitive unless IgnoreArrayOrder() is enabled through the configure callback, and any path registered with IgnorePath(string) is excluded. Each method is generated into a TUnit assertion chain via the [GenerateAssertion] source generator and delegates to JsonEquivalence in the framework-agnostic core. Both a JSON string and a JsonElement are accepted as the asserted value; the expected document is supplied as a JSON string.

JsonPropertyAssertions

Fluent TUnit entry points for asserting the presence or absence of a property at a dot-separated JSON path. Each method is generated into a TUnit assertion chain via the [GenerateAssertion] source generator and delegates to JsonPath in the framework-agnostic core. Both a JSON string and a JsonElement are accepted as the asserted value.

JsonRoundtripAssertions

Fluent assertion that a typed value round-trips cleanly through STJ source-gen via the consumer's JsonTypeInfo<T>. Catches the common "we added a property and forgot to update the JsonSerializerContext" regression class: a missing [JsonSerializable(typeof(T))] entry or a property the context doesn't know about causes the round-trip to produce a different JSON string than the original.

JsonShapeAssertions

Fluent TUnit entry points for asserting the shape of the value at a dot-separated JSON path: that it is a JSON array of a given length (or non-empty, or empty), or that it is of a given JsonValueKind. Each method is generated into a TUnit assertion chain via the [GenerateAssertion] source generator and delegates to JsonPath and JsonShape in the framework-agnostic core. Both a JSON string and a JsonElement are accepted as the asserted value.

JsonValueAssertions

Fluent TUnit entry points for asserting the value at a dot-separated JSON path. Each method is generated into a TUnit assertion chain via the [GenerateAssertion] source generator and delegates to JsonPath and JsonValueComparison in the framework-agnostic core. Both a JSON string and a JsonElement are accepted as the asserted value; the expected value may be a string, a bool, or a number. The integer overloads (int / uint / long / ulong) each match the value whether the JSON encodes it as a number or as a numeric string, because the encoding depends on the serializer (System.Text.Json writes a number; Protobuf's JsonFormatter can emit a string, and serializes 64-bit ints as strings to avoid 53-bit precision loss); the double overload matches a JSON number.

Interfaces

IJsonContextAssertionSource

Covariant-style bridge interface used by JSON-context assertions to escape the C# partial generic inference limit when the underlying assertion-source generic is a closed subtype of JsonSerializerContext.