ProtoTest.Json
1.0.1
dotnet add package ProtoTest.Json --version 1.0.1
NuGet\Install-Package ProtoTest.Json -Version 1.0.1
<PackageReference Include="ProtoTest.Json" Version="1.0.1" />
<PackageVersion Include="ProtoTest.Json" Version="1.0.1" />
<PackageReference Include="ProtoTest.Json" />
paket add ProtoTest.Json --version 1.0.1
#r "nuget: ProtoTest.Json, 1.0.1"
#:package ProtoTest.Json@1.0.1
#addin nuget:?package=ProtoTest.Json&version=1.0.1
#tool nuget:?package=ProtoTest.Json&version=1.0.1
ProtoTest.Json
Partial JSON shape matching and JsonValue constraints, plus the diagnostics redaction engine — the matcher shared by REST, GraphQL, gRPC and messaging.
dotnet add package ProtoTest.Json
The package arrives transitively with ProtoTest.Rest and ProtoTest.GraphQL; reference it directly for a smaller integration that only needs the matcher.
Quick start
JsonShapeMatcher.AssertMatch(json, new
{
id = JsonValue.NotNull(),
name = JsonValue.StringContaining("Proto"),
score = JsonValue.Between(80, 100)
});
// A mismatch throws JsonShapeMismatchException with every mismatch attached.
try
{
JsonShapeMatcher.AssertMatch(json, new { status = "active" });
}
catch (JsonShapeMismatchException exception)
{
foreach (var mismatch in exception.Mismatches)
{
Console.WriteLine(mismatch);
}
}
What it adds
- Shape matcher —
JsonShapeMatcher.AssertMatch(string | JsonElement, expected, options?)returns the matched JSON paths; empty or invalid JSON throwsJsonDocumentAssertionException. - Matching rules — object shapes are partial, arrays are exact in length and position, property names are case-insensitive by default, and
[JsonPropertyName], naming policy and[JsonIgnore]are honoured. - Value constraints —
JsonValue.Any,NotNull,Null,Regex,StringContaining,StringStartingWith,StringEndingWith,StringMatching,GreaterThan,LessThan,Between,OneOfandMatching. - Shared traced assertion —
ProtoShapeAssertion.Assert(...)records theassert.json.shapeoperation with expected/actual shapes and the matched property list; consumers forward an observation on success. - Diagnostics —
JsonDiagnosticOptionsdefaults (RedactSensitiveData,MaxDiagnosticBodyLength,SensitiveJsonProperties) andJsonDiagnosticSanitizerused by the HTTP stack.
Extra JSON properties never fail a match, but arrays are length- and position-sensitive; numeric comparisons go through decimal/double, and describing an expected shape is capped at depth 16 and 4096 expanded containers.
Learn more
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ProtoTest.Core (>= 1.0.1)
-
net8.0
- ProtoTest.Core (>= 1.0.1)
-
net9.0
- ProtoTest.Core (>= 1.0.1)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on ProtoTest.Json:
| Package | Downloads |
|---|---|
|
ProtoTest.Http
Shared HTTP foundations for ProtoTest protocol integrations. |
|
|
ProtoTest.Messaging
Messaging integration for ProtoTest: publish and await messages with a predicate and timeout over a broker capability. |
|
|
ProtoTest.Rest
Runner-independent REST integration testing for ProtoTest. |
|
|
ProtoTest.GraphQL
Fluent, runner-independent GraphQL integration testing for ProtoTest. |
|
|
ProtoTest.Grpc
gRPC integration for ProtoTest: named channels, metadata authentication, unary and streaming helpers, tracing and coverage. |
GitHub repositories
This package is not used by any popular GitHub repositories.