Bundle: redb / redb.Tests.Integration (redb.Tests.Integration.txt), 331 files
Snapshot: 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
Index: https://redbase.app/src/dev-2026-12-06/redb/_index.txt
====
Path: redb/redb.Tests.Integration/Fixtures/CapturingLoggerProvider.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/Fixtures/CapturingLoggerProvider.cs
----
using System.Collections.Concurrent;
using Microsoft.Extensions.Logging;
namespace redb.Tests.Integration.Fixtures;
///
/// Records every log entry of the loggers it creates, so a test can assert that a diagnostic warning was
/// written - and written once.
///
public sealed class CapturingLoggerProvider : ILoggerProvider
{
private readonly ConcurrentQueue _entries = new();
public IReadOnlyList Entries => _entries.ToArray();
/// Messages of the Warning entries, in the order they were written.
public IReadOnlyList Warnings => _entries.Where(e => e.Level == LogLevel.Warning).Select(e => e.Message).ToList();
public ILogger CreateLogger(string categoryName) => new CapturingLogger(this, categoryName);
public void Dispose() { }
private sealed class CapturingLogger : ILogger
{
private readonly CapturingLoggerProvider _owner;
private readonly string _category;
public CapturingLogger(CapturingLoggerProvider owner, string category)
{
_owner = owner;
_category = category;
}
public IDisposable? BeginScope(TState state) where TState : notnull => null;
public bool IsEnabled(LogLevel logLevel) => true;
public void Log(LogLevel logLevel, EventId eventId, TState state, Exception? exception,
Func formatter)
=> _owner._entries.Enqueue(new CapturedLogEntry(_category, logLevel, formatter(state, exception)));
}
}
public sealed record CapturedLogEntry(string Category, LogLevel Level, string Message);
Path: redb/redb.Tests.Integration/Fixtures/CollectionDefinitions.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/Fixtures/CollectionDefinitions.cs
----
namespace redb.Tests.Integration.Fixtures;
[CollectionDefinition("Postgres")]
public class PostgresCollection : ICollectionFixture;
[CollectionDefinition("MsSql")]
public class MsSqlCollection : ICollectionFixture;
[CollectionDefinition("PostgresPro")]
public class PostgresProCollection : ICollectionFixture;
[CollectionDefinition("MsSqlPro")]
public class MsSqlProCollection : ICollectionFixture;
[CollectionDefinition("Sqlite")]
public class SqliteCollection : ICollectionFixture;
[CollectionDefinition("SqlitePro")]
public class SqliteProCollection : ICollectionFixture;
// Case folding. Each needs its own collection: the PostgreSQL pair shares one C-ctype database and
// must not interleave, and SQLite installs the feature per connection on a file of its own.
[CollectionDefinition("PostgresCollation")]
public class PostgresCollationCollection : ICollectionFixture;
[CollectionDefinition("PostgresNoCollation")]
public class PostgresNoCollationCollection : ICollectionFixture;
[CollectionDefinition("SqliteCollation")]
public class SqliteCollationCollection : ICollectionFixture;
[CollectionDefinition("SqliteProCollation")]
public class SqliteProCollationCollection : ICollectionFixture;
[CollectionDefinition("PostgresProCollation")]
public class PostgresProCollationCollection : ICollectionFixture;
Path: redb/redb.Tests.Integration/Fixtures/FixtureWipeGuard.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/Fixtures/FixtureWipeGuard.cs
----
using redb.Core.Data;
namespace redb.Tests.Integration.Fixtures;
///
/// Refuses a fixture wipe of a database that does not look like a test database. The fixtures
/// clean their database COMPLETELY on start (DELETE FROM _values / _objects) - lawful on the
/// dedicated test database, catastrophic on anything else: on 2026-09-10 a freshly seeded
/// 100k-object examples database shared the test connection string and was lost to exactly this
/// (and the 8M-row cascade-trigger delete масked itself as an hours-long hang first).
/// Examples/seeding live in their own databases (redb_examples) since then; this guard is the
/// belt to that suspenders.
///
public static class FixtureWipeGuard
{
/// Way above anything the test suites ever create, way below any real seed.
public const long MaxObjectsForWipe = 50_000;
public static async Task EnsureLooksLikeATestDatabaseAsync(IRedbContext ctx, string fixtureName)
{
var count = await ctx.ExecuteScalarAsync("SELECT COUNT(*) FROM _objects");
if (count > MaxObjectsForWipe)
throw new InvalidOperationException(
$"{fixtureName}: refusing to wipe this database - _objects holds {count:N0} rows " +
$"(threshold {MaxObjectsForWipe:N0}). It looks seeded or production-like, and the " +
"fixture cleanup deletes EVERYTHING. Point the tests at a dedicated test database; " +
"the examples seed belongs in redb_examples.");
}
}
Path: redb/redb.Tests.Integration/Fixtures/MsSqlFixture.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/Fixtures/MsSqlFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Data;
using redb.Core.Extensions;
using redb.Core.Models.Configuration;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
public sealed class MsSqlFixture : IAsyncLifetime
{
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var cs = config.GetConnectionString("MSSql")!;
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedb(options => options
.UseMsSql(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.DeleteInsert;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
}));
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await SyncSchemes();
await Cleanup();
}
private async Task SyncSchemes()
{
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
// Case-folding suite: MSSQL is asserted to need no setting at all (MsSqlCaseFoldingTests).
await Redb.SyncSchemeAsync();
await Redb.InitializeTypeRegistryAsync();
}
private async Task Cleanup()
{
var ctx = ServiceProvider.GetRequiredService();
await FixtureWipeGuard.EnsureLooksLikeATestDatabaseAsync(ctx, nameof(MsSqlFixture));
try { await ctx.ExecuteAsync("DELETE FROM _tree"); } catch { }
try { await ctx.ExecuteAsync("DELETE FROM _values"); } catch { }
await ctx.ExecuteAsync("DELETE FROM _objects");
try { await ctx.ExecuteAsync("DBCC CHECKIDENT ('_objects', RESEED, 0)"); } catch { }
try { await ctx.ExecuteAsync("DBCC CHECKIDENT ('_values', RESEED, 0)"); } catch { }
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
// Same as the Postgres fixtures: return the pooled sessions to the server immediately.
Microsoft.Data.SqlClient.SqlConnection.ClearAllPools();
}
}
Path: redb/redb.Tests.Integration/Fixtures/MsSqlProFixture.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/Fixtures/MsSqlProFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Data;
using redb.Core.Models.Configuration;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
public sealed class MsSqlProFixture : IAsyncLifetime
{
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var cs = config.GetConnectionString("MSSql")!;
var license = config["Redb:License"];
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedbPro(options =>
{
options.UseMsSql(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
c.EnablePvtPrefilter = ProTestOptions.PvtPrefilter;
});
if (!string.IsNullOrWhiteSpace(license))
options.WithLicense(license);
});
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await SyncSchemes();
await Cleanup();
}
private async Task SyncSchemes()
{
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
}
private async Task Cleanup()
{
var ctx = ServiceProvider.GetRequiredService();
await FixtureWipeGuard.EnsureLooksLikeATestDatabaseAsync(ctx, nameof(MsSqlProFixture));
try { await ctx.ExecuteAsync("DELETE FROM _tree"); } catch { }
try { await ctx.ExecuteAsync("DELETE FROM _values"); } catch { }
await ctx.ExecuteAsync("DELETE FROM _objects");
try { await ctx.ExecuteAsync("DBCC CHECKIDENT ('_objects', RESEED, 0)"); } catch { }
try { await ctx.ExecuteAsync("DBCC CHECKIDENT ('_values', RESEED, 0)"); } catch { }
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
// Same as the Postgres fixtures: return the pooled sessions to the server immediately.
Microsoft.Data.SqlClient.SqlConnection.ClearAllPools();
}
}
Path: redb/redb.Tests.Integration/Fixtures/PostgresCollationFixture.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/Fixtures/PostgresCollationFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Npgsql;
using redb.Core;
using redb.Core.Data;
using redb.Core.Extensions;
using redb.Core.Models.Configuration;
using redb.Postgres.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
///
/// A PostgreSQL database created with LC_CTYPE=C, which is the only environment where the
/// case-folding defect is visible at all.
///
///
/// This fixture exists because the ordinary test database is created with en_US.utf8, where
/// 'Привет' ILIKE '%привет%' is already true and every assertion below would pass with the
/// feature removed. That is precisely how the defect survived: the environment masked it, the same
/// way an all-UTC test set masked the DateTime one. A suite that cannot fail on the unfixed code is
/// not a regression test.
///
///
///
/// The database is created once and reused, so a re-run costs nothing. It is deliberately NOT
/// dropped on dispose: recreating a database with a non-default locale is slow, and leaving it
/// keeps the next run fast. It carries a name no other suite uses.
///
///
public sealed class PostgresCollationFixture : IAsyncLifetime
{
/// Name of the C-ctype database. Distinct from every other suite's.
public const string DatabaseName = "redb_collation_c";
/// Collation used by the tests. Deterministic, which LIKE requires.
public const string Collation = "und-x-icu";
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
/// Connection string of the C-ctype database, for a second fixture on the same data.
public static string ConnectionString { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var baseCs = config.GetConnectionString("Postgres")!;
ConnectionString = await EnsureCtypeCDatabaseAsync(baseCs);
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedb(options => options
.UsePostgres(ConnectionString)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.DeleteInsert;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
c.StringCollation = Collation;
// A distinct cache domain: this process also holds services pointed at the ordinary
// test database, and the metadata caches are keyed by domain. Sharing one would let
// a scheme id from the other database answer a lookup here.
c.CacheDomain = "collation-c";
}));
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await Redb.SyncSchemeAsync();
await Redb.InitializeTypeRegistryAsync();
var ctx = ServiceProvider.GetRequiredService();
await FixtureWipeGuard.EnsureLooksLikeATestDatabaseAsync(ctx, nameof(PostgresCollationFixture));
await ctx.ExecuteAsync("DELETE FROM _values");
await ctx.ExecuteAsync("DELETE FROM _objects");
}
///
/// Creates the database if it is absent. TEMPLATE template0 is required: template1 carries the
/// cluster's own locale and CREATE DATABASE refuses a different one from it.
/// Every fixture on this database calls it: on a fresh server whichever collection starts first creates the
/// database, and a session lock keeps two of them from creating it at once.
///
internal static async Task EnsureCtypeCDatabaseAsync(string baseConnectionString)
{
var builder = new NpgsqlConnectionStringBuilder(baseConnectionString);
var target = new NpgsqlConnectionStringBuilder(baseConnectionString) { Database = DatabaseName };
builder.Database = "postgres";
// Unpooled: the session lock below ends with this connection.
builder.Pooling = false;
await using var admin = new NpgsqlConnection(builder.ConnectionString);
await admin.OpenAsync();
await using (var gate = admin.CreateCommand())
{
gate.CommandText = "SELECT pg_advisory_lock(hashtext($1))";
gate.Parameters.Add(new NpgsqlParameter { Value = DatabaseName });
await gate.ExecuteNonQueryAsync();
}
await using (var check = admin.CreateCommand())
{
check.CommandText = "SELECT 1 FROM pg_database WHERE datname = $1";
check.Parameters.Add(new NpgsqlParameter { Value = DatabaseName });
if (await check.ExecuteScalarAsync() is not null)
return target.ConnectionString;
}
await using (var create = admin.CreateCommand())
{
// The name is a compile-time constant, not input, so interpolation here is not a hole.
create.CommandText =
$"CREATE DATABASE \"{DatabaseName}\" TEMPLATE template0 " +
"LC_COLLATE 'C' LC_CTYPE 'C' ENCODING 'UTF8'";
await create.ExecuteNonQueryAsync();
}
return target.ConnectionString;
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
///
/// The same C-ctype database, with the feature OFF. Proves the other half of the contract: without
/// the setting the behaviour is exactly what it was, so nobody's existing deployment changes under
/// them. Creates the database and the schema itself when it starts first.
///
public sealed class PostgresNoCollationFixture : IAsyncLifetime
{
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var baseCs = config.GetConnectionString("Postgres")!;
// The database may not exist yet: on a fresh server this collection can start before the one that used to
// create it.
var target = new NpgsqlConnectionStringBuilder(await PostgresCollationFixture.EnsureCtypeCDatabaseAsync(baseCs));
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedb(options => options
.UsePostgres(target.ConnectionString)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.DeleteInsert;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
// StringCollation deliberately left unset — that is the point of this fixture.
c.CacheDomain = "collation-c";
}));
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await Redb.SyncSchemeAsync();
await Redb.InitializeTypeRegistryAsync();
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
Path: redb/redb.Tests.Integration/Fixtures/PostgresFixture.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/Fixtures/PostgresFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Data;
using redb.Core.Extensions;
using redb.Core.Models.Configuration;
using redb.Postgres.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
public sealed class PostgresFixture : IAsyncLifetime
{
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var cs = config.GetConnectionString("Postgres")!;
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedb(options => options
.UsePostgres(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.DeleteInsert;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
}));
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await SyncSchemes();
await Cleanup();
}
private async Task SyncSchemes()
{
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.InitializeTypeRegistryAsync();
}
private async Task Cleanup()
{
var ctx = ServiceProvider.GetRequiredService();
await FixtureWipeGuard.EnsureLooksLikeATestDatabaseAsync(ctx, nameof(PostgresFixture));
try { await ctx.ExecuteAsync("DELETE FROM _tree"); } catch { }
await ctx.ExecuteAsync("DELETE FROM _values");
await ctx.ExecuteAsync("DELETE FROM _objects");
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
Path: redb/redb.Tests.Integration/Fixtures/PostgresProCollationFixture.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/Fixtures/PostgresProCollationFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Npgsql;
using redb.Core;
using redb.Core.Data;
using redb.Core.Models.Configuration;
using redb.Core.Pro.Extensions;
using redb.Postgres.Pro.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
///
/// PostgreSQL Pro on the C-ctype database, feature ON.
///
///
/// Free and Pro do not share a code path here. Free builds its SQL inside the database and reads the
/// collation from a GUC; Pro builds it in C# and attaches the clause through the dialect. Testing
/// only Free would leave every Pro user unprotected, and the two could drift apart without a single
/// test going red. This fixture exists because the first version of the suite covered Free alone.
///
///
///
/// The PVT prefilter is forced ON regardless of ProTestOptions, because
/// PvtPrefilterRenderer is a separate emitter with its own copy of the ILIKE mapping. With
/// the prefilter off that file is never executed and its folding is untested.
///
///
public sealed class PostgresProCollationFixture : IAsyncLifetime
{
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var baseCs = config.GetConnectionString("Postgres")!;
var license = config["Redb:License"];
// The Free collation fixture owns creation of the C-ctype database; reuse it if it has run,
// otherwise create it here so this suite can also run alone.
var cs = new NpgsqlConnectionStringBuilder(baseCs)
{
Database = PostgresCollationFixture.DatabaseName
}.ConnectionString;
await PostgresCollationFixture.EnsureCtypeCDatabaseAsync(baseCs);
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedbPro(options =>
{
options.UsePostgres(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
c.EnablePvtPrefilter = true; // see the class remark
c.StringCollation = PostgresCollationFixture.Collation;
c.CacheDomain = "collation-c-pro";
});
if (!string.IsNullOrWhiteSpace(license))
options.WithLicense(license);
});
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await Redb.SyncSchemeAsync();
await Redb.InitializeTypeRegistryAsync();
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
Path: redb/redb.Tests.Integration/Fixtures/PostgresProFixture.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/Fixtures/PostgresProFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Data;
using redb.Core.Models.Configuration;
using redb.Core.Pro.Extensions;
using redb.Postgres.Pro.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
public sealed class PostgresProFixture : IAsyncLifetime
{
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var cs = config.GetConnectionString("Postgres")!;
var license = config["Redb:License"];
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedbPro(options =>
{
options.UsePostgres(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
c.EnablePvtPrefilter = ProTestOptions.PvtPrefilter;
});
if (!string.IsNullOrWhiteSpace(license))
options.WithLicense(license);
});
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await SyncSchemes();
await Cleanup();
}
private async Task SyncSchemes()
{
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
}
private async Task Cleanup()
{
var ctx = ServiceProvider.GetRequiredService();
await FixtureWipeGuard.EnsureLooksLikeATestDatabaseAsync(ctx, nameof(PostgresProFixture));
try { await ctx.ExecuteAsync("DELETE FROM _tree"); } catch { }
await ctx.ExecuteAsync("DELETE FROM _values");
await ctx.ExecuteAsync("DELETE FROM _objects");
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
Path: redb/redb.Tests.Integration/Fixtures/ProTestOptions.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/Fixtures/ProTestOptions.cs
----
namespace redb.Tests.Integration.Fixtures;
///
/// Knobs the Pro fixtures read from the environment, so the whole suite can be replayed under a
/// different engine configuration without editing code.
///
internal static class ProTestOptions
{
///
/// REDB_PVT_PREFILTER=1|true|on|yes enables the PVT prefilter. Off when the variable is unset,
/// although RedbServiceConfiguration.EnablePvtPrefilter defaults to true: the fixtures set
/// the flag explicitly, so each pass runs the form it names.
///
/// The prefilter is built as a superset and must not change a single result, so BOTH passes are
/// expected to be green and identical. A test that passes with it off and fails with it on is a
/// bug in the prefilter, never a reason to relax the test.
///
public static bool PvtPrefilter =>
(Environment.GetEnvironmentVariable("REDB_PVT_PREFILTER") ?? string.Empty).Trim().ToLowerInvariant()
is "1" or "true" or "on" or "yes";
}
Path: redb/redb.Tests.Integration/Fixtures/SchemaUpgradeCleanup.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/Fixtures/SchemaUpgradeCleanup.cs
----
namespace redb.Tests.Integration.Fixtures;
///
/// Removes what a schema-upgrade test class created on the test server (its databases, its login or role) when the
/// class is done, whether its tests passed or failed. The class registers the removal; the databases live for the whole
/// class, because every test of it starts from the deployed one.
///
public sealed class SchemaUpgradeCleanup : IAsyncLifetime
{
private Func? _remove;
///
/// A suffix of this run for the names of the databases and the login or role of the class: two runs on one server
/// (a host run and a direct one) must not drop each other's database in the middle of a test.
///
public string Suffix { get; } = Guid.NewGuid().ToString("N")[..8];
/// The removal of the first test instance is kept: every instance of a class names the same objects.
public void Register(Func remove) => _remove ??= remove;
public Task InitializeAsync() => Task.CompletedTask;
public Task DisposeAsync() => _remove?.Invoke() ?? Task.CompletedTask;
}
Path: redb/redb.Tests.Integration/Fixtures/SqliteCollationFixture.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/Fixtures/SqliteCollationFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Data;
using redb.Core.Extensions;
using redb.Core.Models.Configuration;
using redb.SQLite.Data;
using redb.SQLite.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
///
/// SQLite with Unicode case folding enabled.
///
///
/// Unlike PostgreSQL, no special database is needed: SQLite's ASCII-only folding is unconditional,
/// so an ordinary file reproduces the defect. What the fixture does need is its own file, because
/// the feature is installed per connection and the other SQLite fixtures share one database.
///
///
public sealed class SqliteCollationFixture : IAsyncLifetime
{
private const string DbFile = "redb_tests_sqlite_collation.db";
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
// Reuse the configured shape (pragmas, pooling) but a different file.
var baseCs = config.GetConnectionString("Sqlite")!;
var cs = System.Text.RegularExpressions.Regex.Replace(
baseCs, @"Data Source\s*=\s*[^;]+", "Data Source=" + DbFile,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension();
SqliteTestSupport.DeleteDbFiles(cs);
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedb(options => options
.UseSqlite(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.DeleteInsert;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
// On SQLite the value is not a collation name — there is nothing to attach it to.
// It is the switch that installs the Unicode-aware like/lower/upper overrides on
// every connection. The name is validated all the same, so a typo fails at startup
// rather than turning into silence.
c.StringCollation = PostgresCollationFixture.Collation;
c.CacheDomain = "collation-sqlite";
}));
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await Redb.SyncSchemeAsync();
await Redb.InitializeTypeRegistryAsync();
var ctx = ServiceProvider.GetRequiredService();
await FixtureWipeGuard.EnsureLooksLikeATestDatabaseAsync(ctx, nameof(SqliteCollationFixture));
await ctx.ExecuteAsync("DELETE FROM _values");
await ctx.ExecuteAsync("DELETE FROM _objects");
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
Path: redb/redb.Tests.Integration/Fixtures/SqliteFixture.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/Fixtures/SqliteFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Data;
using redb.Core.Extensions;
using redb.Core.Models.Configuration;
using redb.SQLite.Data;
using redb.SQLite.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
///
/// SQLite Free fixture — hosts the in-DB machinery as the native loadable extension
/// (get_object_json / pvt_build_*_sql / ...). The native binary is located by walking up to
/// redb.SQLite/native/build/redbsqlite.{dll,so,dylib}. A fresh DB file is used every run (the datetime
/// columns are REAL Julian and an old TEXT-schema file is not auto-migrated).
///
public sealed class SqliteFixture : IAsyncLifetime
{
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var cs = config.GetConnectionString("Sqlite")!;
SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension();
SqliteTestSupport.DeleteDbFiles(cs);
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedb(options => options
.UseSqlite(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.DeleteInsert;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
}));
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await SyncSchemes();
await Cleanup();
}
private async Task SyncSchemes()
{
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.InitializeTypeRegistryAsync();
}
private async Task Cleanup()
{
var ctx = ServiceProvider.GetRequiredService();
try { await ctx.ExecuteAsync("DELETE FROM _tree"); } catch { }
await ctx.ExecuteAsync("DELETE FROM _values");
await ctx.ExecuteAsync("DELETE FROM _objects");
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
Path: redb/redb.Tests.Integration/Fixtures/SqliteProCollationFixture.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/Fixtures/SqliteProCollationFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Data;
using redb.Core.Models.Configuration;
using redb.Core.Pro.Extensions;
using redb.SQLite.Pro.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
///
/// SQLite Pro with StringCollation set: the Pro registration of SqliteCollationFixture. On SQLite the setting is
/// the switch that installs the Unicode-aware like/lower/upper overrides on every connection; its own file, because they
/// are installed per connection.
///
public sealed class SqliteProCollationFixture : IAsyncLifetime
{
private const string DbFile = "redb_tests_sqlite_pro_collation.db";
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var cs = System.Text.RegularExpressions.Regex.Replace(
config.GetConnectionString("Sqlite")!, @"Data Source\s*=\s*[^;]+", "Data Source=" + DbFile,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
var license = config["Redb:License"];
// As in SqliteProFixture: the path is process-static and other fixtures set it; set before the first connection.
redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension();
SqliteTestSupport.DeleteDbFiles(cs);
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedbPro(options =>
{
options.UseSqlite(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
c.EnablePvtPrefilter = ProTestOptions.PvtPrefilter;
c.StringCollation = PostgresCollationFixture.Collation;
c.CacheDomain = "collation-sqlite-pro";
});
if (!string.IsNullOrWhiteSpace(license))
options.WithLicense(license);
});
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await Redb.SyncSchemeAsync();
await Redb.InitializeTypeRegistryAsync();
var ctx = ServiceProvider.GetRequiredService();
await FixtureWipeGuard.EnsureLooksLikeATestDatabaseAsync(ctx, nameof(SqliteProCollationFixture));
await ctx.ExecuteAsync("DELETE FROM _values");
await ctx.ExecuteAsync("DELETE FROM _objects");
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
Path: redb/redb.Tests.Integration/Fixtures/SqliteProFixture.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/Fixtures/SqliteProFixture.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Data;
using redb.Core.Models.Configuration;
using redb.Core.Pro.Extensions;
using redb.SQLite.Pro.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Fixtures;
///
/// SQLite Pro fixture — pure C# (ProSqlBuilder + C# materialization, no DB-side functions),
/// so no native extension is needed. Uses a separate fresh DB file from the Free fixture to avoid
/// cross-collection contention on the single-writer SQLite file.
///
public sealed class SqliteProFixture : IAsyncLifetime
{
public IRedbService Redb { get; private set; } = null!;
public ServiceProvider ServiceProvider { get; private set; } = null!;
/// The fixture's own database file: a test of the collection that builds a host of its own uses this one.
public string ConnectionString { get; private set; } = null!;
public async Task InitializeAsync()
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
// Own DB file: the Free and Pro collections run in PARALLEL (the old comment assumed
// sequential and was wrong), and SQLite is a single-writer engine - two collections
// hammering one file starve each other on the write lock for minutes (gate hang,
// 2026-09-09: NextResult lost the non-FIFO lock race to the other collection's stream
// of short transactions over and over).
var cs = System.Text.RegularExpressions.Regex.Replace(
config.GetConnectionString("Sqlite")!,
@"Data Sources*=s*[^;]+", "Data Source=redb_tests_sqlite_pro.db");
var license = config["Redb:License"];
// The native extension path is static for the whole process, and several tests set it (every
// Free fixture, and Pro tests built on Free ones). Once it is set, InitializeAsync checks the
// extension's version on the connection it is given; a connection this fixture had opened while
// the path was still empty carried no extension, and that check failed with "no
// pvt_module_version() function" for whichever Pro test happened to run after such a test. Set
// here, before the first connection, every connection of the fixture loads the extension - harmless
// for Pro, which does not call it - and the order of the tests no longer matters.
redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension();
SqliteTestSupport.DeleteDbFiles(cs);
ConnectionString = cs;
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedbPro(options =>
{
options.UseSqlite(cs)
.Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking;
c.SkipHashValidationOnCacheCheck = false;
c.EnablePropsCache = false;
c.EnablePvtPrefilter = ProTestOptions.PvtPrefilter;
});
if (!string.IsNullOrWhiteSpace(license))
options.WithLicense(license);
});
ServiceProvider = services.BuildServiceProvider();
Redb = ServiceProvider.GetRequiredService();
try { await Redb.InitializeAsync(ensureCreated: true); }
catch { await Redb.InitializeAsync(); }
await SyncSchemes();
await Cleanup();
}
private async Task SyncSchemes()
{
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
await Redb.SyncSchemeAsync();
}
private async Task Cleanup()
{
var ctx = ServiceProvider.GetRequiredService();
try { await ctx.ExecuteAsync("DELETE FROM _tree"); } catch { }
await ctx.ExecuteAsync("DELETE FROM _values");
await ctx.ExecuteAsync("DELETE FROM _objects");
}
public async Task DisposeAsync()
{
if (ServiceProvider is IAsyncDisposable ad)
await ad.DisposeAsync();
else
ServiceProvider?.Dispose();
}
}
Path: redb/redb.Tests.Integration/Fixtures/SqliteTestSupport.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/Fixtures/SqliteTestSupport.cs
----
using System.Text.RegularExpressions;
using redb.Core.Data;
namespace redb.Tests.Integration.Fixtures;
/// Shared helpers for the SQLite fixtures.
internal static class SqliteTestSupport
{
///
/// Locate the Free native loadable extension (redbsqlite.{dll,so,dylib}) by walking up from the test
/// output directory to redb.SQLite/native/build/. Returns null to fall back to the packaged locator.
///
public static string? ResolveNativeExtension()
{
var suffix = OperatingSystem.IsWindows() ? ".dll"
: OperatingSystem.IsMacOS() ? ".dylib"
: ".so";
for (var dir = new DirectoryInfo(AppContext.BaseDirectory); dir != null; dir = dir.Parent)
{
// Public mirror layout first (redb.SQLite at the top level), then the development repository layout (redb.DB/src).
var candidate = Path.Combine(dir.FullName, "redb.SQLite", "native", "build", "redbsqlite" + suffix);
if (!File.Exists(candidate))
candidate = Path.Combine(dir.FullName, "redb.DB", "src", "redb.SQLite", "native", "build", "redbsqlite" + suffix);
if (File.Exists(candidate)) return candidate;
}
return null;
}
///
/// Delete the SQLite DB file (and its -wal/-shm siblings) named in the connection string, so each
/// run starts on a freshly created schema (datetimes are REAL Julian; an old TEXT-schema file is
/// NOT auto-migrated).
///
public static void DeleteDbFiles(string connectionString)
{
RegisterSweepAtExit();
var m = Regex.Match(connectionString, @"Data Source\s*=\s*([^;]+)", RegexOptions.IgnoreCase);
if (!m.Success) return;
var file = m.Groups[1].Value.Trim();
foreach (var f in new[] { file, file + "-wal", file + "-shm" })
{
try { if (File.Exists(f)) File.Delete(f); } catch { /* locked from a prior run — ignore */ }
}
// The id cache is a process-wide static in RedbKeyGeneratorBase, holding up to 10000 ids already
// reserved against the file we have just deleted. The replacement file starts its sqlite_sequence
// at zero, so the surviving cache and the fresh sequence hand out overlapping ids and inserts die
// with "UNIQUE constraint failed: _values._id". Both SQLite fixtures share one file inside one
// process, so the second one to start is the one that trips over it, which is why this never
// reproduces when a single test class is run alone.
RedbKeyGeneratorBase.ClearAllCaches();
}
private static int _sweepRegistered;
///
/// The SQLite files the tests create (relative Data Source=redb_tests_*.db, redb_diag_*.db) are
/// deleted before a test uses them but were never deleted after, and the ones named per test by a GUID piled
/// up in the output directory, a few hundred per run. They are swept when the process exits, after the
/// connection pools are closed (a pooled connection keeps the file open); the sweep goes by name, so it also
/// takes what a killed run left. A file still open is skipped.
///
/// Registered from , which every SQLite fixture and test calls first, and not from a
/// module initializer: a test loads a copy of this assembly into a collectible context, the initializer ran in
/// that copy too, and its handler on the process-wide event kept the context alive. Nor at start: the first
/// call falls between the starts of collections running in parallel, and a sweep then could take a file a
/// neighbour had just created.
///
///
private static void RegisterSweepAtExit()
{
if (Interlocked.Exchange(ref _sweepRegistered, 1) == 1) return;
AppDomain.CurrentDomain.ProcessExit += (_, _) =>
{
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
SweepTestDatabases();
};
}
private static void SweepTestDatabases()
{
// A relative Data Source resolves against the current directory, which the runner sets to the output
// directory; both are swept in case they differ.
var directories = new[] { AppContext.BaseDirectory, Environment.CurrentDirectory }
.Select(Path.GetFullPath)
.Distinct(StringComparer.OrdinalIgnoreCase);
foreach (var directory in directories)
{
foreach (var pattern in new[] { "redb_tests_*.db*", "redb_diag_*.db*" })
{
string[] files;
try { files = Directory.GetFiles(directory, pattern); }
catch (IOException) { continue; }
catch (UnauthorizedAccessException) { continue; }
foreach (var file in files)
{
if (!(file.EndsWith(".db", StringComparison.OrdinalIgnoreCase)
|| file.EndsWith(".db-wal", StringComparison.OrdinalIgnoreCase)
|| file.EndsWith(".db-shm", StringComparison.OrdinalIgnoreCase)))
continue;
try { File.Delete(file); }
catch (IOException) { /* open in another process or connection */ }
catch (UnauthorizedAccessException) { }
}
}
}
}
}
Path: redb/redb.Tests.Integration/GlobalUsings.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/GlobalUsings.cs
----
global using Xunit;
global using AwesomeAssertions;
Path: redb/redb.Tests.Integration/Helpers/CommandCounter.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/Helpers/CommandCounter.cs
----
using System.Diagnostics;
using redb.Core.Diagnostics;
namespace redb.Tests.Integration.Helpers;
///
/// Counts the database commands an action runs: the spans of the redb.Core ActivitySource (one per command) under a
/// parent span of the caller only, so commands of tests running in parallel are not counted.
///
public static class CommandCounter
{
private const string ProbeName = "redb.Tests.CommandCount";
private static readonly ActivitySource Probe = new(ProbeName);
/// The database commands runs.
public static Task CountAsync(Func action) => CountAsync(action, excluded: null);
///
/// The commands runs other than scalar side commands (db.operation = scalar): its
/// data statements, whatever the provider reads them with, and any metadata it reads. The PostgreSQL statistics guard
/// is such a side command: until the tables have planner statistics it checks them and sets enable_nestloop around a
/// statement with scalar commands, on a recheck interval, so whether a counted call meets it depends on timing.
///
public static Task CountWithoutScalarsAsync(Func action) => CountAsync(action, excluded: RedbTelemetry.Scalar);
private static async Task CountAsync(Func action, string? excluded)
{
var spans = new List();
using var listener = new ActivityListener
{
ShouldListenTo = s => s.Name == RedbActivitySource.SourceName || s.Name == ProbeName,
Sample = (ref ActivityCreationOptions _) => ActivitySamplingResult.AllDataAndRecorded,
ActivityStopped = a => { lock (spans) spans.Add(a); },
};
ActivitySource.AddActivityListener(listener);
ActivityTraceId trace;
using (var parent = Probe.StartActivity("count")!)
{
trace = parent.TraceId;
await action();
}
lock (spans)
return spans.Count(a => a.Source.Name == RedbActivitySource.SourceName && a.TraceId == trace
&& (excluded == null || (a.GetTagItem("db.operation") as string) != excluded));
}
}
Path: redb/redb.Tests.Integration/Helpers/TestDataFactory.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/Helpers/TestDataFactory.cs
----
using redb.Core;
using redb.Core.Models.Entities;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Helpers;
public static class TestDataFactory
{
private static readonly string[] Positions = ["Developer", "Senior Developer", "Manager", "Analyst", "Tester"];
private static readonly string[] Departments = ["Engineering", "Design", "Sales", "Marketing", "Support"];
private static readonly string[] Cities = ["New York", "London", "Berlin", "Tokyo", "Sydney"];
private static readonly string[] Streets = ["Main St", "Oak Ave", "Pine Rd", "Elm St", "Cedar Blvd"];
private static readonly string[][] SkillSets =
[
["C#", "SQL", "Azure"],
["JavaScript", "React", "Node.js"],
["Python", "Django", "PostgreSQL"],
["Java", "Spring", "Docker"],
["TypeScript", "Angular", "AWS"]
];
public static RedbObject CreateSimple(string title = "Test Item", decimal price = 99.99m) => new()
{
name = title,
Props = new SimpleProps
{
Title = title,
Count = 10,
Price = price,
CreatedAt = new DateTime(2025, 6, 15, 10, 30, 0, DateTimeKind.Utc),
IsActive = true,
Code = Guid.NewGuid(),
Description = "Test description"
}
};
public static RedbObject CreateEmployee(
int index,
string? firstName = null,
string? position = null,
decimal? salary = null,
string? department = null,
string? city = null)
{
var pos = position ?? Positions[index % Positions.Length];
var dept = department ?? Departments[index % Departments.Length];
var c = city ?? Cities[index % Cities.Length];
var sal = salary ?? 50000m + index * 5000m;
var fn = firstName ?? $"Employee{index:D3}";
return new RedbObject
{
name = $"{fn} {pos}",
Props = new EmployeeProps
{
FirstName = fn,
LastName = $"Last{index:D3}",
Age = 25 + (index % 30),
HireDate = new DateTime(2020, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMonths(index),
Position = pos,
Salary = sal,
Department = dept,
EmployeeCode = index % 3 == 0 ? null : $"EMP-{index:D4}",
IsRemote = index % 2 == 0,
Rating = index % 4 == 0 ? null : 3.0 + (index % 5) * 0.5,
Skills = SkillSets[index % SkillSets.Length],
SkillLevels = [5 - (index % 3), 4, 3 + (index % 2)],
HomeAddress = new TestAddress
{
City = c,
Street = Streets[index % Streets.Length],
Building = new TestBuildingInfo
{
Floor = 1 + (index % 20),
Name = $"Building {index % 5 + 1}",
Amenities = ["Parking", "Gym"]
}
},
WorkAddress = new TestAddress
{
City = c,
Street = "Office Park 1"
},
Contacts =
[
new TestContact
{
Type = "email",
Value = $"emp{index}@test.com",
IsVerified = true,
Metadata = [new TestContactDetail { Label = "work", Value = "primary" }]
},
new TestContact
{
Type = "phone",
Value = $"+1-555-{index:D4}",
IsVerified = false
}
],
PhoneDirectory = new Dictionary
{
["desk"] = $"555-{1000 + index}",
["mobile"] = $"555-{2000 + index}"
},
OfficeLocations = new Dictionary
{
["HQ"] = new() { City = "New York", Street = "5th Ave" },
["Branch"] = new() { City = c, Street = "Local St" }
},
BonusByYear = new Dictionary
{
[2023] = 5000m + index * 100m,
[2024] = 6000m + index * 150m
},
DepartmentHistory = new Dictionary
{
[dept] = new()
{
Name = dept,
HeadCount = 10 + index,
Projects = [$"Proj-{index}"],
Leaders = [new TestTag { Name = "Lead", Priority = 1 }]
}
},
PerformanceReviews = new Dictionary<(int Year, string Quarter), string>
{
[(2024, "Q1")] = index % 3 == 0 ? "Excellent" : "Good",
[(2024, "Q2")] = "Meets expectations"
}
}
};
}
public static async Task> SeedEmployees(IRedbService redb, int count = 20)
{
var employees = Enumerable.Range(0, count).Select(i => CreateEmployee(i)).ToList();
return await redb.SaveAsync(employees);
}
public static TreeRedbObject CreateTreeNode(
string name, string code, decimal budget = 100000m) => new()
{
name = name,
Props = new TreeNodeProps
{
Name = name,
Description = $"{name} department",
IsActive = true,
Budget = budget,
Code = code
}
};
}
Path: redb/redb.Tests.Integration/Models/AllTextProbeModels.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/Models/AllTextProbeModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// A scheme only PostgresProPvtPrefilterEquivalenceTests.AllOfATextField_ProbeThenCounts_SameAnswers saves into: more objects
/// than the counterexample probe of AllAsync reads (1 000), so its counts decide.
///
[RedbScheme("AllTextProbe")]
public class AllTextProbeProps
{
public string Name { get; set; } = string.Empty;
public string? Note { get; set; }
}
Path: redb/redb.Tests.Integration/Models/ArrayAnyModels.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/Models/ArrayAnyModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// A list of texts next to the arrays of , for Any() over a List<T>.
[RedbScheme("TestArrayAny")]
public class ArrayAnyProps
{
public string Marker { get; set; } = string.Empty;
public List? Labels { get; set; }
public List? Numbers { get; set; }
}
Path: redb/redb.Tests.Integration/Models/ArrayGroupModels.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/Models/ArrayGroupModels.cs
----
using redb.Core.Attributes;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Models;
///
/// GroupByArray over arrays of every simple value column, over an array of classes whose element holds a class
/// and over elements with a missing key. Each test writes its own objects under a fresh and
/// reads them back by it, so objects other tests leave in the shared database do not count.
///
[RedbScheme("TestArrayValues")]
public class ArrayValuesProps
{
public string Marker { get; set; } = string.Empty;
public string[]? Words { get; set; }
public long[]? Longs { get; set; }
public double[]? Doubles { get; set; }
public decimal[]? Decimals { get; set; }
public bool[]? Flags { get; set; }
public DateTime[]? Dates { get; set; }
public Guid[]? Ids { get; set; }
public ArrayItem[]? Items { get; set; }
}
public class ArrayItem
{
/// Null on some elements: the group of the null key.
public string? Kind { get; set; }
public int Size { get; set; }
public bool Active { get; set; }
public ArrayItemPlace? Place { get; set; }
}
public class ArrayItemPlace
{
public string City { get; set; } = string.Empty;
}
///
/// Arrays GroupByArray refuses by name: list items and object references. Never saved; the refusal comes first.
///
[RedbScheme("TestArrayRefusedElements")]
public class ArrayRefusedElementsProps
{
public List? Roles { get; set; }
public RedbObject[]? Links { get; set; }
}
Path: redb/redb.Tests.Integration/Models/ArrayOfClassesAnyModels.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/Models/ArrayOfClassesAnyModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// An array and a list of classes, for Any() with a condition over the fields of an element.
[RedbScheme("TestArrayOfClassesAny")]
public class OrderSheetProps
{
public string Tag { get; set; } = "";
public int Number { get; set; }
public OrderLine[]? Lines { get; set; }
public List? Extra { get; set; }
}
public class OrderLine
{
public string? Kind { get; set; }
public bool? Active { get; set; }
public int Qty { get; set; }
public decimal? Price { get; set; }
public DateTime? Due { get; set; }
public TimeSpan? Wait { get; set; }
}
Path: redb/redb.Tests.Integration/Models/ByteArrayLegacyModels.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/Models/ByteArrayLegacyModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
// ───────────────────────────────────────────────
// Models for the byte[] storage conversion (V4, work Б1): a byte[] at the root and one nested in
// a class, both of which the pre-V4 sync classified as Array-of-Byte. Synced by the tests.
// ───────────────────────────────────────────────
[RedbScheme(Name = "ByteHolder")]
public class ByteHolderProps
{
public byte[]? Root { get; set; }
public ByteAttachment? File { get; set; }
}
public class ByteAttachment
{
public string? Name { get; set; }
public byte[]? Data { get; set; }
}
Path: redb/redb.Tests.Integration/Models/CollectionGroupKeyModels.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/Models/CollectionGroupKeyModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// A list field and the number of the group its list belongs to, in a scheme of its own.
[RedbScheme("TestCollectionGroupKey")]
public class CollectionGroupKeyProps
{
public string? Label { get; set; }
public int Mark { get; set; }
public List? Tags { get; set; }
}
/// A dictionary field and the number of the group its dictionary belongs to, in a scheme of its own.
[RedbScheme("TestCollectionGroupKeyDict")]
public class CollectionGroupKeyDictProps
{
public string? Label { get; set; }
public int Mark { get; set; }
public Dictionary? Codes { get; set; }
}
Path: redb/redb.Tests.Integration/Models/CollectionKindModels.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/Models/CollectionKindModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
// A property whose collection kind changes between two builds of one Props class (CollectionKindChangeTestsBase). As in
// OlderModelModels, the first build saves under its own scheme name and the test renames that scheme to the second's.
[RedbScheme("Kind change: single value, before", Name = "kind_single_before")]
public class KindSingleBeforeProps { public string Tag { get; set; } = ""; public int Level { get; set; } }
[RedbScheme("Kind change: single value to array", Name = "kind_single", Version = 1)]
public class KindSingleToArrayProps { public string Tag { get; set; } = ""; public int[]? Level { get; set; } }
[RedbScheme("Kind change: array, before", Name = "kind_array_before")]
public class KindArrayBeforeProps { public string Tag { get; set; } = ""; public int[]? Items { get; set; } }
[RedbScheme("Kind change: array to single value", Name = "kind_array", Version = 1)]
public class KindArrayToSingleProps { public string Tag { get; set; } = ""; public int Items { get; set; } }
[RedbScheme("Kind change: array, before (to dictionary)", Name = "kind_array_dict_before")]
public class KindArrayDictBeforeProps { public string Tag { get; set; } = ""; public int[]? Items { get; set; } }
[RedbScheme("Kind change: array to dictionary", Name = "kind_array_dict", Version = 1)]
public class KindArrayToDictionaryProps { public string Tag { get; set; } = ""; public Dictionary? Items { get; set; } }
[RedbScheme("Kind change: dictionary, before", Name = "kind_dict_before")]
public class KindDictionaryBeforeProps { public string Tag { get; set; } = ""; public Dictionary? Items { get; set; } }
[RedbScheme("Kind change: dictionary to array", Name = "kind_dict", Version = 1)]
public class KindDictionaryToArrayProps { public string Tag { get; set; } = ""; public int[]? Items { get; set; } }
Path: redb/redb.Tests.Integration/Models/ComputedComparisonModels.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/Models/ComputedComparisonModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// Fields to compare with each other and with values computed from them.
[RedbScheme("TestComputedComparison")]
public class ComputedComparisonProps
{
public string Tag { get; set; } = string.Empty;
public string First { get; set; } = string.Empty;
public string Last { get; set; } = string.Empty;
public string Full { get; set; } = string.Empty;
public int A { get; set; }
public int B { get; set; }
public decimal Price { get; set; }
public decimal Limit { get; set; }
}
Path: redb/redb.Tests.Integration/Models/ConcurrentWriterModels.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/Models/ConcurrentWriterModels.cs
----
using System;
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// A row written by many concurrent writers at once: one new object with a few root values, the shape of a key ring
/// element or a replay reservation. Synced by the tests that use it.
///
[RedbScheme(Name = "ConcurrentWriterRow")]
public class ConcurrentWriterRowProps
{
public string? Tag { get; set; }
public string? Key { get; set; }
public string? Payload { get; set; }
public DateTimeOffset? WrittenAt { get; set; }
}
Path: redb/redb.Tests.Integration/Models/ContainsWalkModels.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/Models/ContainsWalkModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// An array of text read by a page in object order (MsSqlProContainsWalkTests): SQL Server Pro walks the array's rows
/// before the streams answer.
///
[RedbScheme("TestContainsWalk")]
public class ContainsWalkProps
{
public int Age { get; set; }
public string? Department { get; set; }
public string[]? Skills { get; set; }
}
Path: redb/redb.Tests.Integration/Models/CtProbeModels.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/Models/CtProbeModels.cs
----
using System;
using System.Collections.Generic;
using redb.Core.Attributes;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Models;
///
/// Probe scheme for the ChangeTracking save-invariants suite (ревью 2026-09-03, волна 1.2 + Ш1/Ш2).
/// Synced by the tests that use it, not by the fixtures.
///
[RedbScheme(Name = "CtProbe")]
public class CtProbeProps
{
public string? Label { get; set; }
public long[]? Longs { get; set; }
public decimal[]? Decimals { get; set; }
public string?[]? Tags { get; set; }
public Dictionary? Dict { get; set; }
public Dictionary<(int Year, string Quarter), string>? TupleDict { get; set; }
public List? Items { get; set; }
public List>? Refs { get; set; }
public Dictionary>? RefDict { get; set; }
public RedbListItem? Status { get; set; }
public List? Roles { get; set; }
}
public class CtProbeItem
{
public string? Name { get; set; }
public decimal Price { get; set; }
/// Ш4: собственный массив внутри класса-элемента массива (коллекция в коллекции).
public long[]? Codes { get; set; }
/// Ш4: собственный словарь внутри класса-элемента массива.
public Dictionary? Meta { get; set; }
}
/// Отдельная схема-ребёнок для пинов референс-коллекций (Ш2).
[RedbScheme(Name = "CtProbeChild")]
public class CtProbeChildProps
{
public string? Tag { get; set; }
}
Path: redb/redb.Tests.Integration/Models/DeepChainModels.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/Models/DeepChainModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// An element of , for GroupByArray over a deep tree.
public class DeepChainMark
{
public string Kind { get; set; } = string.Empty;
}
/// A node of a chain deeper than 100 levels (MsSqlProDeepTreeTests), on a scheme of its own.
[RedbScheme("TestDeepChain")]
public class DeepChainProps
{
public string Tag { get; set; } = string.Empty;
public int Index { get; set; }
public string Bucket { get; set; } = string.Empty;
public DeepChainMark[]? Marks { get; set; }
}
Path: redb/redb.Tests.Integration/Models/DictionaryEntryLeadsModels.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/Models/DictionaryEntryLeadsModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// Dictionaries whose entries are filtered by their value: a tuple key with a text value, a text key with a number,
/// and a text key with a class. Every other key holds the same values, so an answer that lost the key shows at once.
///
[RedbScheme("dict_entry_leads")]
public class DictionaryEntryLeadsProps
{
public long Rank { get; set; }
public string? Tag { get; set; }
public Dictionary<(int Year, string Quarter), string>? Reviews { get; set; }
public Dictionary? Scores { get; set; }
public Dictionary? Places { get; set; }
}
public class DictionaryEntryPlace
{
public string City { get; set; } = "";
public long Floor { get; set; }
}
Path: redb/redb.Tests.Integration/Models/DictionaryInterfaceModels.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/Models/DictionaryInterfaceModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
// ───────────────────────────────────────────────
// A dictionary field declared through the interface (DataLoss p.3)
// ───────────────────────────────────────────────
[RedbScheme("DictionaryInterfaceProbe")]
public class DictionaryInterfaceProbeProps
{
public string? Label { get; set; }
///
/// Declared as the interface on purpose. The scheme builder accepts IDictionary<K,V>, so
/// the structure becomes a dictionary, and the RUNTIME value decides whether the save path can
/// enumerate it into rows.
///
public IDictionary? Tags { get; set; }
}
Path: redb/redb.Tests.Integration/Models/DictionaryKeyModels.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/Models/DictionaryKeyModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// The value class of the dictionaries of .
public class KeyedEntry
{
public string Name { get; set; } = string.Empty;
public int Rank { get; set; }
}
/// Dictionaries whose value is a class, one per key type, for a filter on a field of an entry.
[RedbScheme("TestDictionaryKeys")]
public class DictionaryKeyProps
{
public string Marker { get; set; } = string.Empty;
public Dictionary? ByText { get; set; }
public Dictionary? ByNumber { get; set; }
public Dictionary<(int Year, string Quarter), KeyedEntry>? ByTuple { get; set; }
public Dictionary? ByFlag { get; set; }
public Dictionary? ByDate { get; set; }
public Dictionary? ByRatio { get; set; }
}
Path: redb/redb.Tests.Integration/Models/DictionaryOrderModels.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/Models/DictionaryOrderModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// Dictionaries at the top level and inside the elements of an array of classes, for the order of their entries.
[RedbScheme("TestDictionaryOrder")]
public class DictionaryOrderProps
{
public string Tag { get; set; } = "";
public Dictionary? Top { get; set; }
public Dictionary? Numbered { get; set; }
public DictionaryOrderRow[]? Rows { get; set; }
}
public class DictionaryOrderRow
{
public string Name { get; set; } = "";
public Dictionary? Labels { get; set; }
}
Path: redb/redb.Tests.Integration/Models/ElementFoldOrderModels.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/Models/ElementFoldOrderModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// A list field and a label, in a scheme of its own.
[RedbScheme("TestElementFoldOrder")]
public class ElementFoldOrderProps
{
public string? Label { get; set; }
public List? Tags { get; set; }
}
/// A dictionary field, in a scheme of its own.
[RedbScheme("TestElementFoldOrderDict")]
public class ElementFoldOrderDictProps
{
public Dictionary? Codes { get; set; }
}
Path: redb/redb.Tests.Integration/Models/ElementIndexModels.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/Models/ElementIndexModels.cs
----
using redb.Core.Attributes;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Models;
///
/// Arrays and lists read by index in a filter. The object's own Name and Rank share their names with the fields of
/// the elements, so a path that lost its element would compare the object's field instead.
///
[RedbScheme("TestElementIndex")]
public class ElementIndexProps
{
public string Marker { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public int Rank { get; set; }
public int[]? Levels { get; set; }
public List? Tags { get; set; }
public ElementIndexItem[]? Items { get; set; }
public List? Parts { get; set; }
public List? Statuses { get; set; }
}
public class ElementIndexItem
{
public string Name { get; set; } = string.Empty;
public int Rank { get; set; }
public int? Score { get; set; }
public ElementIndexInner? Inner { get; set; }
public int[]? Marks { get; set; }
}
public class ElementIndexInner
{
public string Name { get; set; } = string.Empty;
}
Path: redb/redb.Tests.Integration/Models/EnumComparisonModels.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/Models/EnumComparisonModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
public enum ComparisonShade { Red, Green, Blue }
///
/// An enum field, nullable and not, each with a text twin holding the name the enum is stored by: a filter on the enum
/// must return the ids the same filter on the twin returns.
///
[RedbScheme("TestEnumComparison")]
public class EnumComparisonProps
{
public string Tag { get; set; } = string.Empty;
public ComparisonShade? Maybe { get; set; }
public string? MaybeName { get; set; }
public ComparisonShade Always { get; set; }
public string AlwaysName { get; set; } = string.Empty;
}
Path: redb/redb.Tests.Integration/Models/EnumKeyModels.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/Models/EnumKeyModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// An enum key with explicit values out of name order.
public enum KeyShade { Red = 3, Green = 1, Blue = 2 }
/// A flags enum key: a combination is stored as one key.
[Flags]
public enum KeyAccess { None = 0, Read = 1, Write = 2, Admin = 4 }
/// Dictionaries keyed by an enum, a flags enum and a nullable enum.
[RedbScheme("TestEnumKeys")]
public class EnumKeyProps
{
public string Marker { get; set; } = string.Empty;
public Dictionary? ByShade { get; set; }
public Dictionary? EntryByShade { get; set; }
public Dictionary? ByAccess { get; set; }
public Dictionary? ByMaybeShade { get; set; }
}
Path: redb/redb.Tests.Integration/Models/FieldPathModels.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/Models/FieldPathModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// A class whose own field and the field of its array elements share a name: a filter path that lost its array part
/// would read the field of the object instead of the field of the element.
///
[RedbScheme("TestFieldPath")]
public class FieldPathProps
{
public string Name { get; set; } = string.Empty;
public int Rank { get; set; }
public FieldPathItem[]? Items { get; set; }
public List? Parts { get; set; }
public Dictionary? ByKey { get; set; }
public FieldPathItem? Main { get; set; }
public Dictionary? Scores { get; set; }
}
public class FieldPathItem
{
public string Name { get; set; } = string.Empty;
public int Rank { get; set; }
public int? Score { get; set; }
}
Path: redb/redb.Tests.Integration/Models/GraphModels.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/Models/GraphModels.cs
----
using redb.Core.Attributes;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Models;
///
/// A node with two references to nodes of the same scheme: enough to build a graph that is not a tree - two parents
/// sharing one target - which is what the save's hashing and collection must handle.
///
[RedbScheme]
public class GraphNodeProps
{
public string Title { get; set; } = string.Empty;
public RedbObject? Left { get; set; }
public RedbObject? Right { get; set; }
}
Path: redb/redb.Tests.Integration/Models/HashCanonProbeModels.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/Models/HashCanonProbeModels.cs
----
using System;
using System.Collections.Generic;
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// Probe scheme for the hash canon collisions: values whose canon strings would coincide if the canon did not escape
/// its separators. Synced by the tests that use it, not by the fixtures.
///
[RedbScheme(Name = "HashCanonProbe")]
public class HashCanonProbeProps
{
public string? A { get; set; }
public string? B { get; set; }
public string? Label { get; set; }
public List? Tags { get; set; }
public Dictionary? Dict { get; set; }
public HashCanonPair? Inner { get; set; }
public List? Items { get; set; }
}
/// A class value with two strings: a nested class and an element of a class collection.
public class HashCanonPair
{
public string? A { get; set; }
public string? B { get; set; }
}
///
/// A dictionary key class with value equality and no ToString of its own: its ToString is the type name for every
/// key.
///
public class HashCanonKey : IEquatable
{
public string? Code { get; set; }
public int Rank { get; set; }
public bool Equals(HashCanonKey? other) => other is not null && Code == other.Code && Rank == other.Rank;
public override bool Equals(object? obj) => Equals(obj as HashCanonKey);
public override int GetHashCode() => HashCode.Combine(Code, Rank);
}
/// Probe scheme with a dictionary keyed by a class.
[RedbScheme(Name = "HashCanonClassKeyProbe")]
public class HashCanonClassKeyProps
{
public string? Label { get; set; }
public Dictionary? ByKey { get; set; }
}
/// Probe scheme with a dictionary keyed by a value tuple of culture-sensitive members.
[RedbScheme(Name = "HashCanonTupleKeyProbe")]
public class HashCanonTupleKeyProps
{
public string? Label { get; set; }
public Dictionary<(double Rate, DateTime At), string>? ByTuple { get; set; }
}
Path: redb/redb.Tests.Integration/Models/HeaderProbeModels.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/Models/HeaderProbeModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// Props for the props-cache header-freshness pins: a tiny scheme whose objects get their
/// HEADER (name, note, value_unique) changed behind the cache's back by "another node".
///
[RedbScheme(Name = "HeaderProbe")]
public class HeaderProbeProps
{
public string? Title { get; set; }
}
Path: redb/redb.Tests.Integration/Models/IgnoredGetterProbeModels.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/Models/IgnoredGetterProbeModels.cs
----
using System.Collections.Concurrent;
using redb.Core.Attributes;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Models;
///
/// Props with references and two [RedbIgnore] properties whose getters count their reads per object label, so
/// suites running in parallel on several hosts never share a count. One property has a setter: the Pro reference
/// substitution walks read-write properties only.
///
public class IgnoredGetterProbeProps
{
public static readonly ConcurrentDictionary TechnicalReads = new();
private string? _settable;
public string? Label { get; set; }
public List>? Refs { get; set; }
[RedbIgnore]
public string Technical
{
get { CountRead(); return "technical"; }
}
[RedbIgnore]
public string? TechnicalSettable
{
get { CountRead(); return _settable; }
set => _settable = value;
}
private void CountRead() => TechnicalReads.AddOrUpdate(Label ?? "", 1, (_, n) => n + 1);
}
Path: redb/redb.Tests.Integration/Models/IndexDuplicateProbeModels.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/Models/IndexDuplicateProbeModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// A scheme only IndexRepairTestsBase.DuplicateRows_KeepTheIndexUnbuilt_AreListed_AndNothingIsDeleted saves into: one text
/// field, stored as one root row whose copy the test writes by SQL.
///
[RedbScheme("index_duplicate_probe")]
public class IndexDuplicateProbeProps
{
public string Name { get; set; } = string.Empty;
}
Path: redb/redb.Tests.Integration/Models/InterfaceCollectionModels.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/Models/InterfaceCollectionModels.cs
----
using System.Collections.Generic;
namespace redb.Tests.Integration.Models;
// A list declared as IEnumerable, ICollection or IList and a dictionary declared as IDictionary, with a
// numeric element narrower than the stored one (int, short, byte, float, decimal), a nullable element, and a class
// element. One class per shape; no [RedbScheme], the tests sync them.
public class IfaceIEnumerableOfIntProps { public IEnumerable? Value { get; set; } }
public class IfaceIEnumerableOfShortProps { public IEnumerable? Value { get; set; } }
public class IfaceIEnumerableOfByteProps { public IEnumerable? Value { get; set; } }
public class IfaceIEnumerableOfFloatProps { public IEnumerable? Value { get; set; } }
public class IfaceIEnumerableOfDecimalProps { public IEnumerable? Value { get; set; } }
public class IfaceICollectionOfIntProps { public ICollection? Value { get; set; } }
public class IfaceICollectionOfShortProps { public ICollection? Value { get; set; } }
public class IfaceICollectionOfByteProps { public ICollection? Value { get; set; } }
public class IfaceICollectionOfFloatProps { public ICollection? Value { get; set; } }
public class IfaceICollectionOfDecimalProps { public ICollection? Value { get; set; } }
public class IfaceIListOfIntProps { public IList? Value { get; set; } }
public class IfaceIListOfShortProps { public IList? Value { get; set; } }
public class IfaceIListOfByteProps { public IList? Value { get; set; } }
public class IfaceIListOfFloatProps { public IList? Value { get; set; } }
public class IfaceIListOfDecimalProps { public IList? Value { get; set; } }
public class IfaceIDictionaryOfIntProps { public IDictionary? Value { get; set; } }
public class IfaceIDictionaryOfShortProps { public IDictionary? Value { get; set; } }
public class IfaceIDictionaryOfByteProps { public IDictionary? Value { get; set; } }
public class IfaceIDictionaryOfFloatProps { public IDictionary? Value { get; set; } }
public class IfaceIDictionaryOfDecimalProps { public IDictionary? Value { get; set; } }
public class IfaceIListOfNullableIntProps { public IList? Value { get; set; } }
public class IfaceItem { public string? Name { get; set; } public int Count { get; set; } }
public class IfaceIListOfClassProps { public IList? Value { get; set; } }
public class IfaceICollectionOfClassProps { public ICollection? Value { get; set; } }
public class IfaceIEnumerableOfClassProps { public IEnumerable? Value { get; set; } }
public class IfaceIListOfReferenceProps { public IList>? Value { get; set; } }
public class IfaceIEnumerableOfReferenceProps { public IEnumerable>? Value { get; set; } }
Path: redb/redb.Tests.Integration/Models/KeyDrawModels.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/Models/KeyDrawModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
/// An object with scalars, an array of simple values, an array of classes and a nested class.
[RedbScheme("Key draw", Name = "test_key_draw")]
public class KeyDrawProps
{
public string Tag { get; set; } = "";
public int Score { get; set; }
public int[]? Levels { get; set; }
public List? Lines { get; set; }
public KeyDrawLine? Main { get; set; }
}
public class KeyDrawLine
{
public string Name { get; set; } = "";
public int Rank { get; set; }
}
Path: redb/redb.Tests.Integration/Models/KeywordNameModels.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/Models/KeywordNameModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// Property names that differ from a C# keyword only by case (ref, default, event, string, object). C# keywords are
/// case-sensitive, so these are ordinary property names. PostgreSQL refused them at scheme sync ("Field name is a C#
/// reserved word"), which compared the name in lower case. Every [RedbScheme] type syncs when a fixture starts, so the
/// old refusal stopped the whole PostgreSQL suite.
///
[RedbScheme("keyword_names")]
public class KeywordNamesProps
{
public long Ref { get; set; }
public string Default { get; set; } = "";
public DateTime Event { get; set; }
public string? String { get; set; }
public decimal Object { get; set; }
}
Path: redb/redb.Tests.Integration/Models/LazyOptionModels.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/Models/LazyOptionModels.cs
----
using redb.Core.Attributes;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Models;
///
/// V4 Л2 (LAZY_REFERENCES_PLAN §3.2–3.3): the `virtual` marker under test. and
/// are virtual references — with the option on the builders emit stubs for
/// them regardless of depth; is deliberately NOT virtual and always loads
/// eagerly. Self-referencing, so one scheme covers chains and collections.
///
[RedbScheme]
public class LazyOptionNodeProps
{
public string? Label { get; set; }
/// Virtual reference — lazy when the option is on.
public virtual RedbObject? Next { get; set; }
/// NOT virtual — always eager, whatever the option says.
public RedbObject? Plain { get; set; }
/// Virtual collection of references — a list of stubs when the option is on.
public virtual List>? Children { get; set; }
}
Path: redb/redb.Tests.Integration/Models/LazyReferenceModels.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/Models/LazyReferenceModels.cs
----
using redb.Core.Attributes;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Models;
///
/// Self-referencing node for the V4 Л1 lazy-reference scenarios (LAZY_REFERENCES_PLAN §6):
/// one scheme gives chains of any depth () and collections of references
/// (). The [RedbScheme] marker matters: the Pro stub materializer resolves
/// the CLR type for a nested reference through the attribute-driven registry.
///
[RedbScheme]
public class LazyNodeProps
{
public string? Label { get; set; }
/// A single reference — the stub scenario.
public RedbObject? Next { get; set; }
/// A collection of references — the list-of-stubs scenario.
public List>? Children { get; set; }
///
/// A nested class: depth counts reference hops, never class nesting, so a class field is loaded
/// completely at any depth — by the SQL builders and the Pro materializer alike.
///
public LazyNodeMeta? Meta { get; set; }
}
public class LazyNodeMeta
{
public string? Tag { get; set; }
}
Path: redb/redb.Tests.Integration/Models/LikeEscapingModels.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/Models/LikeEscapingModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// Probe scheme for the LIKE-metacharacter escaping suite (BR-7, 2026-09-02).
/// Synced by the tests that use it, not by the fixtures.
///
[RedbScheme(Name = "LikeProbe")]
public class LikeProbeProps
{
public string? S { get; set; }
}
Path: redb/redb.Tests.Integration/Models/MigrationLiteralProbeModels.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/Models/MigrationLiteralProbeModels.cs
----
using redb.Core.Attributes;
using redb.Core.Pro.Migration;
namespace redb.Tests.Integration.Models;
public enum MigrationLiteralKind
{
First,
Second,
}
///
/// One field per kind of value a migration writes as a SQL literal: MigrationTestsBase fills each by DefaultValue and
/// by a constant in a ComputedFrom lambda, then reads it back and filters on it as a saved value.
///
[RedbScheme("Migrations: literal probe", Name = "migration_literal_probe")]
public class MigrationLiteralProbeProps
{
public string? Text { get; set; }
public double? Real { get; set; }
public decimal? Money { get; set; }
public long? Count { get; set; }
public Guid? Key { get; set; }
public DateTime? At { get; set; }
public DateTimeOffset? Seen { get; set; }
public DateOnly? Day { get; set; }
public TimeOnly? Clock { get; set; }
public TimeSpan? Span { get; set; }
public MigrationLiteralKind? Kind { get; set; }
public byte[]? Blob { get; set; }
}
/// The values of the literal probe; the negative numbers catch a culture's minus sign.
public static class MigrationLiteralValues
{
public const string Text = "it's C:\\path\\ 'quoted' \\' end Привет";
public const double Real = -1234.5;
public const decimal Money = -9876.54m;
public const long Count = -42;
public static readonly Guid Key = new("8f14e45f-ceea-467a-9a36-dedd4bea2543");
public static readonly DateTime At = new(2026, 5, 17, 10, 30, 15, DateTimeKind.Utc);
public static readonly DateTimeOffset Seen = new(2026, 5, 17, 13, 30, 15, TimeSpan.FromHours(3));
public static readonly DateOnly Day = new(2026, 5, 17);
public static readonly TimeOnly Clock = new(10, 30, 15);
public static readonly TimeSpan Span = new(1, 2, 3, 4);
public const MigrationLiteralKind Kind = MigrationLiteralKind.Second;
public static readonly byte[] Blob = [0x00, 0xFF, 0x10, 0x27];
/// The kind the two migrations below act on; set by the test before it migrates.
public static readonly AsyncLocal Current = new();
}
/// DefaultValue of the field named by .
public class MigrationLiteralDefaultMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
switch (MigrationLiteralValues.Current.Value)
{
case nameof(MigrationLiteralProbeProps.Text): builder.Property(p => p.Text).DefaultValue(MigrationLiteralValues.Text); break;
case nameof(MigrationLiteralProbeProps.Real): builder.Property(p => p.Real).DefaultValue(MigrationLiteralValues.Real); break;
case nameof(MigrationLiteralProbeProps.Money): builder.Property(p => p.Money).DefaultValue(MigrationLiteralValues.Money); break;
case nameof(MigrationLiteralProbeProps.Count): builder.Property(p => p.Count).DefaultValue(MigrationLiteralValues.Count); break;
case nameof(MigrationLiteralProbeProps.Key): builder.Property(p => p.Key).DefaultValue(MigrationLiteralValues.Key); break;
case nameof(MigrationLiteralProbeProps.At): builder.Property(p => p.At).DefaultValue(MigrationLiteralValues.At); break;
case nameof(MigrationLiteralProbeProps.Seen): builder.Property(p => p.Seen).DefaultValue(MigrationLiteralValues.Seen); break;
case nameof(MigrationLiteralProbeProps.Day): builder.Property(p => p.Day).DefaultValue(MigrationLiteralValues.Day); break;
case nameof(MigrationLiteralProbeProps.Clock): builder.Property(p => p.Clock).DefaultValue(MigrationLiteralValues.Clock); break;
case nameof(MigrationLiteralProbeProps.Span): builder.Property(p => p.Span).DefaultValue(MigrationLiteralValues.Span); break;
case nameof(MigrationLiteralProbeProps.Kind): builder.Property(p => p.Kind).DefaultValue(MigrationLiteralValues.Kind); break;
case nameof(MigrationLiteralProbeProps.Blob): builder.Property(p => p.Blob).DefaultValue(MigrationLiteralValues.Blob); break;
case "Null": builder.Property(p => p.Text).DefaultValue(null); break;
default: throw new InvalidOperationException($"No literal probe for '{MigrationLiteralValues.Current.Value}'.");
}
}
}
///
/// ComputedFrom keeping a stored value and putting a constant where there is none. Numbers, text and the enum are C#
/// literals (a constant node); the other kinds can only be a captured or static value.
///
public class MigrationLiteralComputedMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
switch (MigrationLiteralValues.Current.Value)
{
case nameof(MigrationLiteralProbeProps.Text): builder.Property(p => p.Text).ComputedFrom(p => p.Text ?? "it's C:\\path\\ 'quoted' \\' end Привет"); break;
case nameof(MigrationLiteralProbeProps.Real): builder.Property(p => p.Real).ComputedFrom(p => p.Real ?? -1234.5); break;
case nameof(MigrationLiteralProbeProps.Money): builder.Property(p => p.Money).ComputedFrom(p => p.Money ?? -9876.54m); break;
case nameof(MigrationLiteralProbeProps.Count): builder.Property(p => p.Count).ComputedFrom(p => p.Count ?? -42L); break;
case nameof(MigrationLiteralProbeProps.Key): builder.Property(p => p.Key).ComputedFrom(p => p.Key ?? MigrationLiteralValues.Key); break;
case nameof(MigrationLiteralProbeProps.At): builder.Property(p => p.At).ComputedFrom(p => p.At ?? MigrationLiteralValues.At); break;
case nameof(MigrationLiteralProbeProps.Seen): builder.Property(p => p.Seen).ComputedFrom(p => p.Seen ?? MigrationLiteralValues.Seen); break;
case nameof(MigrationLiteralProbeProps.Day): builder.Property(p => p.Day).ComputedFrom(p => p.Day ?? MigrationLiteralValues.Day); break;
case nameof(MigrationLiteralProbeProps.Clock): builder.Property(p => p.Clock).ComputedFrom(p => p.Clock ?? MigrationLiteralValues.Clock); break;
case nameof(MigrationLiteralProbeProps.Span): builder.Property(p => p.Span).ComputedFrom(p => p.Span ?? MigrationLiteralValues.Span); break;
case nameof(MigrationLiteralProbeProps.Kind): builder.Property(p => p.Kind).ComputedFrom(p => p.Kind ?? MigrationLiteralKind.Second); break;
case nameof(MigrationLiteralProbeProps.Blob): builder.Property(p => p.Blob).ComputedFrom(p => p.Blob ?? MigrationLiteralValues.Blob); break;
default: throw new InvalidOperationException($"No literal probe for '{MigrationLiteralValues.Current.Value}'.");
}
}
}
Path: redb/redb.Tests.Integration/Models/MigrationProbeModels.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/Models/MigrationProbeModels.cs
----
using redb.Core.Attributes;
using redb.Core.Pro.Migration;
namespace redb.Tests.Integration.Models;
///
/// Props for the Pro data-migration suite: TotalPrice is recomputed from Quantity * Price.
///
[RedbScheme("Миграции: пробный объект", Name = "migration_probe")]
public class MigrationProbeProps
{
public long Quantity { get; set; }
public double Price { get; set; }
public double TotalPrice { get; set; }
}
///
/// The migration under test — the canonical ComputedFrom case from the Pro docs.
///
public class MigrationProbeMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.TotalPrice)
.ComputedFrom(p => p.Quantity * p.Price);
}
}
///
/// Props for the DefaultValue and Transform migrations: one string field each, so the two
/// migrations of the suite never touch each other's rows.
///
[RedbScheme("Migrations: default value and transform probe", Name = "migration_edit_probe")]
public class MigrationEditProbeProps
{
public string? Status { get; set; }
public string? Phone { get; set; }
public bool Enabled { get; set; }
public DateTime? Due { get; set; }
public DateTimeOffset? Seen { get; set; }
}
/// DefaultValue of a DateTime and a DateTimeOffset: the literal must be what the engine stores.
public class MigrationDateDefaultValueMigration : IRedbMigration
{
public static readonly DateTime DueDefault = new(2026, 5, 17, 10, 30, 15, DateTimeKind.Utc);
public static readonly DateTimeOffset SeenDefault = new(2026, 5, 17, 13, 30, 15, TimeSpan.FromHours(3));
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.Due).DefaultValue(DueDefault);
builder.Property(p => p.Seen).DefaultValue(SeenDefault);
}
}
/// DefaultValue: fills the stored rows of Status that hold no value.
public class MigrationDefaultValueMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.Status).DefaultValue("Active");
}
}
/// DefaultValue of a bool: the literal is the engine's own (SQL Server has no TRUE).
public class MigrationBoolDefaultValueMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.Enabled).DefaultValue(true);
}
}
/// Transform: rewrites Phone in place.
public class MigrationTransformMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.Phone).Transform(v => v.Replace("-", ""));
}
}
///
/// Props for ComputedFrom on a [RedbUnique] target: the migration rewrites the value, so the stored key
/// of the old value must not stay behind.
///
[RedbScheme("Migrations: computed unique key probe", Name = "migration_unique_probe")]
public class MigrationUniqueProbeProps
{
public long Quantity { get; set; }
public double Price { get; set; }
[RedbUnique]
public double TotalPrice { get; set; }
}
/// ComputedFrom onto the key field.
public class MigrationUniqueProbeMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.TotalPrice)
.ComputedFrom(p => p.Quantity * p.Price);
}
}
Path: redb/redb.Tests.Integration/Models/MigrationTargetProbeModels.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/Models/MigrationTargetProbeModels.cs
----
using redb.Core.Attributes;
using redb.Core.Pro.Migration;
namespace redb.Tests.Integration.Models;
///
/// Probes how the migration DSL ADDRESSES a field that is not a root scheme field: a member of a
/// nested class and a member of an array element.
///
/// Written for review finding PR-32, which states that the compiled migration SQL correlates the
/// source subquery by object id and structure id only, carrying neither _array_index nor
/// _parent_value_id. That finding only bites if such a target is reachable through the DSL
/// at all, so this suite establishes reachability first and records the observed behaviour.
///
///
/// Field names are deliberately distinct between levels (GrandTotal at the root,
/// LineTotal inside) so a DSL that flattens a dotted path to its leaf name cannot silently
/// resolve to the root field of the same shape.
///
///
[RedbScheme("Миграции: вложенная цель", Name = "migration_target_probe")]
public class MigrationTargetProbeProps
{
public double Base { get; set; }
public double Multiplier { get; set; }
public double GrandTotal { get; set; }
public LineTargetProps? Details { get; set; }
public List Items { get; set; } = new();
}
/// Nested (non-array) member and the array element member.
public class LineTargetProps
{
public double Qty { get; set; }
public double Price { get; set; }
public double LineTotal { get; set; }
}
/// Control: both target and sources are ROOT fields — the shape every existing migration test uses.
public class MigrationTargetRootMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.GrandTotal)
.ComputedFrom(p => p.Base * p.Multiplier);
}
}
/// Nested-class target and nested sources.
public class MigrationTargetNestedMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.Details!.LineTotal)
.ComputedFrom(p => p.Details!.Qty * p.Details!.Price);
}
}
/// Array-element target and array-element sources.
public class MigrationTargetArrayMigration : IRedbMigration
{
public void Configure(IMigrationBuilder builder)
{
builder.Property(p => p.Items[0].LineTotal)
.ComputedFrom(p => p.Items[0].Qty * p.Items[0].Price);
}
}
Path: redb/redb.Tests.Integration/Models/ModuleUnloadModels.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/Models/ModuleUnloadModels.cs
----
using redb.Core.Attributes;
using redb.Core.Interception;
namespace redb.Tests.Integration.Models;
///
/// The Props type of a "module": the module unload test loads this assembly again into a collectible
/// AssemblyLoadContext and works with the copy of this type found there.
///
[RedbScheme(Name = "test.module_unload")]
public class ModuleUnloadProps
{
public string Title { get; set; } = "";
}
/// The save interceptor of the "module" (see ).
public sealed class ModuleUnloadInterceptor : IRedbSaveInterceptor
{
public int Saved;
public int Deleted;
public Task SavedAsync(RedbSavedContext context, CancellationToken cancellationToken = default)
{
Interlocked.Increment(ref Saved);
return Task.CompletedTask;
}
public Task DeletedAsync(RedbDeletedContext context, CancellationToken cancellationToken = default)
{
Interlocked.Increment(ref Deleted);
return Task.CompletedTask;
}
}
Path: redb/redb.Tests.Integration/Models/NestedCollectionModels.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/Models/NestedCollectionModels.cs
----
using System.Collections.Generic;
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
// A collection directly inside a collection, and a multi-dimensional array: the scheme sync refuses them. The refused
// classes carry no [RedbScheme], so that the start of a test service, which syncs every [RedbScheme] class it finds,
// does not meet them; their scheme name is the full class name.
public class NestedListOfListsProps
{
public List>? Value { get; set; }
}
public class NestedJaggedArrayProps
{
public int[][]? Value { get; set; }
}
public class NestedListOfArraysProps
{
public List? Value { get; set; }
}
public class NestedListOfDictionariesProps
{
public List>? Value { get; set; }
}
public class NestedArrayOfDictionariesProps
{
public Dictionary[]? Value { get; set; }
}
public class NestedDictionaryOfListsProps
{
public Dictionary>? Value { get; set; }
}
public class NestedDictionaryOfDictionariesProps
{
public Dictionary>? Value { get; set; }
}
public class NestedMultidimensionalArrayProps
{
public int[,]? Value { get; set; }
}
/// A refused property below a class element of a collection: the sync walks into the element class.
public class NestedInsideElementProps
{
public List? Items { get; set; }
}
public class NestedGridHolder
{
public string Name { get; set; } = "";
public List>? Grid { get; set; }
}
// Allowed and pinned: byte[] as an element or value is one value; a collection inside a class element is stored.
[RedbScheme("TestNestedBytesCollections")]
public class NestedBytesCollectionsProps
{
public List? Chunks { get; set; }
public Dictionary? Blobs { get; set; }
}
[RedbScheme("TestNestedCollectionInElement")]
public class NestedCollectionInElementProps
{
public List? Items { get; set; }
public Dictionary? ByKey { get; set; }
}
public class NestedTaggedItem
{
public string Name { get; set; } = "";
public List? Tags { get; set; }
public Dictionary? Scores { get; set; }
}
// The shapes 4.8.0 synced such properties to: a collection of String (of Long for int[,]) with no children. A scheme
// synced from these stands for one synced by 4.8.0; a save of the refused class against it must refuse too.
[RedbScheme("TestNestedSaveGuardList")]
public class NestedSaveGuardListShape
{
public List? Value { get; set; }
}
[RedbScheme("TestNestedSaveGuardDictionary")]
public class NestedSaveGuardDictionaryShape
{
public Dictionary? Value { get; set; }
}
[RedbScheme("TestNestedSaveGuardGrid")]
public class NestedSaveGuardGridShape
{
public List? Value { get; set; }
}
Path: redb/redb.Tests.Integration/Models/NullComparisonModels.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/Models/NullComparisonModels.cs
----
using System;
using redb.Core.Attributes;
using redb.Core.Models.Entities;
namespace redb.Tests.Integration.Models;
///
/// Pairs of nullable fields of every kind a filter compares: a number, a text, a date, a flag and a list item, each
/// left empty on objects of its own period, so a filter meets objects without a value on one side, the other or both.
///
[RedbScheme("TestNullComparisons")]
public class NullComparisonProps
{
public string Tag { get; set; } = string.Empty;
public int? N { get; set; }
public int? N2 { get; set; }
public string? S { get; set; }
public string? S2 { get; set; }
public DateTime? D { get; set; }
public DateTime? D2 { get; set; }
public bool? B { get; set; }
public bool? B2 { get; set; }
public RedbListItem? L { get; set; }
public RedbListItem? L2 { get; set; }
}
public enum ContainsColor { Red, Green, Blue }
/// A nullable field of every value type a Props field can have, for Contains over a list of that type.
[RedbScheme("TestContainsTypes")]
public class ContainsTypesProps
{
public string Tag { get; set; } = string.Empty;
public long? I64 { get; set; }
public int? I32 { get; set; }
public short? I16 { get; set; }
public byte? U8 { get; set; }
public double? F64 { get; set; }
public float? F32 { get; set; }
public decimal? Dec { get; set; }
public bool? Flag { get; set; }
public char? Ch { get; set; }
public string? Text { get; set; }
public Guid? Id { get; set; }
public DateTime? Dt { get; set; }
public DateTimeOffset? Dto { get; set; }
public DateOnly? Day { get; set; }
public TimeOnly? Time { get; set; }
public TimeSpan? Span { get; set; }
public ContainsColor? Color { get; set; }
}
Path: redb/redb.Tests.Integration/Models/NullableCollectionModels.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/Models/NullableCollectionModels.cs
----
using System;
using System.Collections.Generic;
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
///
/// Dictionaries, arrays and lists of nullable value types, each with a null among the values, and a dictionary of a
/// class whose nullable field is null in one entry: everything must read back as saved, the nulls in place.
///
[RedbScheme("TestNullableCollections")]
public class NullableCollectionsProps
{
public string Tag { get; set; } = string.Empty;
public Dictionary? Ints { get; set; }
public Dictionary? Longs { get; set; }
public Dictionary? Decimals { get; set; }
public Dictionary? Dates { get; set; }
public Dictionary? Flags { get; set; }
public Dictionary? Guids { get; set; }
public int?[]? IntArray { get; set; }
public List? LongList { get; set; }
public List? DecimalList { get; set; }
public bool?[]? FlagArray { get; set; }
public Dictionary? Entries { get; set; }
}
public class NullableCollectionsEntry
{
public string Name { get; set; } = string.Empty;
public int? Score { get; set; }
public DateTime? At { get; set; }
public int?[]? Marks { get; set; }
}
Path: redb/redb.Tests.Integration/Models/OlderModelModels.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/Models/OlderModelModels.cs
----
using redb.Core.Attributes;
namespace redb.Tests.Integration.Models;
// A newer and an older build of one Props class, for the older-model suite (OlderModelTestsBase). Two classes cannot
// share one scheme name in a process (ClrSchemeTypeIndex), so the newer class syncs and saves under its own name and
// the test renames that scheme to the older class's name: the older class then meets exactly the structures and values
// the newer build left.
///