XUnitAssured.Jsonata
6.43.0
dotnet add package XUnitAssured.Jsonata --version 6.43.0
NuGet\Install-Package XUnitAssured.Jsonata -Version 6.43.0
<PackageReference Include="XUnitAssured.Jsonata" Version="6.43.0" />
<PackageVersion Include="XUnitAssured.Jsonata" Version="6.43.0" />
<PackageReference Include="XUnitAssured.Jsonata" />
paket add XUnitAssured.Jsonata --version 6.43.0
#r "nuget: XUnitAssured.Jsonata, 6.43.0"
#:package XUnitAssured.Jsonata@6.43.0
#addin nuget:?package=XUnitAssured.Jsonata&version=6.43.0
#tool nuget:?package=XUnitAssured.Jsonata&version=6.43.0
XUnitAssured.Jsonata
JSONata expressions for XUnitAssured: select, transform and assert on the JSON a step returns.
var resposta = await Given(api).ApiResource("/pedidos").Post(pedido).ExecuteAsync();
var saida = resposta.GetResult().ToJsonObject(); // { status, headers, body }
JsonataExpression.AssertTrue("status = 201 and $exists(body.id)", saida);
var total = JsonataExpression.Evaluate("$sum(body.itens.(preco * qtd))", saida).Required("total");
var caros = JsonataExpression.Evaluate("body.itens[preco > 100].sku", saida).Value;
Variables are passed by name and read as $name:
JsonataExpression.AssertTrue("body.cliente.id = $clienteId", saida,
new Dictionary<string, JsonNode?> { ["clienteId"] = clienteId });
ToJsonObject() exists on the HTTP, Kafka and RabbitMQ results, with body in all three (the JSON of
the body when it is JSON, its text otherwise).
What this package adds to JSONata
- A time limit (5 s by default,
JsonataOptions.Timeout) and a recursion limit (250): a runaway expression fails the test instead of hanging it or crashing the process. $jwt(token): the claims of a JWT payload, without checking the signature.- Date formats are .NET formats (
yyyy-MM-dd), as in Jsonata.Net.Native. A picture in the XPath format of the JSONata docs ([Y0001]-[M01]-[D01]) in$fromMillis,$toMillisor$nowfails with an error that says so, instead of returning wrong text. Number formats ($formatNumber,$formatInteger,$parseInteger) are also .NET formats. - A variable cannot take the name of a function (
sum,count, ...): it would hide it.
Built on Jsonata.Net.Native.
| 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
- Jsonata.Net.Native (>= 3.0.0)
-
net8.0
- Jsonata.Net.Native (>= 3.0.0)
-
net9.0
- Jsonata.Net.Native (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
New in XUnitAssured.Camunda: CamundaHubClient, a client of the Camunda Hub (the Web Modeler) REST API, v1 and v2, with OAuth only: workspaces, projects, folders, files with their revision, and versions. No breaking changes. Release notes: https://github.com/andrewBezerra/xunit-assured-net/blob/main/docs/releases/6.43.0.md