Path: redb/redb.Tests.Integration/Tests/Base/DbInfoTestsBase.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/Base/DbInfoTestsBase.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; namespace redb.Tests.Integration.Tests.Base; /// /// Server facts through : the version and the database size. The SQLite service sent the /// PostgreSQL text - version() and pg_database_size(current_database()) - and failed on its own provider; /// MSSQL reported the size in kilobytes while the others reported bytes. /// public abstract class DbInfoTestsBase { /// Registers the provider on the options builder (Free or Pro, see ). protected abstract void UseProvider(RedbOptionsBuilder options); protected virtual void Register(IServiceCollection services, Action configure) => services.AddRedb(configure); /// Text every version string of this provider contains. protected abstract string VersionMarker { get; } /// The database size in bytes, straight from the server's own catalog, to pin the unit. protected abstract string SizeInBytesSql { get; } private ServiceProvider Build() { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); Register(services, options => { UseProvider(options); options.Configure(c => c.CacheDomain = "db-info"); }); return services.BuildServiceProvider(); } [Fact] public async Task Version_ComesFromTheServer() { await using var sp = Build(); var service = sp.GetRequiredService(); await service.InitializeAsync(ensureCreated: true); (await service.GetDbVersionAsync()).Should().Contain(VersionMarker); service.dbVersion.Should().Contain(VersionMarker); } [Fact] public async Task Size_IsInBytes() { await using var sp = Build(); var service = sp.GetRequiredService(); await service.InitializeAsync(ensureCreated: true); var reported = service.dbSize; var expected = await service.Context.ExecuteScalarAsync(SizeInBytesSql); expected.Should().BeGreaterThan(0); reported.Should().NotBeNull(); // Other suites write to the shared database meanwhile: the unit is pinned, not the exact byte count. reported!.Value.Should().BeInRange(expected / 2, expected * 2, "dbSize reports bytes on every provider"); } }