Precept 0.14.0

Precept.Data

Database testing for Precept. It works with any ADO.NET provider (SQL Server, PostgreSQL, MySQL, SQLite) supplied by the test project, so no driver is forced on you.

dotnet add package Precept.Data
services.AddPreceptData(cs => new NpgsqlConnection(cs));
await Db.ExecuteAsync(
    "insert into clients (id, name) values (@id, @name)",
    ("id", id), ("name", "Acme"));

var outstanding = await Db.ScalarAsync<long>("select count(*) from outbox where sent = 0");
var rows = await Db.QueryAsync("select id, name from clients where active = 1");

Db.InRolledBackTransactionAsync runs work in a transaction that is always rolled back, for a check that must leave nothing behind. Connection strings come from the ConnectionStrings section of precept.json, or from PRECEPT_CONNECTIONSTRINGS__<NAME> environment variables so that a password never has to be committed. Every method takes a database argument that defaults to "Default".

Waiting for the database to catch up is the ordinary assertion sentence, not a sleep:

await Assert.Eventually(() => Db.ScalarAsync<long>("select count(*) from outbox where sent = 0"))
            .ToBeEqualAsync(0L);

Part of Precept, a .NET 10 test framework built on Microsoft.Testing.Platform. Full documentation: assertions · waiting · configuration · environment variables

Precept 0.14.0 · MIT · © 2026

Esc