Precept.Api
0.11.1
dotnet add package Precept.Api --version 0.11.1
NuGet\Install-Package Precept.Api -Version 0.11.1
<PackageReference Include="Precept.Api" Version="0.11.1" />
<PackageVersion Include="Precept.Api" Version="0.11.1" />
<PackageReference Include="Precept.Api" />
paket add Precept.Api --version 0.11.1
#r "nuget: Precept.Api, 0.11.1"
#:package Precept.Api@0.11.1
#addin nuget:?package=Precept.Api&version=0.11.1
#tool nuget:?package=Precept.Api&version=0.11.1
Precept.Api
HTTP API testing for Precept: a fluent request builder, response assertions, and automatic logging of every request and response into the test's report.
dotnet add package Precept.Api
services.AddPreceptApi();
var response = await Rest.Post("/orders")
.WithJsonBody(new { sku = "ABC", quantity = 2 })
.SendAsync();
await Assert.That(response).ToBeSuccessfulAsync();
await Assert.That(response).ToHaveJsonValueAsync("status", "created");
await Assert.That(response).JsonAt("customer.email").ToEndWithAsync("@example.com");
await Assert.That(response).Json<Order>().ToSatisfyAsync(o => o.Lines.Count == 2, "have two lines");
Every failure carries the request line and the response body, because that is always the next question.
The response assertions are ToHaveStatusAsync, ToBeSuccessfulAsync, ToHaveHeaderAsync,
ToContainAsync, ToHaveJsonValueAsync, ToHaveXmlValueAsync and ToRespondWithinAsync.
JsonAt, Json<T>, XmlAt and Xml<T> narrow to a part of the response so the general
assertions apply to it. For an XML API, WithXmlBody writes a [DataContract] type and XmlAt
takes an XPath whose prefixes are declared in Api:XmlNamespaces.
Polling for a state that arrives later uses the same sentence under Assert.Eventually:
await Assert.Eventually(() => Rest.Get($"/jobs/{id}").SendAsync())
.Within(TimeSpan.FromMinutes(2))
.ToHaveJsonValueAsync("state", "Completed");
Part of Precept, a .NET 10 test framework built on Microsoft.Testing.Platform. Full documentation: assertions on a response · XML · waiting · configuration
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Microsoft.Extensions.Configuration (>= 10.0.12)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.12)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.12)
- Microsoft.Extensions.Configuration.Json (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Precept.Core (>= 0.11.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.11.1 | 0 | 9/16/2026 |
| 0.11.0 | 29 | 9/15/2026 |
| 0.10.0 | 90 | 9/10/2026 |
| 0.8.0 | 86 | 9/10/2026 |
| 0.7.0 | 94 | 9/9/2026 |
| 0.6.0 | 90 | 9/2/2026 |
| 0.5.1 | 93 | 9/2/2026 |
| 0.5.0 | 96 | 9/1/2026 |
| 0.4.1 | 97 | 8/16/2026 |
| 0.4.0 | 107 | 8/16/2026 |
| 0.3.0 | 95 | 8/15/2026 |
| 0.2.0 | 95 | 8/15/2026 |
| 0.1.3 | 91 | 8/13/2026 |
| 0.1.2 | 102 | 8/13/2026 |
| 0.1.1 | 99 | 8/13/2026 |
| 0.1.0 | 100 | 8/12/2026 |