Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteExportRenameHistoryTests.cs Snapshot: redb, 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 Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Sqlite/SqliteExportRenameHistoryTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; /// on SQLite, scratch files deleted afterwards. public class SqliteExportRenameHistoryTests : ExportRenameHistoryTestsBase, IAsyncLifetime { private readonly List _databases = []; private readonly List _files = []; protected override string ProviderName => "sqlite"; public Task InitializeAsync() => Task.CompletedTask; public Task DisposeAsync() { SqliteConnection.ClearAllPools(); foreach (var database in _databases) SqliteTestSupport.DeleteDbFiles(database); foreach (var file in _files) File.Delete(file); return Task.CompletedTask; } protected override Task NewDatabaseAsync(string suffix) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_export_ren_{suffix}_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); _databases.Add(cs); return Task.FromResult(cs); } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"export-ren-{Guid.NewGuid():N}"); }); return services.BuildServiceProvider(); } protected override string NewFile() { var file = Path.Combine(Path.GetTempPath(), $"redb-export-ren-{Guid.NewGuid():N}.redb"); _files.Add(file); return file; } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; return AsText(await command.ExecuteScalarAsync()); } protected override async Task ExecuteSqlAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; await command.ExecuteNonQueryAsync(); } protected override async Task> PairsAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; await using var reader = await command.ExecuteReaderAsync(); var rows = new List<(string?, string?)>(); while (await reader.ReadAsync()) rows.Add((AsText(reader.GetValue(0)), AsText(reader.GetValue(1)))); return rows; } }