Skip to content

Integration Sqlite Extension

Aryeh Citron edited this page Apr 29, 2026 · 3 revisions

The TestTrackingDiagrams.Extensions.Sqlite package adds SQLite operation tracking to your test diagrams using a DbConnection wrapping decorator pattern.

Why wrapping? Unlike PostgreSQL, SQL Server, and MySQL, Microsoft.Data.Sqlite does not emit DiagnosticSource events. This extension wraps SqliteConnection with TrackingSqliteConnection, which intercepts all command executions and transaction operations.


How It Works

TrackingSqliteConnection wraps a real SqliteConnection and returns TrackingSqliteCommand instances that intercept all 6 execution methods (ExecuteReader/NonQuery/Scalar × sync/async). TrackingSqliteTransaction intercepts Begin/Commit/Rollback. All intercepted operations are classified by UnifiedSqlClassifier and logged to RequestResponseLogger.


Install

dotnet add package TestTrackingDiagrams.Extensions.Sqlite

Setup

Option A — Dependency Injection

services.AddSqliteTestTracking(options =>
{
    options.Verbosity = SqlTrackingVerbosityLevel.Detailed;
});

This decorates all DbConnection registrations with a type-check guard — only SqliteConnection instances are wrapped; others pass through unchanged.

Option B — Manual Wrapping (No DI)

var inner = new SqliteConnection("Data Source=:memory:");
var tracked = inner.WithTestTracking(new SqliteTrackingOptions
{
    Verbosity = SqlTrackingVerbosityLevel.Detailed
});

await tracked.OpenAsync();
// Use tracked as your DbConnection...

Configuration

Property Default Description
ServiceName "SQLite" Participant name in diagrams
Verbosity Detailed Raw, Detailed, or Summarised
LogSqlText false Include full SQL text in Detailed mode
LogParameters false Include parameter values
DependencyCategory "SQLite" Controls participant shape/colour
UriScheme "sqlite" URI scheme in diagram URIs

All options inherit from SqlTrackingOptionsBase.


Verbosity Levels

Level Arrow label URI
Raw Full SQL text sqlite:///database
Detailed SELECT FROM Users sqlite:///database/Users
Summarised SELECT sqlite:///database/Users

Transaction Tracking

TrackingSqliteTransaction logs BEGIN TRANSACTION, COMMIT, and ROLLBACK operations automatically. These appear as separate arrows in the sequence diagram.

Home


Demo


Getting Started

Common Tasks

Integration Guides

Extensions

Configuration

Features

Reference

Clone this wiki locally