Path: redb-route/tests/redb.Route.Tests.Core/Sql/SqliteRedbSqlDataSourceTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Core/Sql/SqliteRedbSqlDataSourceTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.SQLite.Extensions; namespace redb.Route.Tests.Core.Sql; /// Two redb (Free) services on SQLite files of their own: the default one and the one named orders. public sealed class SqliteRedbSqlFixture : IAsyncLifetime { private readonly string _directory = Path.Combine(Path.GetTempPath(), "redb-route-sql-lease-" + Guid.NewGuid().ToString("N")[..8]); public ServiceProvider Services { get; private set; } = null!; public ServiceProvider NamedServices { get; private set; } = null!; public async Task InitializeAsync() { Directory.CreateDirectory(_directory); Services = await BuildAsync(Path.Combine(_directory, "default.db")); NamedServices = await BuildAsync(Path.Combine(_directory, "orders.db")); } private static async Task BuildAsync(string file) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(o => o.UseSqlite($"Data Source={file}")); var provider = services.BuildServiceProvider(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.Context.ExecuteAsync("CREATE TABLE IF NOT EXISTS route_sql_lease_rows (tag TEXT NOT NULL)"); return provider; } public async Task DisposeAsync() { await Services.DisposeAsync(); await NamedServices.DisposeAsync(); Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools(); try { Directory.Delete(_directory, recursive: true); } catch (IOException) { /* a file still mapped by the native extension: the temp folder keeps it */ } } } public sealed class SqliteRedbSqlDataSourceTests(SqliteRedbSqlFixture fixture) : RedbSqlDataSourceTestsBase, IClassFixture { protected override IServiceProvider Services => fixture.Services; protected override IServiceProvider NamedServices => fixture.NamedServices; protected override bool ChecksDistributedTransaction => false; }