v0.6.0
[0.6.0] - 2026-07-11: JSON subset matching and typed extraction
Minor release. Adds subset (contains) assertions and typed value extraction. Purely additive.
Added
Assert.That(actual).ContainsJson(expectedSubset)asserts 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 ofIsEquivalentJsonTo(full equality), for the common case where a response carries fields a test does not want to pin. A JSONstring, aJsonElement, and anHttpResponseMessage(body read with a flowedCancellationToken) are accepted as the actual value; the expected subset is a JSONstring. Matching is independent of object-property order and number form. An expected array asserts a positional prefix (the actual array may be longer);IgnoreArrayOrder()matches expected elements against the actual array as a multiset subset, andIgnorePath(...)excludes a path, both through the configure overload. On failure the message lists every missing or mismatched path in one report, each with its category and a rendered view of both sides, so a single run enumerates every field that is wrong.JsonEquivalence.ContainsAll(expected, actual, options)(framework-agnostic core) exposes the subset comparison directly over JSON strings orJsonElements, returning everyJsonDifferencefound (empty when the actual document contains the subset).JsonFailureMessage.ContainsMismatch(differences)renders the multi-difference failure text.GetJsonValue<T>(path),GetJsonString(path), andGetJsonElement(path)read a typed value out of a JSON document at a path and return it, for a test that needs the value (pulling an id to drive the next request, reading a count to cross-check an array length) rather than an assertion.GetJsonValue<T>parses the value as anyIParsable<T>(int/long/bool/Guid/DateTimeOffset, ...) from a JSON string or a JSON number literal, usingCultureInfo.InvariantCulture;GetJsonElementreturns a detached copy that stays valid after the source document is disposed. Each is available over a JSONstring, aJsonElement, and (asGetJsonValueAsync/GetJsonStringAsync/GetJsonElementAsync) anHttpResponseMessage. A failure to resolve the path, convert the value, or parse the source throwsJsonExtractionExceptionwith the same path-context message the assertions render, replacing a hand-rolledJsonDocument.Parse(...).GetProperty(...).GetInt32()chain and its bare BCL exceptions.