Interface IJsonContextAssertionSource
- Namespace
- JsonAssertions.TUnit
- Assembly
- JsonAssertions.TUnit.dll
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.
public interface IJsonContextAssertionSource
- Extension Methods
Remarks
The TUnit invariant IAssertionSource<TContext> binds at the concrete subtype
of JsonSerializerContext the consumer wrote, e.g. IAssertionSource<MyContext>.
A natural assertion like HasJsonTypeInfoFor<MyDto>() would force the consumer to
specify both type arguments at the call site (HasJsonTypeInfoFor<MyDto, MyContext>())
because C# does not allow partial inference: either all method-level type arguments are
supplied or none are.
This interface is the receiver type for the JSON-context assertion family. The bridge
extension AsJsonContext<TContext>(IAssertionSource<TContext>)
wraps an invariant IAssertionSource<TContext> into an IJsonContextAssertionSource
whose Context is statically typed at JsonSerializerContext. The
upcast is performed at construction time via the existing TUnit context mapping; no
reflection is used and the path stays AOT-clean.
Call site shape consumers see:
await Assert.That(MyContext.Default).AsJsonContext().HasJsonTypeInfoFor<MyDto>();
Properties
Context
The TUnit assertion context viewed at the JsonSerializerContext base type. All JSON-context-family assertions execute against this context.
AssertionContext<JsonSerializerContext> Context { get; }
Property Value
- AssertionContext<JsonSerializerContext>