Precept.Files
0.11.1
dotnet add package Precept.Files --version 0.11.1
NuGet\Install-Package Precept.Files -Version 0.11.1
<PackageReference Include="Precept.Files" Version="0.11.1" />
<PackageVersion Include="Precept.Files" Version="0.11.1" />
<PackageReference Include="Precept.Files" />
paket add Precept.Files --version 0.11.1
#r "nuget: Precept.Files, 0.11.1"
#:package Precept.Files@0.11.1
#addin nuget:?package=Precept.Files&version=0.11.1
#tool nuget:?package=Precept.Files&version=0.11.1
Precept.Files
Excel, CSV, JSON and XML files for Precept tests. Write a workbook or a CSV from a data table or a query result, append a row to a file the system under test produced, read a file back as rows, and build, query, change and assert on JSON and XML documents. Every file a test writes lands in its artifacts and is 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 with 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, which is unique to the test and one step from every report. It is 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 framework built on Microsoft.Testing.Platform. Full documentation: files · Excel · CSV · JSON · XML · where files go
| 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
- ClosedXML (>= 0.105.1)
- 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.