Precept 0.10.0

Precept.Files

Excel, CSV, JSON and XML files for Precept tests: a workbook or a CSV written from a data table or a query result, a row appended to what the system under test already has, a file read back as rows, JSON and XML built, queried, changed in place and asserted on — every file a test writes landing in its artifacts and attached to its result.

dotnet add package Precept.Files
services.AddPreceptFiles();
// A Reqnroll DataTable's rows in, a spreadsheet out — the package never references Reqnroll:
// a row is anything dictionary-shaped, or an object whose properties are the columns.
var path = await Excel.WriteAsync("clients.xlsx", table.Rows, sheet: "Clients");

// A row appended under the columns the sheet already has, whatever their order:
using var export = Excel.Open("export.xlsx");
export.Sheet("Clients").AddRow(new { Name = "Acme", Email = "acme@example.test" });
await export.SaveAsync();

await Assert.That(export.Sheet("Clients")).ToContainRowsAsync(table.Rows);

var order = Json.New().Set("customer.id", 42).Set("lines", Json.Array(table.Rows));
await Assert.That(Json.Parse(response.Body).At("lines")).ToContainRowsAsync(table.Rows);

var shipment = Xml.Load("shipment.xml").WithDefaultNamespace("s");
await Assert.That(shipment).ToHaveValueAsync("/s:shipment/s:status", "accepted");

A sheet, a CSV file and a JSON array share one model — a header, rows under it by column name — and one set of row assertions. A bare file name is written into the running test's artifact directory — unique to the test, and one step from every report — and read from there first, then from beside the test binary. The ClosedXML worksheet, the JsonNode and the XDocument underneath are one property away, so nothing the libraries can do is out of reach.


Part of Precept, a .NET 10 test automation framework. Full documentation: files · Excel · CSV · JSON · XML · where files go

Precept 0.10.0 · MIT · © 2026

Esc