Bundle: redb / redb.Tests.Integration (redb.Tests.Integration.2.txt), 828 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/Tests/MsSql/MsSqlMaterializationFidelityTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlMaterializationFidelityTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlMaterializationFidelityTests : MaterializationFidelityTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlModuleSmokeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlModuleSmokeTests.cs
----
using System.Text.RegularExpressions;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using redb.Tests.Integration.Fixtures;
namespace redb.Tests.Integration.Tests.MsSql;
///
/// Runs the SQL module's own smoke runner, redb.MSSql/sql/v2-pvt/99_smoke_auto.sql , against the fixture
/// database (review SQ-4). It was run by hand only, so nothing kept it passing. It builds SQL for a table of filter
/// cases over the test model corpus, asserts shapes, and raises at the end when any case failed; the PRINT lines
/// name the cases and are attached to the failure.
///
[Collection("MsSql")]
public class MsSqlModuleSmokeTests
{
// Ensures the fixture has initialized the database (schemes, module) before the script runs.
public MsSqlModuleSmokeTests(MsSqlFixture fixture) => _ = fixture.Redb;
[Fact]
public async Task TheModuleSmokeRunner_Passes()
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
var script = await File.ReadAllTextAsync(Path.Combine(AppContext.BaseDirectory, "Smoke", "mssql_99_smoke_auto.sql"));
var printed = new List();
// One connection for every batch: the runner keeps its cases in a #temp table.
await using var connection = new SqlConnection(cs);
connection.InfoMessage += (_, e) => printed.Add(e.Message);
await connection.OpenAsync();
try
{
foreach (var batch in Regex.Split(script, @"^\s*GO\s*$", RegexOptions.Multiline | RegexOptions.IgnoreCase))
{
if (string.IsNullOrWhiteSpace(batch)) continue;
await using var command = new SqlCommand(batch, connection) { CommandTimeout = 600 };
await command.ExecuteNonQueryAsync();
}
}
catch (SqlException ex)
{
throw new Xunit.Sdk.XunitException(
ex.Message + Environment.NewLine + string.Join(Environment.NewLine, printed.Where(IsFailure)));
}
printed.Where(IsFailure).Should().BeEmpty();
}
// "FAIL [scheme / case] ...", "INSPECT [...] FAILED: ...", "SHAPE-FAIL ..." - not a summary such as "fail: 0".
private static bool IsFailure(string line) =>
line.StartsWith("FAIL [", StringComparison.Ordinal)
|| line.Contains(" FAILED", StringComparison.Ordinal)
|| line.Contains("SHAPE-FAIL", StringComparison.Ordinal);
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlNestedDictionaryFilterTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlNestedDictionaryFilterTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlNestedDictionaryFilterTests : NestedDictionaryFilterTestsBase
{
public MsSqlNestedDictionaryFilterTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlNullComparisonTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlNullComparisonTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlNullComparisonTests : NullComparisonTestsBase
{
public MsSqlNullComparisonTests(MsSqlFixture fixture) : base(fixture.Redb) { }
protected override bool NegatedListItemTakesObjectsWithoutItem => true;
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlNullableCollectionsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlNullableCollectionsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlNullableCollectionsTests : NullableCollectionsTestsBase
{
public MsSqlNullableCollectionsTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderAbsentValueTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderAbsentValueTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlOrderAbsentValueTests : OrderAbsentValueTestsBase
{
public MsSqlOrderAbsentValueTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderPositionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderPositionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlOrderPositionTests : FreeOrderPositionTestsBase
{
public MsSqlOrderPositionTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlOrderingTests : OrderingTestsBase
{
public MsSqlOrderingTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrphanTransactionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrphanTransactionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlOrphanTransactionTests : OrphanTransactionTestsBase
{
public MsSqlOrphanTransactionTests(MsSqlFixture fixture) : base(fixture.ServiceProvider) { }
protected override string FailingBatchThatOpensATransaction =>
"BEGIN TRANSACTION; RAISERROR(N'redb orphan-transaction probe', 16, 1);";
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlParallelImportFinishTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlParallelImportFinishTests.cs
----
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
/// on SQL Server, scratch databases dropped afterwards.
public class MsSqlParallelImportFinishTests : ParallelImportFinishTestsBase, IAsyncLifetime
{
private string _server = null!;
private readonly List _databases = [];
private readonly List _files = [];
protected override string ProviderName => "mssql";
public Task InitializeAsync()
{
_server = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
return Task.CompletedTask;
}
public async Task DisposeAsync()
{
SqlConnection.ClearAllPools();
foreach (var database in _databases)
await ExecuteAsync(Master(),
$"IF DB_ID('{database}') IS NOT NULL BEGIN ALTER DATABASE [{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{database}] END");
foreach (var file in _files)
File.Delete(file);
}
protected override async Task NewDatabaseAsync(string suffix)
{
var name = $"redb_export_fin_{Guid.NewGuid().ToString("N")[..12]}_{suffix}";
_databases.Add(name);
await ExecuteAsync(Master(), $"CREATE DATABASE [{name}]");
return new SqlConnectionStringBuilder(_server) { InitialCatalog = name }.ConnectionString;
}
protected override ServiceProvider Build(string cs)
{
var services = new ServiceCollection();
services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning));
services.AddRedb(options => options.UseMsSql(cs).Configure(c => c.CacheDomain = $"fin-{Guid.NewGuid():N}"));
return services.BuildServiceProvider();
}
protected override string NewFile()
{
var file = Path.Combine(Path.GetTempPath(), $"redb-export-fin-{Guid.NewGuid():N}.redb");
_files.Add(file);
return file;
}
protected override async Task ScalarAsync(string cs, string sql)
{
await using var connection = new SqlConnection(cs);
await connection.OpenAsync();
await using var command = new SqlCommand(sql, connection);
return Convert.ToString(await command.ExecuteScalarAsync());
}
protected override Task DropSequenceAsync(string cs) => ExecuteAsync(cs, "DROP SEQUENCE [dbo].[global_identity]");
protected override async Task> ShapeAsync(string cs)
{
var lines = new List();
await using var connection = new SqlConnection(cs);
await connection.OpenAsync();
foreach (var sql in new[]
{
"""
SELECT 'index ' + t.name + '.' + i.name + ' disabled=' + CAST(i.is_disabled AS varchar(1))
FROM sys.indexes i JOIN sys.tables t ON t.object_id = i.object_id
WHERE i.name IS NOT NULL ORDER BY 1
""",
"SELECT 'fk ' + name + ' disabled=' + CAST(is_disabled AS varchar(1)) + ' untrusted=' + CAST(is_not_trusted AS varchar(1)) FROM sys.foreign_keys ORDER BY 1",
"SELECT 'trigger ' + name + ' disabled=' + CAST(is_disabled AS varchar(1)) FROM sys.triggers ORDER BY 1",
})
{
await using var command = new SqlCommand(sql, connection);
await using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
lines.Add(reader.GetString(0));
}
return lines;
}
private string Master() => new SqlConnectionStringBuilder(_server) { InitialCatalog = "master" }.ConnectionString;
private static async Task ExecuteAsync(string cs, string sql)
{
await using var connection = new SqlConnection(cs);
await connection.OpenAsync();
await using var command = new SqlCommand(sql, connection);
await command.ExecuteNonQueryAsync();
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPasswordHasherDefaultTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlPasswordHasherDefaultTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlPasswordHasherDefaultTests : PasswordHasherDefaultTestsBase
{
public MsSqlPasswordHasherDefaultTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPolymorphicTreeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlPolymorphicTreeTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlPolymorphicTreeTests : PolymorphicTreeTestsBase
{
public MsSqlPolymorphicTreeTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlProCancellationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlProCancellationTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSqlPro")]
public class MsSqlProCancellationTests : CancellationTestsBase
{
public MsSqlProCancellationTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override string? SleepSql => "WAITFOR DELAY '00:00:30'";
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlProQueryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlProQueryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlProQueryTests : ProQueryTestsBase
{
public MsSqlProQueryTests(MsSqlFixture fixture) : base(fixture.Redb, isPro: false) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlProjectionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlProjectionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlProjectionTests : ProjectionTestsBase
{
public MsSqlProjectionTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropertyRenameTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropertyRenameTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlPropertyRenameTests : PropertyRenameTestsBase
{
public MsSqlPropertyRenameTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheHeaderTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheHeaderTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlPropsCacheHeaderTests : PropsCacheHeaderTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheSkipValidationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheSkipValidationTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlPropsCacheSkipValidationTests : PropsCacheSkipValidationTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheTransactionKeepTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheTransactionKeepTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlPropsCacheTransactionKeepTests : PropsCacheTransactionKeepTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheTransactionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheTransactionTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlPropsCacheTransactionTests : PropsCacheTransactionTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryOrderTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryOrderTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlQueryOrderTests : QueryOrderTestsBase
{
public MsSqlQueryOrderTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryPlannerBlockTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryPlannerBlockTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlQueryPlannerBlockTests : FreeQueryPlannerBlockTestsBase
{
public MsSqlQueryPlannerBlockTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryRowsAsJsonTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryRowsAsJsonTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlQueryRowsAsJsonTests : QueryRowsAsJsonTestsBase
{
public MsSqlQueryRowsAsJsonTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlReaderConnectionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlReaderConnectionTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlReaderConnectionTests : ReaderConnectionTestsBase
{
protected override string SlowScalarSql => "WAITFOR DELAY '00:00:02'; SELECT CAST(1 AS bigint)";
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlReferenceListSaveTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlReferenceListSaveTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlReferenceListSaveTests : ReferenceListSaveTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlReferenceStubTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlReferenceStubTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlReferenceStubTests : ReferenceStubTestsBase
{
public MsSqlReferenceStubTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlRegexQueryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlRegexQueryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlRegexQueryTests : RegexQueryTestsBase
{
public MsSqlRegexQueryTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveGraphHashTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveGraphHashTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlSaveGraphHashTests : SaveGraphHashTestsBase
{
public MsSqlSaveGraphHashTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveInterceptorTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveInterceptorTests.cs
----
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlSaveInterceptorTests : SaveInterceptorTestsBase
{
protected override string ConnectionStringName => "MSSql";
protected override void UseProvider(RedbOptionsBuilder options, string connectionString)
=> options.UseMsSql(connectionString);
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveLockScopeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveLockScopeTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlSaveLockScopeTests : SaveLockScopeTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaInitTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaInitTests.cs
----
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Export.Services;
using redb.MSSql.Sql;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
/// on SQL Server, scratch databases dropped afterwards.
public class MsSqlSchemaInitTests : SchemaInitTestsBase, IAsyncLifetime
{
private string _server = null!;
private readonly List _databases = [];
protected override string ProviderName => "mssql";
protected override string RequiredVersion => new MsSqlDialect().Query_PvtRequiredVersion()!;
private const string UserObjectsSql = "SELECT COUNT(*) FROM sys.objects WHERE is_ms_shipped = 0";
// The SQL Server script runs batch by batch, each committed on its own: a failure in the middle leaves the batches
// before it. A table of the script's own name stops it after _types is created.
[Fact]
public async Task AnInit_ThatFailsHalfWay_NamesTheHalfCreatedDatabase_AndOnlyDropAndCreate()
{
var cs = await NewDatabaseAsync("half");
await ExecuteAsync(cs, "CREATE TABLE dbo._links (x int)");
var init = async () => await SchemaInitService.InitializeAsync(ProviderName, cs);
(await init.Should().ThrowAsync()).Which.Message
.Should().Contain("holds part of the redb schema").And.Contain("drop and create the database")
.And.NotContain("schema --upgrade");
(await ScalarAsync(cs, "SELECT CASE WHEN OBJECT_ID(N'dbo._types', N'U') IS NULL THEN 0 ELSE 1 END"))
.Should().Be("1", "precondition: the batches before the failure stayed");
}
[Fact]
public async Task AnInit_OverAHalfCreatedDatabase_LeadsWithDropAndCreate_AndTouchesNothing()
{
var cs = await NewDatabaseAsync("half-again");
await ExecuteAsync(cs, "CREATE TABLE dbo._links (x int)");
await FluentActions.Awaiting(() => SchemaInitService.InitializeAsync(ProviderName, cs))
.Should().ThrowAsync("precondition: the first init stopped half-way");
var before = await ScalarAsync(cs, UserObjectsSql);
var again = async () => await SchemaInitService.InitializeAsync(ProviderName, cs);
var message = (await again.Should().ThrowAsync()).Which.Message;
message.Should().Contain("holds part of the redb schema").And.Contain("has changed nothing");
message.IndexOf("drop and create the database", StringComparison.Ordinal).Should().BeGreaterThan(-1)
.And.BeLessThan(IndexOfOrEnd(message, "start a redb"), "drop and create comes first");
message.Should().NotContain("schema --upgrade");
(await ScalarAsync(cs, UserObjectsSql)).Should().Be(before);
}
[Fact]
public async Task AnInit_OverASchemaWithoutItsModuleVersion_IsTakenForIncomplete()
{
// _schemes is there, the function the script deploys last is not: the probe used to answer "upgrade it".
var cs = await NewDatabaseAsync("no-module");
await SchemaInitService.InitializeAsync(ProviderName, cs);
await ExecuteAsync(cs, "DROP FUNCTION dbo.pvt_module_version");
var again = async () => await SchemaInitService.InitializeAsync(ProviderName, cs);
(await again.Should().ThrowAsync()).Which.Message
.Should().Contain("holds part of the redb schema").And.Contain("drop and create the database")
.And.NotContain("schema --upgrade");
}
private static int IndexOfOrEnd(string text, string value)
{
var index = text.IndexOf(value, StringComparison.Ordinal);
return index < 0 ? text.Length : index;
}
public Task InitializeAsync()
{
_server = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
return Task.CompletedTask;
}
public async Task DisposeAsync()
{
SqlConnection.ClearAllPools();
foreach (var database in _databases)
await ExecuteAsync(Master(),
$"IF DB_ID('{database}') IS NOT NULL BEGIN ALTER DATABASE [{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{database}] END");
}
protected override async Task NewDatabaseAsync(string suffix)
{
var name = $"redb_init_{Guid.NewGuid().ToString("N")[..12]}_{suffix}";
_databases.Add(name);
await ExecuteAsync(Master(), $"CREATE DATABASE [{name}]");
return new SqlConnectionStringBuilder(_server) { InitialCatalog = name }.ConnectionString;
}
protected override ServiceProvider Build(string cs)
{
var services = new ServiceCollection();
services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning));
services.AddRedb(options => options.UseMsSql(cs).Configure(c => c.CacheDomain = $"init-{Guid.NewGuid():N}"));
return services.BuildServiceProvider();
}
protected override async Task ScalarAsync(string cs, string sql)
{
await using var connection = new SqlConnection(cs);
await connection.OpenAsync();
await using var command = new SqlCommand(sql, connection);
return Convert.ToString(await command.ExecuteScalarAsync());
}
protected override async Task> CatalogAsync(string cs)
{
var lines = new List();
await using var connection = new SqlConnection(cs);
await connection.OpenAsync();
foreach (var sql in new[]
{
"SELECT 'sequence ' + name FROM sys.sequences ORDER BY 1",
"SELECT 'fk ' + name + ' disabled=' + CAST(is_disabled AS varchar(1)) FROM sys.foreign_keys ORDER BY 1",
"SELECT 'trigger ' + name + ' disabled=' + CAST(is_disabled AS varchar(1)) FROM sys.triggers ORDER BY 1",
"SELECT 'module ' + dbo.pvt_module_version()",
})
{
await using var command = new SqlCommand(sql, connection);
await using var reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
lines.Add(reader.GetString(0));
}
return lines;
}
private string Master() => new SqlConnectionStringBuilder(_server) { InitialCatalog = "master" }.ConnectionString;
private static async Task ExecuteAsync(string cs, string sql)
{
await using var connection = new SqlConnection(cs);
await connection.OpenAsync();
await using var command = new SqlCommand(sql, connection);
await command.ExecuteNonQueryAsync();
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaMissingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaMissingTests.cs
----
using Microsoft.Data.SqlClient;
using redb.Core.Extensions;
using redb.MSSql.Data;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlSchemaMissingTests : SchemaMissingTestsBase
{
private readonly string _name = $"redb_probe_empty_{Guid.NewGuid():N}"[..40];
protected override async Task CreateEmptyDatabaseAsync()
{
await using var admin = new SqlRedbConnection(ConnString("MSSql"));
await admin.ExecuteAsync($"CREATE DATABASE [{_name}]");
return new SqlConnectionStringBuilder(ConnString("MSSql")) { InitialCatalog = _name }.ConnectionString;
}
protected override async Task DropDatabaseAsync(string connectionString)
{
SqlConnection.ClearPool(new SqlConnection(connectionString));
await using var admin = new SqlRedbConnection(ConnString("MSSql"));
await admin.ExecuteAsync(
$"IF DB_ID(N'{_name}') IS NOT NULL BEGIN " +
$"ALTER DATABASE [{_name}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{_name}]; END");
}
protected override void UseProvider(RedbOptionsBuilder options, string connectionString)
=> options.UseMsSql(connectionString);
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaUpgradeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaUpgradeTests.cs
----
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core;
using redb.Core.Data;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
///
/// Owns database redb_upgrade_<run> and login redb_noddl_<run> on the test server. See the
/// PostgreSQL twin for why it is not in a collection.
///
public class MsSqlSchemaUpgradeTests : SchemaUpgradeTestsBase
{
public MsSqlSchemaUpgradeTests(SchemaUpgradeCleanup cleanup) : base(cleanup) { }
// Virtual so the Pro subclass owns its own database and login: both classes damage the
// schema on purpose and must not share it.
protected virtual string DatabaseName => $"redb_upgrade_{RunSuffix}";
protected virtual string FreshDatabaseName => $"redb_upgrade_fresh_{RunSuffix}";
protected virtual string RestrictedLogin => $"redb_noddl_{RunSuffix}";
private const string RestrictedPassword = "NoDdl!12345";
private static readonly string AdminBase =
new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
protected override string OwnerConnectionString =>
new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = DatabaseName }.ConnectionString;
protected override string FreshDatabaseConnectionString =>
new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = FreshDatabaseName }.ConnectionString;
protected override async Task RecreateFreshDatabaseAsync()
{
await ExecAdminAsync("master",
$"IF DB_ID(N'{FreshDatabaseName}') IS NOT NULL BEGIN " +
$"ALTER DATABASE [{FreshDatabaseName}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; " +
$"DROP DATABASE [{FreshDatabaseName}]; END");
await ExecAdminAsync("master", $"CREATE DATABASE [{FreshDatabaseName}]");
}
protected override string RestrictedConnectionString =>
new SqlConnectionStringBuilder(AdminBase)
{
InitialCatalog = DatabaseName, UserID = RestrictedLogin, Password = RestrictedPassword
}.ConnectionString;
protected override void UseProvider(RedbOptionsBuilder options, string connectionString)
=> options.UseMsSql(connectionString);
private static async Task ExecAdminAsync(string database, string sql)
{
var cs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database, Pooling = false }.ConnectionString;
await using var conn = new SqlConnection(cs);
await conn.OpenAsync();
await using var cmd = conn.CreateCommand();
cmd.CommandText = sql;
await cmd.ExecuteNonQueryAsync();
}
private static async Task ScalarAdminAsync(string database, string sql)
{
var cs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database, Pooling = false }.ConnectionString;
await using var conn = new SqlConnection(cs);
await conn.OpenAsync();
await using var cmd = conn.CreateCommand();
cmd.CommandText = sql;
var v = await cmd.ExecuteScalarAsync();
return v is null or DBNull ? default : (T)v;
}
protected override async Task PrepareDatabaseAndLoginAsync()
{
if (await ScalarAdminAsync("master", $"SELECT 1 FROM sys.databases WHERE name = '{DatabaseName}'") is null)
await ExecAdminAsync("master", $"CREATE DATABASE [{DatabaseName}]");
if (await ScalarAdminAsync("master", $"SELECT 1 FROM sys.server_principals WHERE name = '{RestrictedLogin}'") is null)
await ExecAdminAsync("master",
$"CREATE LOGIN [{RestrictedLogin}] WITH PASSWORD = '{RestrictedPassword}', CHECK_POLICY = OFF");
if (await ScalarAdminAsync(DatabaseName, $"SELECT 1 FROM sys.database_principals WHERE name = '{RestrictedLogin}'") is null)
await ExecAdminAsync(DatabaseName, $"CREATE USER [{RestrictedLogin}] FOR LOGIN [{RestrictedLogin}]");
}
protected override async Task DropOwnedServerObjectsAsync()
{
SqlConnection.ClearAllPools();
foreach (var database in new[] { DatabaseName, FreshDatabaseName, ContainedDatabaseName })
await ExecAdminAsync("master",
$"IF DB_ID(N'{database}') IS NOT NULL BEGIN " +
$"ALTER DATABASE [{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; " +
$"DROP DATABASE [{database}]; END");
await ExecAdminAsync("master",
$"IF EXISTS (SELECT 1 FROM sys.server_principals WHERE name = N'{RestrictedLogin}') DROP LOGIN [{RestrictedLogin}]");
}
protected override async Task GrantRestrictedAsync()
{
// db_datareader + db_datawriter + EXECUTE: reads, writes, calls functions. No CREATE, no
// ALTER, no DROP — the shape a DBA leaves an application in after installation.
await ExecAdminAsync(DatabaseName, $"""
ALTER ROLE db_datareader ADD MEMBER [{RestrictedLogin}];
ALTER ROLE db_datawriter ADD MEMBER [{RestrictedLogin}];
GRANT EXECUTE TO [{RestrictedLogin}];
""");
}
protected override Task SetDeployedModuleVersionAsync(string version)
=> ExecAdminAsync(DatabaseName, $"""
ALTER FUNCTION dbo.pvt_module_version() RETURNS nvarchar(50) WITH SCHEMABINDING
AS BEGIN RETURN N'{version}'; END
""");
protected override async Task ReadDeployedModuleVersionAsync()
=> (await ScalarAdminAsync(DatabaseName, "SELECT dbo.pvt_module_version()"))!;
protected override Task SetDeployedModuleCompatAsync(string? compat)
=> ExecAdminAsync(DatabaseName, compat is null
? "DROP FUNCTION IF EXISTS dbo.pvt_module_compat"
: $"""
CREATE OR ALTER FUNCTION dbo.pvt_module_compat() RETURNS nvarchar(50) WITH SCHEMABINDING
AS BEGIN RETURN N'{compat}'; END
""");
/// The refusing guard sets NOEXEC ON on its session (it stops SSMS and sqlcmd): no pooled session keeps it.
protected override Task AfterRefusedScriptAsync()
{
SqlConnection.ClearAllPools();
return Task.CompletedTask;
}
protected override async Task DropV4UpgradeDdlAsync()
{
await ExecAdminAsync(DatabaseName, """
IF EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._values') AND name = N'UIX__values__structure_unique')
DROP INDEX [UIX__values__structure_unique] ON [dbo].[_values];
IF EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._objects') AND name = N'UIX__objects__scheme_unique')
DROP INDEX [UIX__objects__scheme_unique] ON [dbo].[_objects];
IF COL_LENGTH('dbo._values', '_unique') IS NOT NULL ALTER TABLE [dbo].[_values] DROP COLUMN [_unique];
IF COL_LENGTH('dbo._structures', '_unique') IS NOT NULL ALTER TABLE [dbo].[_structures] DROP COLUMN [_unique];
IF COL_LENGTH('dbo._structures', '_unique_version') IS NOT NULL ALTER TABLE [dbo].[_structures] DROP COLUMN [_unique_version];
IF COL_LENGTH('dbo._structures', '_lazy') IS NOT NULL ALTER TABLE [dbo].[_structures] DROP COLUMN [_lazy];
IF COL_LENGTH('dbo._scheme_metadata_cache', '_unique') IS NOT NULL ALTER TABLE [dbo].[_scheme_metadata_cache] DROP COLUMN [_unique];
IF COL_LENGTH('dbo._scheme_metadata_cache', '_unique_version') IS NOT NULL ALTER TABLE [dbo].[_scheme_metadata_cache] DROP COLUMN [_unique_version];
IF COL_LENGTH('dbo._scheme_metadata_cache', '_lazy') IS NOT NULL ALTER TABLE [dbo].[_scheme_metadata_cache] DROP COLUMN [_lazy];
IF COL_LENGTH('dbo._objects', '_value_unique') IS NOT NULL ALTER TABLE [dbo].[_objects] DROP COLUMN [_value_unique];
IF EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._objects') AND name = N'IX__objects__value_string')
DROP INDEX [IX__objects__value_string] ON [dbo].[_objects];
ALTER TABLE [dbo].[_objects] ALTER COLUMN [_value_string] NVARCHAR(MAX) NULL;
""");
}
protected override async Task V4UpgradeDdlExistsAsync()
{
var present = await ScalarAdminAsync(DatabaseName, """
SELECT (SELECT COUNT(*) FROM sys.columns c JOIN sys.tables t ON t.object_id = c.object_id
WHERE (t.name = '_values' AND c.name = '_unique')
OR (t.name = '_structures' AND c.name IN ('_unique', '_unique_version', '_lazy'))
OR (t.name = '_scheme_metadata_cache' AND c.name IN ('_unique', '_unique_version', '_lazy'))
OR (t.name = '_objects' AND c.name = '_value_unique'))
+ (SELECT COUNT(*) FROM sys.indexes
WHERE name IN ('UIX__values__structure_unique', 'UIX__objects__scheme_unique', 'IX__objects__value_string'))
+ (SELECT COUNT(*) FROM sys.columns
WHERE object_id = OBJECT_ID('dbo._objects') AND name = '_value_string' AND max_length = 900)
-- owner decision 2026-09-02: the unread full-text index must be GONE (counts as 0)
+ (SELECT COUNT(*) FROM sys.fulltext_indexes WHERE object_id = OBJECT_ID('dbo._values'))
""");
return Convert.ToInt64(present) == 12;
}
protected override async Task ApplyScriptAsOwnerAsync(IRedbContext ownerContext, string script)
{
// The same split the provider's start-up does: GO is a client-side batch separator.
var batches = System.Text.RegularExpressions.Regex.Split(script, @"^\s*GO\s*$",
System.Text.RegularExpressions.RegexOptions.Multiline | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
foreach (var batch in batches)
{
var trimmed = batch.Trim();
if (trimmed.Length > 0)
await ownerContext.ExecuteAsync(trimmed);
}
}
protected override async Task ReadSchemaFingerprintAsync()
=> (await ScalarAdminAsync(DatabaseName, """
SELECT CONCAT(
(SELECT COUNT(*) FROM sys.foreign_keys), '|',
(SELECT CONVERT(nvarchar(40), current_value) FROM sys.sequences WHERE name = N'global_identity'), '|',
(SELECT COUNT(*) FROM sys.triggers), '|',
(SELECT COUNT(*) FROM sys.objects WHERE type IN ('P', 'FN', 'IF', 'TF')), '|',
(SELECT COUNT(*) FROM dbo._objects), '|', (SELECT COUNT(*) FROM dbo._values), '|',
(SELECT COUNT(*) FROM dbo._schemes), '|', (SELECT COUNT(*) FROM dbo._users))
"""))!;
///
/// sqlcmd and SSMS: every batch on one session, an error does not stop the next batch. Only the NOEXEC the guard
/// sets keeps the batches after it from running.
///
protected override async Task> RunScriptByHandAsync(string script)
{
var errors = new List();
var cs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = DatabaseName, Pooling = false }.ConnectionString;
await using var conn = new SqlConnection(cs);
await conn.OpenAsync();
foreach (var batch in System.Text.RegularExpressions.Regex.Split(script, @"^\s*GO\s*$",
System.Text.RegularExpressions.RegexOptions.Multiline | System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
var trimmed = batch.Trim();
if (trimmed.Length == 0) continue;
await using var cmd = conn.CreateCommand();
cmd.CommandText = trimmed;
cmd.CommandTimeout = 300;
try { await cmd.ExecuteNonQueryAsync(); }
catch (SqlException ex) { errors.Add(ex.Message); }
}
return errors;
}
[Fact]
public async Task FreshDatabase_Saves_KeepTheForeignKeysTrusted()
{
// The bulk copy of new objects and values checks the foreign keys (CheckConstraints). Without the hint SQL
// Server skipped them and marked every foreign key of the table untrusted after the first save.
await RecreateFreshDatabaseAsync();
await using var sp = Build(FreshDatabaseConnectionString, autoApply: true, cacheDomain: $"trusted-fk-{Guid.NewGuid():N}");
var redb = sp.GetRequiredService();
await redb.InitializeAsync(ensureCreated: true);
await redb.SyncSchemeAsync();
var root = new redb.Core.Models.Entities.TreeRedbObject
{ name = "fk-root", Props = new redb.Tests.Integration.Models.LazyNodeProps { Label = "root" } };
root.id = await redb.SaveAsync(root);
await redb.CreateChildAsync(new redb.Core.Models.Entities.TreeRedbObject
{
name = "fk-child",
Props = new redb.Tests.Integration.Models.LazyNodeProps
{
Label = "child", Next = new redb.Core.Models.Entities.RedbObject { id = root.id }
}
}, root);
var keys = Convert.ToInt32(await ScalarAdminAsync(FreshDatabaseName,
"SELECT COUNT(*) FROM sys.foreign_keys WHERE OBJECT_NAME(parent_object_id) IN ('_objects', '_values')"));
var untrusted = Convert.ToInt32(await ScalarAdminAsync(FreshDatabaseName,
"SELECT COUNT(*) FROM sys.foreign_keys WHERE OBJECT_NAME(parent_object_id) IN ('_objects', '_values') AND is_not_trusted = 1"));
keys.Should().BeGreaterThan(0);
untrusted.Should().Be(0, "a save checks the keys, so the server keeps trusting them");
}
[Fact]
public async Task ModuleUpgrade_DisablesTheNodePermissionTrigger_AsOnPostgres()
{
// A database of a version before 0.2.41: the trigger enabled, the module behind. The start applies the module,
// which disables the trigger as the PostgreSQL schema has it: the bulk copy fires triggers from 0.2.41 on.
await ExecAdminAsync(DatabaseName, "ALTER TABLE [dbo].[_objects] ENABLE TRIGGER [tr_auto_create_node_permissions]");
await SetDeployedModuleVersionAsync("0.2.40");
await using (var sp = Build(OwnerConnectionString, autoApply: true, cacheDomain: $"trigger-upgrade-{Guid.NewGuid():N}"))
await sp.GetRequiredService().InitializeAsync(ensureCreated: true);
(await ReadDeployedModuleVersionAsync()).Should().NotBe("0.2.40");
var disabled = Convert.ToInt32(await ScalarAdminAsync(DatabaseName,
"SELECT OBJECTPROPERTY(OBJECT_ID(N'dbo.tr_auto_create_node_permissions'), 'ExecIsTriggerDisabled')"));
disabled.Should().Be(1);
}
protected virtual string ContainedDatabaseName => $"redb_upgrade_contained_{RunSuffix}";
private const string ContainedUser = "redb_contained";
private const string ContainedPassword = "Contained!12345";
[Fact]
public async Task ContainedUser_DeployedDatabase_Starts_AndSchemaWorkNamesTheWayOut()
{
// The DBA scenario: the schema is deployed by a privileged login, the application connects as a user of the
// database alone, with no access to master where the schema lock lives. A database in step needs no lock, so
// the start goes through; schema work stops with an error that names both ways out.
// A server setting, not the test's to change: checked, and a server without it fails the test loudly.
var containedAuth = await ScalarAdminAsync("master",
"SELECT CAST(value_in_use AS int) FROM sys.configurations WHERE name = 'contained database authentication'");
Convert.ToInt32(containedAuth).Should().Be(1,
"this test needs contained database authentication on the test server; enable it once with " +
"EXEC sp_configure 'contained database authentication', 1; RECONFIGURE;");
await ExecAdminAsync("master",
$"IF DB_ID(N'{ContainedDatabaseName}') IS NOT NULL BEGIN " +
$"ALTER DATABASE [{ContainedDatabaseName}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; " +
$"DROP DATABASE [{ContainedDatabaseName}]; END");
await ExecAdminAsync("master", $"CREATE DATABASE [{ContainedDatabaseName}] CONTAINMENT = PARTIAL");
var ownerCs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = ContainedDatabaseName }.ConnectionString;
await using (var sp = Build(ownerCs, autoApply: true, cacheDomain: $"contained-owner-{Guid.NewGuid():N}"))
await sp.GetRequiredService().InitializeAsync(ensureCreated: true);
await ExecAdminAsync(ContainedDatabaseName, $"""
CREATE USER [{ContainedUser}] WITH PASSWORD = '{ContainedPassword}';
ALTER ROLE db_datareader ADD MEMBER [{ContainedUser}];
ALTER ROLE db_datawriter ADD MEMBER [{ContainedUser}];
GRANT EXECUTE TO [{ContainedUser}];
""");
var userCs = new SqlConnectionStringBuilder(AdminBase)
{
InitialCatalog = ContainedDatabaseName, UserID = ContainedUser, Password = ContainedPassword
}.ConnectionString;
var openMaster = async () =>
{
await using var master = new SqlConnection(new SqlConnectionStringBuilder(userCs) { InitialCatalog = "master" }.ConnectionString);
await master.OpenAsync();
};
await openMaster.Should().ThrowAsync("the user exists in its database only");
await using (var sp = Build(userCs, autoApply: true, cacheDomain: $"contained-user-{Guid.NewGuid():N}"))
await sp.GetRequiredService().InitializeAsync(ensureCreated: true);
await ExecAdminAsync(ContainedDatabaseName, """
ALTER FUNCTION dbo.pvt_module_version() RETURNS nvarchar(50) WITH SCHEMABINDING
AS BEGIN RETURN N'0.0.0-test'; END
""");
await using (var sp = Build(userCs, autoApply: true, cacheDomain: $"contained-user-{Guid.NewGuid():N}"))
{
var start = () => sp.GetRequiredService().InitializeAsync(ensureCreated: true);
(await start.Should().ThrowAsync())
.Which.Message.Should().Contain("access to master").And.Contain("GetUpgradeScript");
}
}
[Fact]
public async Task Upgrade_RefusesToNarrowValueString_WhileLongValuesExist()
{
// Owner decision 2026-09-02: _value_string is an identifier column (450); long text belongs
// in _note. A database already holding longer values must not be truncated silently - the
// upgrade stops, names the offenders query, and changes nothing.
await RecreateFreshDatabaseAsync();
await using (var sp = Build(FreshDatabaseConnectionString, autoApply: true))
await sp.GetRequiredService().InitializeAsync(ensureCreated: true);
// The pre-decision shape: the MAX column with one over-long value, module behind.
await ExecAdminAsync(FreshDatabaseName, "DROP INDEX [IX__objects__value_string] ON [dbo].[_objects]");
await ExecAdminAsync(FreshDatabaseName, "ALTER TABLE [dbo].[_objects] ALTER COLUMN [_value_string] NVARCHAR(MAX) NULL");
await ExecAdminAsync(FreshDatabaseName, """
INSERT INTO [dbo].[_objects] (_id, _id_scheme, _id_owner, _id_who_change, _name, _value_string)
SELECT 900000001, (SELECT TOP 1 _id FROM [dbo].[_schemes] ORDER BY _id),
(SELECT TOP 1 _id FROM [dbo].[_users] ORDER BY _id),
(SELECT TOP 1 _id FROM [dbo].[_users] ORDER BY _id),
N'long-value-string', REPLICATE(N'x', 500)
""");
await ExecAdminAsync(FreshDatabaseName, """
ALTER FUNCTION dbo.pvt_module_version() RETURNS nvarchar(50) WITH SCHEMABINDING
AS BEGIN RETURN N'0.0.0-test'; END
""");
await using (var sp = Build(FreshDatabaseConnectionString, autoApply: true))
{
var act = async () => await sp.GetRequiredService().InitializeAsync();
(await act.Should().ThrowAsync("silent truncation is not an option"))
.Which.ToString().Should().Contain("_value_string", "the refusal names the column and the way out");
}
// The way out the message names: move the text to _note, start again.
await ExecAdminAsync(FreshDatabaseName,
"UPDATE [dbo].[_objects] SET _note = _value_string, _value_string = NULL WHERE _id = 900000001");
await using (var sp = Build(FreshDatabaseConnectionString, autoApply: true))
await sp.GetRequiredService().InitializeAsync();
(await ScalarAdminAsync(FreshDatabaseName, "SELECT CAST(COL_LENGTH('dbo._objects', '_value_string') AS INT)"))
.Should().Be(900, "the column is NVARCHAR(450) once the data allows it");
(await ScalarAdminAsync(FreshDatabaseName,
"SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._objects') AND name = N'IX__objects__value_string'"))
.Should().NotBeNull("and the index the other providers always had exists now");
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeLoadValidationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeLoadValidationTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlSchemeLoadValidationTests : SchemeLoadValidationTestsBase
{
public MsSqlSchemeLoadValidationTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeNamingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeNamingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlSchemeNamingTests : SchemeNamingTestsBase
{
public MsSqlSchemeNamingTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeRenameTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeRenameTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlSchemeRenameTests : SchemeRenameTestsBase
{
public MsSqlSchemeRenameTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSmallSaveTimingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSmallSaveTimingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
using Xunit.Abstractions;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlSmallSaveTimingTests : SmallSaveTimingTestsBase
{
public MsSqlSmallSaveTimingTests(MsSqlFixture fixture, ITestOutputHelper output) : base(fixture.ServiceProvider, output) { }
protected override string? PlanCacheReportSql => MsSqlPlanCache.InsertReport;
}
/// The cached plans of the insert statements of the current database (read only, needs VIEW SERVER STATE).
internal static class MsSqlPlanCache
{
public const string InsertReport = """
SELECT s.Statement, COUNT(*) AS Plans, SUM(CAST(s.usecounts AS bigint)) AS Executions, LEFT(MIN(s.text), 400) AS Sample
FROM (
SELECT CASE WHEN t.text LIKE '%INSERT INTO _values (_id, _id_structure%' THEN 'INSERT _values'
WHEN t.text LIKE '%INSERT INTO _objects (_id, _id_parent%' THEN 'INSERT _objects'
WHEN t.text LIKE '%insert bulk%' THEN 'insert bulk' END AS Statement,
cp.usecounts, t.text
FROM sys.dm_exec_cached_plans cp
CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) t
CROSS APPLY sys.dm_exec_plan_attributes(cp.plan_handle) pa
WHERE pa.attribute = 'dbid' AND CAST(pa.value AS int) = DB_ID()
AND t.text NOT LIKE '%dm_exec_cached_plans%'
) s
WHERE s.Statement IS NOT NULL
GROUP BY s.Statement
""";
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSoftDeleteProcedureTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSoftDeleteProcedureTests.cs
----
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using redb.Core.Models.Entities;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSql;
///
/// sp_mark_for_deletion runs under SET XACT_ABORT ON (trash review, 2026-09-14). Without it a client
/// cancel or a command timeout arriving inside the procedure's transaction bypasses CATCH and leaves the
/// transaction open on the session - after the connection returns to the pool as well - so every later
/// statement of that session runs inside it and is rolled back with it. The pin blocks the procedure on
/// a row lock held by another session, lets the command time out right there, and checks the session.
///
[Collection("MsSql")]
public class MsSqlSoftDeleteProcedureTests
{
private readonly MsSqlFixture _fixture;
public MsSqlSoftDeleteProcedureTests(MsSqlFixture fixture) => _fixture = fixture;
private static string ConnString() =>
new SqlConnectionStringBuilder(
new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json")
.Build()
.GetConnectionString("MSSql")!)
{ Pooling = false }.ConnectionString;
[Fact]
public async Task MarkForDeletion_TimedOutInsideItsTransaction_LeavesNoTransactionOnTheSession()
{
await _fixture.Redb.SyncSchemeAsync();
var id = await _fixture.Redb.SaveAsync(new RedbObject
{ name = "trash-xact-abort-probe", Props = new TrashTargetProps { Title = "probe" } });
var userId = _fixture.Redb.SecurityContext.GetEffectiveUser().Id;
await using var holder = new SqlConnection(ConnString());
await holder.OpenAsync();
await using var held = (SqlTransaction)await holder.BeginTransactionAsync();
await using (var hold = new SqlCommand("UPDATE [dbo].[_objects] SET [_note] = N'held' WHERE [_id] = @id", holder, held))
{
hold.Parameters.AddWithValue("@id", id);
await hold.ExecuteNonQueryAsync();
}
await using var session = new SqlConnection(ConnString());
await session.OpenAsync();
await using (var mark = new SqlCommand(
"DECLARE @trash BIGINT, @marked BIGINT; EXEC [dbo].[sp_mark_for_deletion] @ids, @user, NULL, @trash OUTPUT, @marked OUTPUT;",
session) { CommandTimeout = 2 })
{
mark.Parameters.AddWithValue("@ids", id.ToString());
mark.Parameters.AddWithValue("@user", userId);
var act = async () => await mark.ExecuteNonQueryAsync();
await act.Should().ThrowAsync("the procedure waits on the held row until the command times out");
}
await using (var probe = new SqlCommand("SELECT @@TRANCOUNT", session))
Convert.ToInt32(await probe.ExecuteScalarAsync()).Should().Be(0,
"a timeout inside the procedure must roll its transaction back, not leave it on the session");
await held.RollbackAsync();
(await _fixture.Redb.Context.ExecuteScalarAsync($"SELECT _id_scheme FROM _objects WHERE _id = {id}"))
.Should().NotBe(-10, "the timed-out mark changed nothing");
await _fixture.Redb.DeleteAsync(id);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlStringMatchContractTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlStringMatchContractTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlStringMatchContractTests : MsSqlStringMatchContractTestsBase
{
public MsSqlStringMatchContractTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSubSecondUpdateTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSubSecondUpdateTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlSubSecondUpdateTests : SubSecondUpdateTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTagsFieldTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTagsFieldTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTagsFieldTests : TagsFieldTestsBase
{
public MsSqlTagsFieldTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTemporalRoundTripTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTemporalRoundTripTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTemporalRoundTripTests : TemporalRoundTripTestsBase
{
public MsSqlTemporalRoundTripTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTimeTicksTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTimeTicksTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTimeTicksTests : TimeTicksTestsBase
{
public MsSqlTimeTicksTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTransactionIsolationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTransactionIsolationTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTransactionIsolationTests : TransactionIsolationTestsBase
{
public MsSqlTransactionIsolationTests(MsSqlFixture fixture) : base(fixture.Redb) { }
protected override string? ReadLevelSql => """
SELECT CASE transaction_isolation_level
WHEN 1 THEN 'read uncommitted' WHEN 2 THEN 'read committed'
WHEN 3 THEN 'repeatable read' WHEN 4 THEN 'serializable'
WHEN 5 THEN 'snapshot' END
FROM sys.dm_exec_sessions WHERE session_id = @@SPID
""";
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashBackgroundServiceTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashBackgroundServiceTests.cs
----
using Microsoft.Data.SqlClient;
using redb.Core.Extensions;
using redb.MSSql.Data;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlTrashBackgroundServiceTests : TrashBackgroundServiceTestsBase
{
private readonly string _name = $"redb_probe_trashbg_{Guid.NewGuid():N}"[..40];
protected override async Task CreateEmptyDatabaseAsync()
{
await using var admin = new SqlRedbConnection(ConnString("MSSql"));
await admin.ExecuteAsync($"CREATE DATABASE [{_name}]");
return new SqlConnectionStringBuilder(ConnString("MSSql")) { InitialCatalog = _name }.ConnectionString;
}
protected override async Task DropDatabaseAsync(string connectionString)
{
SqlConnection.ClearPool(new SqlConnection(connectionString));
await using var admin = new SqlRedbConnection(ConnString("MSSql"));
await admin.ExecuteAsync(
$"IF DB_ID(N'{_name}') IS NOT NULL BEGIN " +
$"ALTER DATABASE [{_name}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{_name}]; END");
}
protected override void UseProvider(RedbOptionsBuilder options, string connectionString)
=> options.UseMsSql(connectionString);
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashPurgeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashPurgeTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTrashPurgeTests : TrashPurgeTestsBase
{
public MsSqlTrashPurgeTests(MsSqlFixture fixture) : base(fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashedReferenceTargetTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashedReferenceTargetTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlTrashedReferenceTargetTests : TrashedReferenceTargetTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeDistinctTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeDistinctTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTreeDistinctTests : TreeDistinctTestsBase
{
public MsSqlTreeDistinctTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeLevelAnalyticsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeLevelAnalyticsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTreeLevelAnalyticsTests : TreeLevelAnalyticsTestsBase
{
public MsSqlTreeLevelAnalyticsTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeQueryShapesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeQueryShapesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTreeQueryShapesTests : TreeQueryShapesTestsBase
{
public MsSqlTreeQueryShapesTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeSourceFormTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeSourceFormTests.cs
----
using redb.Core;
using redb.Core.Models.Entities;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Helpers;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSql;
///
/// Free SQL Server module: a tree query with a Props filter calls the walk (pvt_tree_descendants) once and reads the
/// values of each object through OUTER APPLY. The pivot joined to the objects ran the walk on both sides, and a filter
/// over a 100 thousand node subtree took 3.3 s instead of 1.8 s (E204).
///
[Collection("MsSql")]
public class MsSqlTreeSourceFormTests
{
private readonly IRedbService _redb;
public MsSqlTreeSourceFormTests(MsSqlFixture fixture) => _redb = fixture.Redb;
[Fact]
public async Task TreeQueryWithAPropsFilter_WalksTheTreeOnce()
{
await _redb.SyncSchemeAsync();
var root = new TreeRedbObject { name = "form-" + Guid.NewGuid().ToString("N")[..8], Props = TestDataFactory.CreateEmployee(1).Props };
root.id = await _redb.SaveAsync(root);
var sql = await _redb.TreeQuery(root.id)
.Where(e => e.Salary >= 60000m && e.Salary < 90000m)
.ToSqlStringAsync();
sql.Should().Contain("OUTER APPLY (");
System.Text.RegularExpressions.Regex.Matches(sql, @"pvt_tree_descendants\(").Count.Should().Be(1, sql);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeSqlPreviewTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeSqlPreviewTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTreeSqlPreviewTests : TreeSqlPreviewTestsBase
{
public MsSqlTreeSqlPreviewTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTreeTests : TreeTestsBase
{
public MsSqlTreeTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTypeMigrationSyncTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlTypeMigrationSyncTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlTypeMigrationSyncTests : TypeMigrationSyncTestsBase
{
public MsSqlTypeMigrationSyncTests(MsSqlFixture fixture) : base(fixture.Redb) { }
protected override string TextTypeName => "NVARCHAR(50)";
protected override string BoolTrue => "1";
protected override string BoolFalse => "0";
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlUniqueKeyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlUniqueKeyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlUniqueKeyTests : UniqueKeyTestsBase
{
public MsSqlUniqueKeyTests(MsSqlFixture fixture) : base(fixture.Redb) { }
protected override string BoolTrue => "1";
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlUnregisteredTreeTargetTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlUnregisteredTreeTargetTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlUnregisteredTreeTargetTests : UnregisteredTreeTargetTestsBase
{
public MsSqlUnregisteredTreeTargetTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlUntypedLinkedObjectTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlUntypedLinkedObjectTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.MSSql.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
public class MsSqlUntypedLinkedObjectTests : UntypedLinkedObjectTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlUserConfigurationServiceTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlUserConfigurationServiceTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlUserConfigurationServiceTests : UserConfigurationServiceTestsBase
{
public MsSqlUserConfigurationServiceTests(MsSqlFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlValueOnlyObjectSaveTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlValueOnlyObjectSaveTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlValueOnlyObjectSaveTests : ValueOnlyObjectSaveTestsBase
{
public MsSqlValueOnlyObjectSaveTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlValueUniqueTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlValueUniqueTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlValueUniqueTests : ValueUniqueTestsBase
{
public MsSqlValueUniqueTests(MsSqlFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlValuesFkIndexesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlValuesFkIndexesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlValuesFkIndexesTests : ValuesFkIndexesTestsBase
{
public MsSqlValuesFkIndexesTests(MsSqlFixture fixture) : base(fixture.Redb) { }
protected override async Task IndexExistsAsync(string indexName)
=> await Redb.Context.ExecuteScalarAsync(
"SELECT COUNT(*) FROM sys.indexes WHERE name = '{0}'".Replace("{0}", indexName)) > 0;
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlWhereTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlWhereTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlWhereTests : WhereTestsBase
{
public MsSqlWhereTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlWindowTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlWindowTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSql;
[Collection("MsSql")]
public class MsSqlWindowTests : WindowTestsBase
{
public MsSqlWindowTests(MsSqlFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAbsentFieldConsistencyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAbsentFieldConsistencyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProAbsentFieldConsistencyTests : AbsentFieldConsistencyTestsBase
{
public MsSqlProAbsentFieldConsistencyTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAbsentValuesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAbsentValuesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProAbsentValuesTests : AbsentValuesTestsBase
{
public MsSqlProAbsentValuesTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregatePathTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregatePathTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProAggregatePathTests : AggregatePathTestsBase
{
public MsSqlProAggregatePathTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregatePreviewTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregatePreviewTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProAggregatePreviewTests : ProAggregatePreviewTestsBase
{
public MsSqlProAggregatePreviewTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregationOverArrayTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregationOverArrayTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProAggregationOverArrayTests : AggregationOverArrayTestsBase
{
public MsSqlProAggregationOverArrayTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregationTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProAggregationTests : AggregationTestsBase
{
public MsSqlProAggregationTests(MsSqlProFixture fixture) : base(fixture.Redb, isPro: true) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAmbientTransactionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAmbientTransactionTests.cs
----
using redb.Core.Data;
using redb.MSSql.Data;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProAmbientTransactionTests : AmbientTransactionTestsBase
{
public MsSqlProAmbientTransactionTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { }
protected override string CreateProbeTableSql =>
"IF OBJECT_ID(N'dbo.ambient_tx_rows', N'U') IS NULL CREATE TABLE dbo.ambient_tx_rows (tag nvarchar(100) NOT NULL);";
protected override string SlowStatementSql => "WAITFOR DELAY '00:00:02'; SELECT 1";
protected override IRedbConnection CreateStandaloneConnection(IServiceProvider services, bool differentSessionSettings)
=> new SqlRedbConnection(ConnString("MSSql"), lazyReferences: differentSessionSettings);
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAnalyticsTelemetryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAnalyticsTelemetryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProAnalyticsTelemetryTests : AnalyticsTelemetryTestsBase
{
public MsSqlProAnalyticsTelemetryTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override int CommandsPerCall => 1;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayAnyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayAnyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProArrayAnyTests : ArrayAnyTestsBase
{
public MsSqlProArrayAnyTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayContainsFoldTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayContainsFoldTests.cs
----
using System.Text.RegularExpressions;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// An OR of several Contains over one array reads the elements once, with the values in a list: one EXISTS with IN, not
/// one EXISTS per value (E169: 260 -> 140 ms). The answers are held equal to the other form by
/// PvtPrefilterEquivalenceTestsBase; this pins the shape of the statement with the planner on.
///
[Collection("MsSqlPro")]
public class MsSqlProArrayContainsFoldTests
{
private readonly redb.Core.IRedbService _redb;
public MsSqlProArrayContainsFoldTests(MsSqlProFixture fixture) => _redb = fixture.Redb;
[Fact]
public async Task OrOfContainsOverOneArray_IsOneExistsWithTheValuesInAList()
{
var restore = _redb.Configuration.EnablePvtPrefilter;
try
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
var sql = await _redb.Query()
.Where(e => e.Skills != null && (e.Skills.Contains("C#") || e.Skills.Contains("Python") || e.Skills.Contains("SQL")))
.Take(100)
.ToSqlStringAsync();
Regex.Matches(sql, @"_array_index IS NOT NULL AND a\._\w+ = ").Count.Should().Be(0, "no EXISTS per value:\n{0}", sql);
Regex.Matches(sql, @"_array_index IS NOT NULL AND a\._\w+ IN \(").Count.Should().Be(1, "one read of the elements:\n{0}", sql);
}
finally
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayGroupByDeepTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayGroupByDeepTests.cs
----
using redb.Core;
using redb.Core.Models.Entities;
using redb.Core.Query.Aggregation;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Helpers;
using redb.Tests.Integration.Models;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProArrayGroupByDeepTests : ArrayGroupByDeepTestsBase
{
private readonly IRedbService _redb;
public MsSqlProArrayGroupByDeepTests(MsSqlProFixture fixture) : base(fixture.Redb) => _redb = fixture.Redb;
// Without a condition every element is read anyway: the flat grouping always takes hash joins, since with two fields
// of an element the second one otherwise became a many-to-many merge join (E142).
[Fact]
public async Task UnconditionedGrouping_CarriesTheHashJoinHint()
{
var sql = await _redb.Query()
.GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label)
.ToSqlStringAsync(g => new { Label = g.Key, Entries = Agg.Count(g), OfA = Agg.Count(g, m => m.Value == "a") });
sql.Should().Contain("OPTION (HASH JOIN, MAXDOP 1)").And.NotContain("IF (SELECT COUNT(*)");
}
// With a condition the hint pays only over many objects and loses on a few, where nested loops read only the
// matching elements. The streams source (planner on) puts the ids into a temporary table, and the batch picks the
// statement by their count; the pivot source (planner off) has no count and runs without the hint.
[Fact]
public async Task ConditionedGrouping_TakesTheHintOnlyOverManyIds()
{
var sql = await _redb.Query()
.Where(e => e.HomeAddress!.Building!.Floor > 10)
.GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label)
.ToSqlStringAsync(g => new { Label = g.Key, Entries = Agg.Count(g), OfA = Agg.Count(g, m => m.Value == "a") });
if (ProTestOptions.PvtPrefilter)
{
sql.Should().Contain("IF (SELECT COUNT(*) FROM (SELECT TOP (10000) _id FROM #redb_ids")
.And.Contain(") >= 10000")
.And.Contain("OPTION (HASH JOIN, MAXDOP 1);")
.And.Contain("\nELSE\n");
sql.Split("FOR JSON PATH").Length.Should().Be(3, "both branches carry the grouping");
}
else
sql.Should().NotContain("HASH JOIN").And.NotContain("IF (SELECT COUNT(*)");
}
// The branch with the hint runs over 10 000 ids, more than the test database holds, so this test lowers the threshold
// for one call and the same few objects go through IF ... OPTION (HASH JOIN, MAXDOP 1). The collection runs its tests
// one after another, and the threshold is put back in finally. Planner off: the pivot source has no count and no hint.
[Fact]
public async Task ConditionedGrouping_TheBranchWithTheHint_MatchesTheObjects()
{
var threshold = typeof(redb.MSSql.Pro.Query.ProQueryProvider).GetProperty(
"ArrayGroupHashJoinThreshold", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)!;
var before = (int)threshold.GetValue(null)!;
threshold.SetValue(null, 1);
try
{
await ConditionedGrouping_OverAFewObjects_MatchesTheObjects();
}
finally
{
threshold.SetValue(null, before);
}
}
// A condition over a few objects: the ids go into the temporary table (planner on) and the batch runs the grouping
// without the hint. The answer is the same LINQ over the objects.
[Fact]
public async Task ConditionedGrouping_OverAFewObjects_MatchesTheObjects()
{
await _redb.SyncSchemeAsync();
var marker = "gh" + Guid.NewGuid().ToString("N")[..10];
var seeded = new List>();
for (var i = 0; i < 6; i++)
{
var e = TestDataFactory.CreateEmployee(i, firstName: $"{marker}-{i:D2}");
e.Props.Contacts![0].Metadata = [new TestContactDetail { Label = "work", Value = i % 2 == 0 ? "a" : "b" }];
e.Props.Contacts[1].Metadata = [new TestContactDetail { Label = "night", Value = "a" }];
e.Props.HomeAddress!.Building!.Floor = 5 + i * 3;
await _redb.SaveAsync(e);
seeded.Add(e);
}
var rows = await _redb.Query()
.Where(e => e.FirstName.StartsWith(marker) && e.HomeAddress!.Building!.Floor > 10)
.GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label)
.SelectAsync(g => new { Label = g.Key, Entries = Agg.Count(g), OfA = Agg.Count(g, m => m.Value == "a") });
var expected = seeded.Where(e => e.Props.HomeAddress!.Building!.Floor > 10)
.SelectMany(e => e.Props.Contacts!).SelectMany(c => c.Metadata ?? [])
.GroupBy(m => m.Label)
.Select(g => new { Label = g.Key, Entries = g.Count(), OfA = g.Count(m => m.Value == "a") })
.ToList();
expected.Should().NotBeEmpty("precondition: some of the objects match");
rows.Should().BeEquivalentTo(expected);
}
// The tree grouping does not: its node set may be a recursive CTE, and a hash-join hint leaves SQL Server without a
// plan for it (error 8622). A change here is a change of the tree path, not of this test.
[Fact]
public async Task TreeGroupingStatement_CarriesNoJoinHint()
{
await _redb.SyncSchemeAsync();
var root = new TreeRedbObject
{
name = "hint-root-" + Guid.NewGuid().ToString("N")[..8],
Props = TestDataFactory.CreateEmployee(0).Props
};
root.id = await _redb.SaveAsync(root);
var sql = await _redb.TreeQuery(root.id)
.GroupByArray(e => e.Contacts!, c => c.Type)
.ToSqlStringAsync(g => new { Type = g.Key, Count = Agg.Count(g), Verified = Agg.Count(g, c => c.IsVerified == true) });
sql.Should().NotContain("HASH JOIN");
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayGroupMetadataCacheTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayGroupMetadataCacheTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProArrayGroupMetadataCacheTests : ArrayGroupMetadataCacheTestsBase
{
public MsSqlProArrayGroupMetadataCacheTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayOfClassesAnyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayOfClassesAnyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProArrayOfClassesAnyTests : ArrayOfClassesAnyTestsBase
{
public MsSqlProArrayOfClassesAnyTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override bool ReadsAnyOverClasses => true;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayParentIndexTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayParentIndexTests.cs
----
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Fixtures;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// IX__values__array_parent_id is the leading column of IX__values__array_parent_index, which serves the same lookups,
/// the check of FK__values__array_parent and the cascade trigger. A new database does not create it; the module drops it
/// on an existing database only where an unfiltered index led by _array_parent_id remains. The test owns its database
/// and makes the module apply again by removing its version function, as a database with an older module meets it.
///
public class MsSqlProArrayParentIndexTests : IClassFixture
{
private const string Narrow = "IX__values__array_parent_id";
private const string Wide = "IX__values__array_parent_index";
private static readonly string AdminBase =
new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
private readonly SchemaUpgradeCleanup _cleanup;
public MsSqlProArrayParentIndexTests(SchemaUpgradeCleanup cleanup)
{
_cleanup = cleanup;
cleanup.Register(async () =>
{
SqlConnection.ClearAllPools();
await AdminAsync("master",
$"IF DB_ID(N'{DatabaseName}') IS NOT NULL BEGIN ALTER DATABASE [{DatabaseName}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{DatabaseName}]; END");
});
}
private string DatabaseName => $"redb_arrparent_pro_{_cleanup.Suffix}";
[Fact]
public async Task NarrowIndex_IsLeftOutOfANewDatabase_AndDroppedOnlyWhereTheWideOneExists()
{
var database = DatabaseName;
await AdminAsync("master",
$"IF DB_ID(N'{database}') IS NOT NULL BEGIN ALTER DATABASE [{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{database}]; END");
await AdminAsync("master", $"CREATE DATABASE [{database}]");
await StartAsync(database, ensureCreated: true);
(await IndexExistsAsync(database, Narrow)).Should().BeFalse("a new database does not keep it");
(await IndexExistsAsync(database, Wide)).Should().BeTrue();
// An existing database of an older module: both indexes. The module drops the narrow one.
await AdminAsync(database, $"CREATE INDEX [{Narrow}] ON [dbo].[_values]([_array_parent_id])");
await AdminAsync(database, "DROP FUNCTION dbo.pvt_module_version");
await StartAsync(database, ensureCreated: false);
(await IndexExistsAsync(database, Narrow)).Should().BeFalse("the wider index serves its lookups, the key check and the trigger");
(await IndexExistsAsync(database, Wide)).Should().BeTrue();
// A database created by an old version without the wide index: the narrow one is the only index led by the parent.
await AdminAsync(database, $"CREATE INDEX [{Narrow}] ON [dbo].[_values]([_array_parent_id])");
await AdminAsync(database, $"DROP INDEX [{Wide}] ON [dbo].[_values]");
await AdminAsync(database, "DROP FUNCTION dbo.pvt_module_version");
await StartAsync(database, ensureCreated: false);
(await IndexExistsAsync(database, Narrow)).Should().BeTrue("without a wider index the key check and the trigger keep this one");
}
private static async Task StartAsync(string database, bool ensureCreated)
{
var cs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database }.ConnectionString;
var license = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build()["Redb:License"];
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning));
services.AddRedbPro(options =>
{
options.UseMsSql(cs).Configure(c => c.EnablePropsCache = false);
if (!string.IsNullOrWhiteSpace(license))
options.WithLicense(license);
});
await using var provider = services.BuildServiceProvider();
await provider.GetRequiredService().InitializeAsync(ensureCreated);
SqlConnection.ClearAllPools();
}
private static async Task IndexExistsAsync(string database, string name)
{
await using var conn = new SqlConnection(new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database, Pooling = false }.ConnectionString);
await conn.OpenAsync();
await using var cmd = conn.CreateCommand();
cmd.CommandText = "SELECT COUNT(*) FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._values') AND name = @name";
cmd.Parameters.AddWithValue("@name", name);
return (int)(await cmd.ExecuteScalarAsync())! > 0;
}
private static async Task AdminAsync(string database, string sql)
{
await using var conn = new SqlConnection(new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database, Pooling = false }.ConnectionString);
await conn.OpenAsync();
await using var cmd = conn.CreateCommand();
cmd.CommandText = sql;
cmd.CommandTimeout = 600;
await cmd.ExecuteNonQueryAsync();
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProArrayTests : ArrayTestsBase
{
public MsSqlProArrayTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBareRedbObjectFieldTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBareRedbObjectFieldTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProBareRedbObjectFieldTests : BareRedbObjectFieldTestsBase
{
public MsSqlProBareRedbObjectFieldTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBaseFieldNameCollisionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBaseFieldNameCollisionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProBaseFieldNameCollisionTests : BaseFieldNameCollisionTestsBase
{
public MsSqlProBaseFieldNameCollisionTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBulkInsertTimeoutTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBulkInsertTimeoutTests.cs
----
using System.Diagnostics;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core;
using redb.Core.Models.Configuration;
using redb.Core.Models.Contracts;
using redb.Core.Models.Entities;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// The SqlBulkCopy of AddNewObjectsAsync waits for a lock that another session holds on _values . Without
/// BulkInsertTimeout it gives up after the driver's 30 seconds whatever the connection string says; with the option it
/// waits as long as configured. The wait costs the server nothing: one table lock, no load. 300 objects of SimpleProps
/// put both tables past the statement path (250 rows), so the objects and the values go through SqlBulkCopy.
///
[Collection("MsSqlPro")]
public class MsSqlProBulkInsertTimeoutTests
{
private const int Objects = 300;
private static readonly TimeSpan LockHeld = TimeSpan.FromSeconds(35);
private readonly string _connectionString;
public MsSqlProBulkInsertTimeoutTests(MsSqlProFixture fixture)
{
_ = fixture; // the fixture created the database and synced the schemes
_connectionString = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
}
[Fact]
public async Task BulkLoad_WaitsPastThirtySeconds_WithTheOption_AndIsCutAtThirty_WithoutIt()
{
// Without the option: the driver's 30 seconds cut the load while the lock is held.
await using (var plain = await ServiceAsync(null))
await using (var blocker = await HoldValuesLockAsync())
{
var watch = Stopwatch.StartNew();
var act = () => plain.Redb.AddNewObjectsAsync(NewObjects("bulk-timeout-plain"));
var thrown = await act.Should().ThrowAsync();
watch.Stop();
HasSqlTimeout(thrown.Which).Should().BeTrue($"the load is cut by the client timeout, got: {thrown.Which}");
watch.Elapsed.Should().BeGreaterThan(TimeSpan.FromSeconds(25)).And.BeLessThan(TimeSpan.FromSeconds(90),
"the driver's default of 30 seconds applies");
}
// With the option: the load outwaits a lock held longer than 30 seconds and saves every object.
await using (var configured = await ServiceAsync(TimeSpan.FromSeconds(120)))
{
await using var blocker = await HoldValuesLockAsync();
var release = Task.Run(async () =>
{
await Task.Delay(LockHeld);
await blocker.DisposeAsync();
});
var watch = Stopwatch.StartNew();
var ids = await configured.Redb.AddNewObjectsAsync(NewObjects("bulk-timeout-set"));
watch.Stop();
await release;
ids.Should().HaveCount(Objects);
watch.Elapsed.Should().BeGreaterThan(TimeSpan.FromSeconds(30), "the load waited for the lock past the old cut");
(await configured.Redb.Query().Where(p => p.Title == "bulk-timeout-set").CountAsync())
.Should().Be(Objects);
(await configured.Redb.Query().Where(p => p.Title == "bulk-timeout-plain").CountAsync())
.Should().Be(0, "the cut load rolled back");
await configured.Redb.DeleteAsync(ids);
}
}
private static List> NewObjects(string title)
=> Enumerable.Range(0, Objects).Select(i => (IRedbObject)new RedbObject
{
name = $"{title}-{i}",
Props = new SimpleProps
{
Title = title, Count = i, Price = i, CreatedAt = DateTime.UtcNow, IsActive = true, Code = Guid.NewGuid(),
Description = "d", OptionalNumber = i
}
}).ToList();
private static bool HasSqlTimeout(Exception? e)
{
for (; e != null; e = e.InnerException)
if (e is SqlException { Number: -2 }) return true;
return false;
}
/// A session that holds an exclusive table lock on _values until it is disposed.
private async Task HoldValuesLockAsync()
{
// Not pooled: a pooled connection would go back to the pool with the transaction still open.
var connection = new SqlConnection(new SqlConnectionStringBuilder(_connectionString) { Pooling = false }.ConnectionString);
await connection.OpenAsync();
await using var command = new SqlCommand(
"BEGIN TRANSACTION; SELECT TOP (1) _id FROM _values WITH (TABLOCKX, HOLDLOCK);", connection);
await command.ExecuteNonQueryAsync();
return new ValuesLock(connection);
}
private sealed class ValuesLock(SqlConnection connection) : IAsyncDisposable
{
private int _released;
public async ValueTask DisposeAsync()
{
if (Interlocked.Exchange(ref _released, 1) == 1) return;
try
{
await using var rollback = new SqlCommand("IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION;", connection);
await rollback.ExecuteNonQueryAsync();
}
finally
{
await connection.DisposeAsync();
}
}
}
private async Task ServiceAsync(TimeSpan? bulkInsertTimeout)
{
var services = new ServiceCollection();
services.AddRedbPro(o => o.UseMsSql(_connectionString).Configure(c =>
{
c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking;
c.EnablePropsCache = false;
c.BulkInsertTimeout = bulkInsertTimeout;
}));
var provider = services.BuildServiceProvider();
var redb = provider.GetRequiredService();
await redb.InitializeAsync();
await redb.SyncSchemeAsync();
return new Service(provider, redb);
}
private sealed record Service(ServiceProvider Provider, IRedbService Redb) : IAsyncDisposable
{
public ValueTask DisposeAsync() => Provider.DisposeAsync();
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBytesRoundTripTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBytesRoundTripTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProBytesRoundTripTests : BytesRoundTripTestsBase
{
public MsSqlProBytesRoundTripTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCacheBehaviorTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCacheBehaviorTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProCacheBehaviorTests : CacheBehaviorTestsBase
{
public MsSqlProCacheBehaviorTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProColdSchemeLinkedObjectTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProColdSchemeLinkedObjectTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProColdSchemeLinkedObjectTests : ColdSchemeLinkedObjectTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProColdSchemeTreeFilterTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProColdSchemeTreeFilterTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProColdSchemeTreeFilterTests : ColdSchemeTreeFilterTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionFilterAnalyticsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionFilterAnalyticsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProCollectionFilterAnalyticsTests : CollectionFilterAnalyticsTestsBase
{
public MsSqlProCollectionFilterAnalyticsTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionGroupKeyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionGroupKeyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProCollectionGroupKeyTests : CollectionGroupKeyTestsBase
{
public MsSqlProCollectionGroupKeyTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionKindChangeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionKindChangeTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProCollectionKindChangeTests : CollectionKindChangeTestsBase
{
public MsSqlProCollectionKindChangeTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProComputedComparisonTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProComputedComparisonTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProComputedComparisonTests : ComputedComparisonTestsBase
{
public MsSqlProComputedComparisonTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrencyStressTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrencyStressTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProConcurrencyStressTests : ConcurrencyStressTestsBase
{
public MsSqlProConcurrencyStressTests(MsSqlProFixture fixture)
: base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentDeleteCountTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentDeleteCountTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProConcurrentDeleteCountTests : ConcurrentDeleteCountTestsBase
{
public MsSqlProConcurrentDeleteCountTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
protected override async Task HoldRowAsync(long objectId) => await RowHolders.SqlServerAsync(objectId);
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentDeleteListTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentDeleteListTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Pro.Extensions;
using redb.Core.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProConcurrentDeleteListTests : ConcurrentDeleteListTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentWritersTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentWritersTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProConcurrentWritersTests : ConcurrentWritersTestsBase
{
public MsSqlProConcurrentWritersTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConnectionLeaseTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConnectionLeaseTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProConnectionLeaseTests : ConnectionLeaseTestsBase
{
public MsSqlProConnectionLeaseTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { }
protected override string CreateProbeTableSql =>
"IF OBJECT_ID(N'dbo.connection_lease_rows', N'U') IS NULL CREATE TABLE dbo.connection_lease_rows (tag nvarchar(100) NOT NULL);";
protected override bool AmbientLeaseCarriesTransaction => false;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConstantPredicateTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConstantPredicateTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProConstantPredicateTests : ConstantPredicateTestsBase
{
public MsSqlProConstantPredicateTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProContainsWalkTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProContainsWalkTests.cs
----
using System.Linq.Expressions;
using redb.Core;
using redb.Core.Models.Entities;
using redb.Core.Query;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// A page in object order under a Contains on an array of text: SQL Server Pro walks the first rows of the array in
/// object order (at least 1 000, fifty per row of the page) and answers from the walk when it filled the page, from the
/// streams otherwise. The answers must not change: every query runs with the planner off and on and is compared with the
/// answer computed from the loaded objects, with the page filled by the walk (two values on many objects, Skip, a value
/// twice in one array, a scalar condition beside it, the id ascending), and left to the streams (a rare value; values
/// only on the last objects, past the walk's rows). The first object that matches is in the trash, its rows still there.
///
[Collection("MsSqlPro")]
public class MsSqlProContainsWalkTests
{
private const int Objects = 300;
private static readonly SemaphoreSlim SeedLock = new(1, 1);
private readonly IRedbService _redb;
public MsSqlProContainsWalkTests(MsSqlProFixture fixture) => _redb = fixture.Redb;
// About five rows of the array per object (its header and the elements), 1 500 for 300 objects: the walk of a page
// of 5 reads the first 1 000, about 200 objects, so the last objects are past it.
private static string[] SkillsOf(int i)
{
var skills = new List { "x", "y", "z" };
if (i % 2 == 0) skills.Add("a");
if (i % 10 == 0) skills.Add("a");
if (i % 3 == 0) skills.Add("b");
if (i == 250) skills.Add("rare");
if (i >= 280) skills.Add("late");
return skills.ToArray();
}
private async Task>> SeedAsync()
{
await SeedLock.WaitAsync();
try
{
var all = await _redb.Query().ToListAsync();
if (all.Count == Objects - 1)
return all;
if (all.Count > 0)
await _redb.DeleteAsync(all.Select(o => o.Id).ToList());
var objects = Enumerable.Range(0, Objects).Select(i => new RedbObject
{
name = $"contains-walk-{i:000}",
Props = new ContainsWalkProps { Age = i % 50, Department = i % 4 == 0 ? "eng" : "ops", Skills = SkillsOf(i) }
}).ToList();
await _redb.SaveAsync(objects);
// The first object holds a and b: in the trash with its rows, it must not come back.
await _redb.SoftDeleteAsync([objects[0].Id]);
all = await _redb.Query().ToListAsync();
all.Should().HaveCount(Objects - 1);
return all;
}
finally
{
SeedLock.Release();
}
}
private async Task EachFormAsync(Func check)
{
var restore = _redb.Configuration.EnablePvtPrefilter;
try
{
foreach (var on in new[] { false, true })
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = on);
await check(on ? "planner on" : "planner off");
}
}
finally
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
private static List Expected(IEnumerable> all, Func keep, int skip, int take)
=> all.Where(o => keep(o.Props)).Select(o => o.Id).OrderBy(id => id).Skip(skip).Take(take).ToList();
public static IEnumerable Pages()
{
static object[] Case(string name, Expression> filter, int skip, int take)
=> [name, filter, skip, take];
yield return Case("two wide values", p => p.Skills!.Contains("a") && p.Skills!.Contains("b"), 0, 5);
yield return Case("two wide values, Skip", p => p.Skills!.Contains("a") && p.Skills!.Contains("b"), 7, 5);
yield return Case("a value twice in one array", p => p.Skills!.Contains("a"), 0, 5);
yield return Case("a scalar condition beside it", p => p.Skills!.Contains("b") && p.Age > 30, 0, 5);
yield return Case("a text scalar beside it", p => p.Skills!.Contains("a") && p.Department == "eng", 0, 5);
yield return Case("a rare value", p => p.Skills!.Contains("rare") && p.Skills!.Contains("a"), 0, 5);
yield return Case("values past the walk", p => p.Skills!.Contains("late") && p.Skills!.Contains("a"), 0, 5);
yield return Case("no match", p => p.Skills!.Contains("rare") && p.Skills!.Contains("late"), 0, 5);
}
[Theory]
[MemberData(nameof(Pages))]
public async Task PageInObjectOrder_SameAnswer(string name, Expression> filter, int skip, int take)
{
var all = await SeedAsync();
var keep = filter.Compile();
var expected = Expected(all, keep, skip, take);
await EachFormAsync(async form =>
{
var plain = await _redb.Query().Where(filter).Skip(skip).Take(take).ToListAsync();
plain.Select(o => o.Id).Should().Equal(expected, $"{name}, no ordering, {form}");
var byId = await _redb.Query().Where(filter).OrderByRedb(o => o.Id).Skip(skip).Take(take).ToListAsync();
byId.Select(o => o.Id).Should().Equal(expected, $"{name}, by id, {form}");
var byIdDesc = await _redb.Query().Where(filter).OrderByDescendingRedb(o => o.Id).Skip(skip).Take(take).ToListAsync();
byIdDesc.Select(o => o.Id).Should().Equal(
all.Where(o => keep(o.Props)).Select(o => o.Id).OrderByDescending(id => id).Skip(skip).Take(take).ToList(),
$"{name}, by id descending, {form}");
});
}
///
/// The walk is written for a page in object order only: not for a page sorted by a Props field or by the id descending,
/// nor for a count. Read off the statement with the planner on (the streams form needs it).
///
[Fact]
public async Task Walk_OnlyForAPageInObjectOrder()
{
await SeedAsync();
var restore = _redb.Configuration.EnablePvtPrefilter;
try
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
IRedbQueryable Query() => _redb.Query().Where(p => p.Skills!.Contains("a") && p.Skills!.Contains("b"));
(await Query().Take(5).ToSqlStringAsync()).Should().Contain("@pvt_walk", "a page in object order");
(await Query().OrderByRedb(o => o.Id).Take(5).ToSqlStringAsync()).Should().Contain("@pvt_walk", "a page by id");
(await Query().OrderByDescendingRedb(o => o.Id).Take(5).ToSqlStringAsync()).Should().NotContain("@pvt_walk", "by id descending");
(await Query().OrderBy(p => p.Age).Take(5).ToSqlStringAsync()).Should().NotContain("@pvt_walk", "by a Props field");
(await Query().ToSqlStringAsync()).Should().NotContain("@pvt_walk", "no page");
}
finally
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCrudTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCrudTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProCrudTests : CrudTestsBase
{
public MsSqlProCrudTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCtPerfBenchmarkTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCtPerfBenchmarkTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProCtPerfBenchmarkTests : CtPerfBenchmarkTestsBase
{
public MsSqlProCtPerfBenchmarkTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override string ProviderName => "MsSqlPro";
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCtSaveInvariantsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCtSaveInvariantsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProCtSaveInvariantsTests : CtSaveInvariantsTestsBase
{
public MsSqlProCtSaveInvariantsTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
/// Фикстура гоняет ChangeTracking - строки нетронутых значений обязаны сохранять _id.
protected override bool ExpectStableValueRowIds => true;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDbInfoTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDbInfoTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProDbInfoTests : DbInfoTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
protected override string VersionMarker => "Microsoft SQL Server";
// sys.database_files.size is in 8 KB pages.
protected override string SizeInBytesSql => "SELECT SUM(CAST(size AS BIGINT)) * 8192 FROM sys.database_files";
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDecimalRoundTripTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDecimalRoundTripTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProDecimalRoundTripTests : DecimalRoundTripTestsBase
{
public MsSqlProDecimalRoundTripTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeepTreeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeepTreeTests.cs
----
using redb.Core;
using redb.Core.Models.Entities;
using redb.Core.Query;
using redb.Core.Query.Aggregation;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// An unrooted tree query that needs levels (WhereLevel, a query maxDepth) walks every node up to the real root of its
/// tree with a recursive CTE. SQL Server stops a recursion at 100 levels unless the statement says otherwise, and every
/// statement form that read that walk failed on a deeper tree ("The maximum recursion 100 has been exhausted"). A chain
/// of 120 levels on a scheme of its own, read by each form: the list, the count, Any, the query's maxDepth, Sum, a batch
/// aggregate, GroupBy, a window, GroupByArray, and the listing path of WhereHasAncestor.
///
[Collection("MsSqlPro")]
public class MsSqlProDeepTreeTests
{
private const int Depth = 120;
private readonly IRedbService _redb;
public MsSqlProDeepTreeTests(MsSqlProFixture fixture) => _redb = fixture.Redb;
private async Task SeedChainAsync()
{
await _redb.SyncSchemeAsync();
var tag = "deep-" + Guid.NewGuid().ToString("N")[..8];
TreeRedbObject Node(int i) => new()
{
name = $"{tag}-{i}",
Props = new DeepChainProps { Tag = tag, Index = i, Bucket = i % 2 == 0 ? "even" : "odd", Marks = [new() { Kind = "k" }] }
};
var previous = Node(0);
previous.id = await _redb.SaveAsync(previous);
for (var i = 1; i < Depth; i++)
{
var node = Node(i);
node.id = await _redb.CreateChildAsync(node, previous);
previous = node;
}
return tag;
}
[Fact]
public async Task EveryForm_ReadsATreeDeeperThan100Levels()
{
var tag = await SeedChainAsync();
// Levels count from the real root (level 0): the deepest ten nodes are levels 110..119.
IRedbQueryable Deep() => _redb.TreeQuery().Where(n => n.Tag == tag).WhereLevel(l => l >= 110);
var deepIndexes = Enumerable.Range(110, 10).ToList();
(await Deep().ToListAsync()).Select(o => o.Props.Index).Should().BeEquivalentTo(deepIndexes, "the list");
(await Deep().CountAsync()).Should().Be(10, "the count");
(await _redb.TreeQuery().Where(n => n.Tag == tag).WhereLevel(l => l >= Depth - 1).AnyAsync())
.Should().BeTrue("Any");
(await _redb.TreeQuery().Where(n => n.Tag == tag).WithMaxDepth(115).CountAsync())
.Should().Be(116, "the query's maxDepth, levels 0..115");
(await Deep().SumAsync(n => n.Index)).Should().Be(deepIndexes.Sum(), "Sum");
var batch = await Deep().AggregateAsync(x => new { Count = Agg.Count(), Max = Agg.Max(x.Props.Index) });
batch.Count.Should().Be(10, "a batch aggregate");
batch.Max.Should().Be(Depth - 1);
var groups = await Deep().GroupBy(n => n.Bucket).SelectAsync(g => new { g.Key, C = Agg.Count(g) });
groups.ToDictionary(g => g.Key, g => g.C).Should().BeEquivalentTo(new Dictionary { ["even"] = 5, ["odd"] = 5 }, "GroupBy");
var window = await Deep().WithWindow(w => w.OrderBy(n => n.Index)).SelectAsync(x => new { x.Id, Row = Win.RowNumber() });
window.Should().HaveCount(10, "a window");
var marks = await Deep().GroupByArray(n => n.Marks!, m => m.Kind).SelectAsync(g => new { g.Key, C = Agg.Count(g) });
marks.Single().C.Should().Be(10, "GroupByArray");
var listed = await _redb.TreeQuery().Where(n => n.Tag == tag)
.WhereHasAncestor(n => n.Tag == tag && n.Index == 100).WhereLevel(l => l >= 110).ToListAsync();
// The ancestor at level 100: the listing reaches the default 50 levels below it, so 110..119 are in.
listed.Select(o => o.Props.Index).Should().BeEquivalentTo(deepIndexes, "the listing path of WhereHasAncestor");
}
///
/// A tree query under one root or one parent walks down with a recursive CTE when the planner is off; with a depth
/// limit above 100 that recursion went past SQL Server's default of 100 levels on the chain. The list, the count and
/// the subtree that WhereHasAncestor looks for its ancestors in, each under the node at the top of the chain.
///
[Fact]
public async Task UnderOneRootOrParent_PlannerOff_ReadsMoreThan100LevelsDown()
{
var tag = await SeedChainAsync();
var top = (await _redb.TreeQuery().Where(n => n.Tag == tag && n.Index == 0).ToListAsync()).Single().Id;
var below = Enumerable.Range(1, Depth - 1).ToList();
var restore = _redb.Configuration.EnablePvtPrefilter;
try
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false);
(await _redb.TreeQuery(top, 150).Where(n => n.Tag == tag).ToListAsync())
.Select(o => o.Props.Index).Should().BeEquivalentTo(below, "under the root");
(await _redb.TreeQuery(top, 150).Where(n => n.Tag == tag).CountAsync())
.Should().Be(Depth - 1, "the count under the root");
(await _redb.TreeQuery(new[] { top }, 150).Where(n => n.Tag == tag).ToListAsync())
.Select(o => o.Props.Index).Should().BeEquivalentTo(below, "under one parent");
var under = await _redb.TreeQuery(top, 150).Where(n => n.Tag == tag)
.WhereHasAncestor(n => n.Tag == tag && n.Index == 105).ToListAsync();
under.Select(o => o.Props.Index).Should().BeEquivalentTo(Enumerable.Range(106, Depth - 106),
"WhereHasAncestor looks for the ancestor in the subtree of the root");
}
finally
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
///
/// WhereHasAncestor under a root lists the descendants of the matching ancestors first, with a recursion as deep as its
/// maxDepth: 150 below the node at level 5 of the chain reaches the bottom, 114 levels down, past SQL Server's default
/// of 100.
///
[Fact]
public async Task UnderARoot_WhereHasAncestor_ListsMoreThan100LevelsDown()
{
var tag = await SeedChainAsync();
var top = (await _redb.TreeQuery().Where(n => n.Tag == tag && n.Index == 0).ToListAsync()).Single().Id;
var under = await _redb.TreeQuery(top, 150).Where(n => n.Tag == tag)
.WhereHasAncestor(n => n.Tag == tag && n.Index == 5, 150).ToListAsync();
under.Select(o => o.Props.Index).Should().BeEquivalentTo(Enumerable.Range(6, Depth - 6));
}
///
/// WhereHasDescendant with no root, no parents and no other tree filter climbs in the batch of the statement that
/// reads the nodes (a loop over a table variable, one level per pass). A match at the bottom of the chain with maxDepth
/// 150 climbs 119 levels to the top; without maxDepth the default 50. List and count, planner off and on.
///
[Fact]
public async Task InBatch_WhereHasDescendant_ClimbsMoreThan100Levels()
{
var tag = await SeedChainAsync();
IRedbQueryable Above(int? maxDepth) => _redb.TreeQuery().Where(n => n.Tag == tag)
.WhereHasDescendant(n => n.Tag == tag && n.Index == Depth - 1, maxDepth);
var restore = _redb.Configuration.EnablePvtPrefilter;
try
{
foreach (var on in new[] { false, true })
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = on);
var form = on ? "planner on" : "planner off";
(await Above(150).ToListAsync()).Select(o => o.Props.Index)
.Should().BeEquivalentTo(Enumerable.Range(0, Depth - 1), $"every node above the bottom, {form}");
(await Above(150).CountAsync()).Should().Be(Depth - 1, $"the count, {form}");
(await Above(null).ToListAsync()).Select(o => o.Props.Index)
.Should().BeEquivalentTo(Enumerable.Range(Depth - 51, 50), $"the default 50 levels, {form}");
}
}
finally
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeleteBatchCountTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeleteBatchCountTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProDeleteBatchCountTests : DeleteBatchCountTestsBase
{
public MsSqlProDeleteBatchCountTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeleteSubtreeCountTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeleteSubtreeCountTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Pro.Extensions;
using redb.Core.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProDeleteSubtreeCountTests : DeleteSubtreeCountTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryEntryKeyFilterTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryEntryKeyFilterTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProDictionaryEntryKeyFilterTests : DictionaryEntryKeyFilterTestsBase
{
public MsSqlProDictionaryEntryKeyFilterTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryEntryLeadsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryEntryLeadsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProDictionaryEntryLeadsTests : DictionaryEntryLeadsTestsBase
{
public MsSqlProDictionaryEntryLeadsTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryOrderTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryOrderTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProDictionaryOrderTests : DictionaryOrderTestsBase
{
public MsSqlProDictionaryOrderTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProDictionaryTests : DictionaryTestsBase
{
public MsSqlProDictionaryTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override int? DictionaryKeyBound => 430;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDisposedScopeGuardTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDisposedScopeGuardTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProDisposedScopeGuardTests : DisposedScopeGuardTestsBase
{
public MsSqlProDisposedScopeGuardTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProElementFoldOrderTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProElementFoldOrderTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProElementFoldOrderTests : ElementFoldOrderTestsBase
{
public MsSqlProElementFoldOrderTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProElementIndexFilterTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProElementIndexFilterTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProElementIndexFilterTests : ElementIndexFilterTestsBase
{
public MsSqlProElementIndexFilterTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProEnumComparisonTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProEnumComparisonTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProEnumComparisonTests : EnumComparisonTestsBase
{
public MsSqlProEnumComparisonTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProEnumDictionaryKeyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProEnumDictionaryKeyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProEnumDictionaryKeyTests : EnumDictionaryKeyTestsBase
{
public MsSqlProEnumDictionaryKeyTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProFieldNamedLikeAFunctionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProFieldNamedLikeAFunctionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProFieldNamedLikeAFunctionTests : FieldNamedLikeAFunctionTestsBase
{
public MsSqlProFieldNamedLikeAFunctionTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProFilterFieldPathTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProFilterFieldPathTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProFilterFieldPathTests : FilterFieldPathTestsBase
{
public MsSqlProFilterFieldPathTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override bool ReadsElementsByIndex => true;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupByHavingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupByHavingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProGroupByHavingTests : GroupByHavingTestsBase
{
public MsSqlProGroupByHavingTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupBySelectShapesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupBySelectShapesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProGroupBySelectShapesTests : GroupBySelectShapesTestsBase
{
public MsSqlProGroupBySelectShapesTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupByTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupByTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProGroupByTests : GroupByTestsBase
{
public MsSqlProGroupByTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHasAncestorFormTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHasAncestorFormTests.cs
----
using redb.Core;
using redb.Core.Models.Contracts;
using redb.Core.Models.Entities;
using redb.Core.Query;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Helpers;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// WhereHasAncestor on SQL Server Pro: without a root, parents, query depth or other tree filter, the query walks down from
/// the matching ancestors as its parents, in the statement that reads the page: without maxDepth at any depth, with a
/// maxDepth at most that many levels (the query's own depth limit). Every other case lists the descendants first and sends
/// their ids back. Each case returns the right objects; the walk takes one data statement less than the listing. With a
/// maxDepth the walk must count from the nearest matching ancestor and return a node under two nested ones once.
///
[Collection("MsSqlPro")]
public class MsSqlProHasAncestorFormTests
{
private readonly IRedbService _redb;
public MsSqlProHasAncestorFormTests(MsSqlProFixture fixture) => _redb = fixture.Redb;
// root (marked) -> a -> b -> c, and root -> d. Only the root matches the ancestor condition.
private async Task<(string Tag, long Root, long A, long B, long C, long D)> SeedAsync()
{
var tag = "ha-" + Guid.NewGuid().ToString("N")[..8];
var root = TestDataFactory.CreateTreeNode($"{tag}-root", tag);
root.Props.Description = "anchor";
root.id = await _redb.SaveAsync(root);
var a = TestDataFactory.CreateTreeNode($"{tag}-a", tag); a.Props.Description = "mid"; a.id = await _redb.CreateChildAsync(a, root);
var b = TestDataFactory.CreateTreeNode($"{tag}-b", tag); b.id = await _redb.CreateChildAsync(b, a);
var c = TestDataFactory.CreateTreeNode($"{tag}-c", tag); c.id = await _redb.CreateChildAsync(c, b);
var d = TestDataFactory.CreateTreeNode($"{tag}-d", tag); d.id = await _redb.CreateChildAsync(d, root);
return (tag, root.id, a.id, b.id, c.id, d.id);
}
private static async Task<(List Ids, int Statements)> RunAsync(IRedbQueryable query)
{
List ids = [];
var statements = await CommandCounter.CountAsync(async () =>
ids = (await query.ToListAsync()).Select(o => o.id).ToList());
return (ids, statements);
}
[Fact]
public async Task EachCase_ReturnsItsAnswer_InTheFormItsShapeCalls()
{
var (tag, root, a, b, c, d) = await SeedAsync();
IRedbQueryable Tree() => _redb.TreeQuery().Where(n => n.Code == tag);
// No maxDepth: every descendant of the root, walked from it.
var any = await RunAsync(Tree().WhereHasAncestor(n => n.Code == tag && n.Description == "anchor"));
any.Ids.Should().BeEquivalentTo([a, b, c, d]);
// maxDepth 1: the children, walked from the root.
var children = await RunAsync(Tree().WhereHasAncestor(n => n.Code == tag && n.Description == "anchor", 1));
children.Ids.Should().BeEquivalentTo([a, d]);
// maxDepth 2: two levels, walked from the root with the query's depth limit.
var two = await RunAsync(Tree().WhereHasAncestor(n => n.Code == tag && n.Description == "anchor", 2));
two.Ids.Should().BeEquivalentTo([a, b, d]);
// A root of the query: listed first. The ancestor is looked for inside the query's tree, so it is a, not the root.
var rooted = await RunAsync(_redb.TreeQuery(root).Where(n => n.Code == tag)
.WhereHasAncestor(n => n.Code == tag && n.Description == "mid"));
rooted.Ids.Should().BeEquivalentTo([b, c]);
// Another tree filter beside it (a second WhereHasAncestor): the first one is listed, the second resolved after it.
var both = await RunAsync(Tree().WhereHasAncestor(n => n.Code == tag && n.Description == "anchor")
.WhereHasAncestor(n => n.Code == tag && n.Description == "mid"));
both.Ids.Should().BeEquivalentTo([b, c], "under the anchor and under a");
// The walk reads the page in the statement that walks down; the listing adds the statement of the descendants.
var counts = $"statements: no maxDepth {any.Statements}, maxDepth 1 {children.Statements}, maxDepth 2 {two.Statements}, " +
$"rooted {rooted.Statements}, two filters {both.Statements}";
two.Statements.Should().Be(any.Statements, "maxDepth 2 walks down from the ancestors too; {0}", counts);
rooted.Statements.Should().BeGreaterThan(any.Statements, "a rooted query keeps the listing; {0}", counts);
both.Statements.Should().BeGreaterThan(any.Statements, "another tree filter keeps the listing; {0}", counts);
}
///
/// Two matching ancestors, one under the other: root (marked) -> a (marked) -> x -> y, and root -> d. With maxDepth 2,
/// x is one level below a and two below the root and comes once; y is two levels below a, three below the root, and is
/// in: the depth counts from the nearest matching ancestor.
///
[Fact]
public async Task MaxDepth_NestedAncestors_NodeOnce_DepthFromTheNearest()
{
var tag = "han-" + Guid.NewGuid().ToString("N")[..8];
var root = TestDataFactory.CreateTreeNode($"{tag}-root", tag); root.Props.Description = "anchor";
root.id = await _redb.SaveAsync(root);
var a = TestDataFactory.CreateTreeNode($"{tag}-a", tag); a.Props.Description = "anchor"; a.id = await _redb.CreateChildAsync(a, root);
var x = TestDataFactory.CreateTreeNode($"{tag}-x", tag); x.id = await _redb.CreateChildAsync(x, a);
var y = TestDataFactory.CreateTreeNode($"{tag}-y", tag); y.id = await _redb.CreateChildAsync(y, x);
var z = TestDataFactory.CreateTreeNode($"{tag}-z", tag); z.id = await _redb.CreateChildAsync(z, y);
var d = TestDataFactory.CreateTreeNode($"{tag}-d", tag); d.id = await _redb.CreateChildAsync(d, root);
IRedbQueryable Under(int maxDepth) => _redb.TreeQuery().Where(n => n.Code == tag)
.WhereHasAncestor(n => n.Code == tag && n.Description == "anchor", maxDepth);
var two = (await Under(2).ToListAsync()).Select(o => o.id).ToList();
two.Should().OnlyHaveUniqueItems("x is under both anchors");
two.Should().BeEquivalentTo([a.id, x.id, y.id, d.id], "z is three levels below a");
var three = (await Under(3).ToListAsync()).Select(o => o.id).ToList();
three.Should().OnlyHaveUniqueItems();
three.Should().BeEquivalentTo([a.id, x.id, y.id, z.id, d.id]);
(await Under(2).CountAsync()).Should().Be(4, "the count reads the same walk");
}
///
/// More matching ancestors than the provider sends one parameter each (ProSqlBuilder.InListParameterLimit, 500): the
/// parents travel as one list. 520 marked roots, each with a child and a grandchild, one great-grandchild under the
/// first; maxDepth 2 returns the children and the grandchildren.
///
[Fact]
public async Task MaxDepth_ParentsAboveTheParameterLimit()
{
const int anchors = 520;
var tag = "hap-" + Guid.NewGuid().ToString("N")[..8];
IRedbObject Node(string name, long? parent, string? description = null) => new RedbObject
{
name = name, parent_id = parent,
Props = new TreeNodeProps { Name = name, Code = tag, Description = description ?? string.Empty, IsActive = true }
};
var rootIds = await _redb.SaveAsync(Enumerable.Range(0, anchors).Select(i => Node($"{tag}-r{i}", null, "anchor")).ToList());
var childIds = await _redb.SaveAsync(rootIds.Select((r, i) => Node($"{tag}-c{i}", r)).ToList());
var grandchildIds = await _redb.SaveAsync(childIds.Select((c, i) => Node($"{tag}-g{i}", c)).ToList());
await _redb.SaveAsync(new List { Node($"{tag}-deep", grandchildIds[0]) });
var ids = (await _redb.TreeQuery().Where(n => n.Code == tag)
.WhereHasAncestor(n => n.Code == tag && n.Description == "anchor", 2).ToListAsync())
.Select(o => o.id).ToList();
ids.Should().OnlyHaveUniqueItems();
ids.Should().BeEquivalentTo(childIds.Concat(grandchildIds));
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHasDescendantFormTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHasDescendantFormTests.cs
----
using redb.Core;
using redb.Core.Query;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Helpers;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// WhereHasDescendant on SQL Server Pro: with no root, no parents and no other tree filter, the climb from the matching
/// descendants runs in the batch of the statement that reads the nodes, into a temporary table that statement reads;
/// otherwise its ids come back first and are sent as a condition on the object id. Each case returns the objects that
/// have a matching descendant (within maxDepth), in both planner modes, through the list, the count, Any and an
/// aggregate; the batch takes one statement less than the ids sent back.
///
[Collection("MsSqlPro")]
public class MsSqlProHasDescendantFormTests
{
private readonly IRedbService _redb;
public MsSqlProHasDescendantFormTests(MsSqlProFixture fixture) => _redb = fixture.Redb;
// r -> a -> b (marked), r -> c; x -> y (marked); z (marked, no parent, no child).
private async Task<(string Tag, long R, long A, long B, long C, long X, long Y, long Z)> SeedAsync()
{
var tag = "hd-" + Guid.NewGuid().ToString("N")[..8];
async Task Node(string name, long? parent, bool marked, decimal budget)
{
var n = TestDataFactory.CreateTreeNode($"{tag}-{name}", tag, budget);
n.Props.Description = marked ? "marked" : "plain";
if (parent == null) return await _redb.SaveAsync(n);
var parentNode = await _redb.LoadAsync(parent.Value);
return await _redb.CreateChildAsync(n, parentNode!);
}
var r = await Node("r", null, false, 1);
var a = await Node("a", r, false, 10);
var b = await Node("b", a, true, 100);
var c = await Node("c", r, false, 1000);
var x = await Node("x", null, false, 10000);
var y = await Node("y", x, true, 100000);
var z = await Node("z", null, true, 1000000);
return (tag, r, a, b, c, x, y, z);
}
private async Task EachFormAsync(Func check)
{
var restore = _redb.Configuration.EnablePvtPrefilter;
try
{
foreach (var on in new[] { false, true })
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = on);
await check(on ? "planner on" : "planner off");
}
}
finally
{
_redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
[Fact]
public async Task EachCase_ReturnsTheObjectsAboveAMatch()
{
var (tag, r, a, _, _, x, _, _) = await SeedAsync();
IRedbQueryable Above(string description, int? maxDepth = null) => _redb.TreeQuery()
.Where(n => n.Code == tag).WhereHasDescendant(n => n.Code == tag && n.Description == description, maxDepth);
await EachFormAsync(async form =>
{
(await Above("marked").ToListAsync()).Select(o => o.id).Should().BeEquivalentTo([r, a, x], form);
(await Above("marked", 1).ToListAsync()).Select(o => o.id).Should().BeEquivalentTo([a, x], $"maxDepth 1, {form}");
(await Above("marked").CountAsync()).Should().Be(3, $"count, {form}");
(await Above("marked").AnyAsync()).Should().BeTrue($"any, {form}");
(await Above("marked").SumAsync(n => n.Budget)).Should().Be(10011m, $"sum, {form}");
(await Above("none").ToListAsync()).Should().BeEmpty($"no match, {form}");
(await Above("none").CountAsync()).Should().Be(0, $"no match, count, {form}");
(await Above("none").AnyAsync()).Should().BeFalse($"no match, any, {form}");
// Under a root: the climb looks among the root's descendants and its ids come back first.
(await _redb.TreeQuery(r).Where(n => n.Code == tag)
.WhereHasDescendant(n => n.Code == tag && n.Description == "marked").ToListAsync())
.Select(o => o.id).Should().BeEquivalentTo([a], $"under a root, {form}");
});
}
[Fact]
public async Task InBatch_TakesOneStatementLess_AndShowsTheClimbInItsPreview()
{
var (tag, r, a, _, _, x, _, _) = await SeedAsync();
var plain = _redb.TreeQuery().Where(n => n.Code == tag)
.WhereHasDescendant(n => n.Code == tag && n.Description == "marked");
// A second tree filter keeps the ids sent back.
var listed = _redb.TreeQuery().Where(n => n.Code == tag)
.WhereHasDescendant(n => n.Code == tag && n.Description == "marked")
.WhereHasDescendant(n => n.Code == tag && n.Description == "marked");
List plainIds = [], listedIds = [];
var inBatch = await CommandCounter.CountAsync(async () => plainIds = (await plain.ToListAsync()).Select(o => o.id).ToList());
var sentBack = await CommandCounter.CountAsync(async () => listedIds = (await listed.ToListAsync()).Select(o => o.id).ToList());
plainIds.Should().BeEquivalentTo([r, a, x]);
listedIds.Should().BeEquivalentTo([r, a, x]);
inBatch.Should().BeLessThan(sentBack, "the climb runs in the batch of the statement; sent back it is a statement of its own and a second for the next filter");
var preview = await plain.ToSqlStringAsync();
preview.Should().Contain("#redb_up", "the climb is part of the batch shown");
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHashCanonCollisionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHashCanonCollisionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProHashCanonCollisionTests : HashCanonCollisionTestsBase
{
public MsSqlProHashCanonCollisionTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIgnoredPropertyWalkTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIgnoredPropertyWalkTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProIgnoredPropertyWalkTests : IgnoredPropertyWalkTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIndexCatalogTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIndexCatalogTests.cs
----
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Models;
using redb.Core.Models.Configuration;
using redb.MSSql.Pro.Sql;
using redb.MSSql.Sql;
using redb.Tests.Integration.Tests.MsSql;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// MsSqlProIndexCatalog.Pro, the index of the streams query form, against a fresh SQL Server Pro database of this build
/// with the planner on (see ).
///
public class MsSqlProIndexCatalogTests : MsSqlIndexCatalogTests
{
protected override void AddRedb(IServiceCollection services, string connectionString, Action configure)
=> redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions.AddRedbPro(services,
o => redb.MSSql.Pro.Extensions.MsSqlProOptionsExtensions.UseMsSql(o, connectionString).Configure(configure));
protected override IReadOnlyList Catalog => MsSqlProIndexCatalog.Pro;
protected override IReadOnlyList CoveredElsewhere => MsSqlIndexCatalog.Base;
protected override (string File, string Namespace, string Class, string Member, RedbIndexOrigin Origin) Target =>
("redb.MSSql.Pro/Sql/MsSqlProIndexCatalog.g.cs", "redb.MSSql.Pro.Sql", "MsSqlProIndexCatalog", "Pro", RedbIndexOrigin.ProModule);
}
/// The streams index of SQL Server Pro is built once (see ).
public class MsSqlProStreamsIndexOnceTests : Base.StreamsIndexOnceTestsBase
{
protected override async Task CreateDatabaseAsync(string name)
{
await MsSqlIndexCatalogTests.ExecAdminAsync($"CREATE DATABASE [{name}]");
return new Microsoft.Data.SqlClient.SqlConnectionStringBuilder(MsSqlIndexCatalogTests.AdminBase) { InitialCatalog = name }.ConnectionString;
}
protected override async Task DropDatabaseAsync(string name)
{
Microsoft.Data.SqlClient.SqlConnection.ClearAllPools();
await MsSqlIndexCatalogTests.ExecAdminAsync(
$"IF DB_ID(N'{name}') IS NOT NULL BEGIN ALTER DATABASE [{name}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{name}]; END");
}
protected override void AddRedbPro(IServiceCollection services, string connectionString, Action configure)
=> redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions.AddRedbPro(services,
o => redb.MSSql.Pro.Extensions.MsSqlProOptionsExtensions.UseMsSql(o, connectionString).Configure(configure));
protected override string StreamsIndex => "IX__values__structure_object_scalar";
protected override string DropStreamsIndexSql => "DROP INDEX [IX__values__structure_object_scalar] ON [dbo].[_values]";
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIntegerAverageTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIntegerAverageTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProIntegerAverageTests : IntegerAverageTestsBase
{
public MsSqlProIntegerAverageTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeyCacheRepeatTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeyCacheRepeatTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProKeyCacheRepeatTests : KeyCacheRepeatTestsBase
{
public MsSqlProKeyCacheRepeatTests(MsSqlProFixture fixture) { _ = fixture; }
protected override ServiceProvider Build(string applicationName)
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var cs = config.GetConnectionString("MSSql")! + $";Application Name={applicationName}";
var services = new ServiceCollection();
services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning));
services.AddRedbPro(options =>
{
options.UseMsSql(cs).Configure(c => c.EnablePvtPrefilter = ProTestOptions.PvtPrefilter);
if (config["Redb:License"] is { Length: > 0 } license)
options.WithLicense(license);
});
return services.BuildServiceProvider();
}
protected override string SequenceTopSql =>
"SELECT CAST(current_value AS bigint) FROM sys.sequences WHERE name = 'global_identity'";
protected override string SequenceRestartSql(long next) => $"ALTER SEQUENCE dbo.global_identity RESTART WITH {next}";
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeyDrawTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeyDrawTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProKeyDrawTests : KeyDrawTestsBase
{
public MsSqlProKeyDrawTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeywordNamesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeywordNamesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProKeywordNamesTests : KeywordNamesTestsBase
{
public MsSqlProKeywordNamesTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyHostTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyHostTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProLazyHostTests : LazyHostTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
protected override string ReadFlagSql => "SELECT CAST(SESSION_CONTEXT(N'redb.lazy_refs') AS NVARCHAR(10))";
/// The Pro materializer reads the global option live; its registrations do not arm the session flag.
protected override bool SessionFlagIsTheChannel => false;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyReferenceTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyReferenceTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProLazyReferenceTests : LazyReferenceTestsBase
{
public MsSqlProLazyReferenceTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyReferencesOptionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyReferencesOptionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProLazyReferencesOptionTests : LazyReferencesOptionTestsBase
{
public MsSqlProLazyReferencesOptionTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
// Л2 boundary: the Pro materializer reads the global option, not the session flag.
protected override bool PerQueryOverrideWorks => false;
protected override bool GlobalMutationAffects => true;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLikeEscapingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLikeEscapingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProLikeEscapingTests : LikeEscapingTestsBase
{
public MsSqlProLikeEscapingTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListItemArrayAnyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListItemArrayAnyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProListItemArrayAnyTests : ListItemArrayAnyTestsBase
{
public MsSqlProListItemArrayAnyTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListItemObjectWalkTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListItemObjectWalkTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProListItemObjectWalkTests : ListItemObjectWalkTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListReadPropsOnceTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListReadPropsOnceTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Pro.Extensions;
using redb.Core.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProListReadPropsOnceTests : ListReadPropsOnceTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListRoundTripsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListRoundTripsTests.cs
----
using System.Data.Common;
using System.Diagnostics;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProListRoundTripsTests : ListRoundTripsTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
///
/// The list goes to the server as its builder writes it (the statement ToSqlStringAsync shows), with the scheme hash
/// as a second result set of the same batch: no table variable around the page. The INSERT ... SELECT of the page into
/// a table variable lost the parallel and the batch-mode plans of sorted and distinct pages.
///
[Fact]
public async Task ListStatement_IsSentAsBuilt_WithTheHashBesideIt()
{
var run = Guid.NewGuid().ToString("N")[..8];
var services = new ServiceCollection();
Register(services, options =>
{
UseProvider(options);
options.Configure(c => { c.EnablePropsCache = false; c.CacheDomain = $"round-trips-text-{run}"; });
});
await using var sp = services.BuildServiceProvider();
var redb = sp.GetRequiredService();
await redb.InitializeAsync(ensureCreated: true);
await redb.SyncSchemeAsync();
var query = redb.Query().Where(p => p.Tag == run).OrderBy(p => p.Number).Take(10);
await query.ToListAsync();
var preview = await query.ToSqlStringAsync();
var built = string.Join("\n", preview.Split('\n').Where(l => !l.TrimStart().StartsWith("--", StringComparison.Ordinal))).Trim();
var sent = new List();
using var observer = new ListenerObserver(listener => listener.Name != "SqlClientDiagnosticListener" ? null
: listener.Subscribe(new EventObserver(e =>
{
if (e.Key.EndsWith("WriteCommandBefore", StringComparison.Ordinal)
&& e.Value?.GetType().GetProperty("Command")?.GetValue(e.Value) is DbCommand command)
lock (sent) sent.Add(command.CommandText);
})));
using (DiagnosticListener.AllListeners.Subscribe(observer))
await query.ToListAsync();
lock (sent)
{
sent.Should().NotContain(s => s.Contains("@redb_page", StringComparison.Ordinal), "the page is not wrapped");
sent.Should().Contain(s => s.Contains(built, StringComparison.Ordinal)
&& s.Contains("_structure_hash FROM _schemes", StringComparison.Ordinal),
"the list goes as its builder writes it, with the hash in its batch");
}
}
private sealed class ListenerObserver(Func onNext) : IObserver, IDisposable
{
private readonly List _subscriptions = [];
public void OnNext(DiagnosticListener value) { if (onNext(value) is { } s) lock (_subscriptions) _subscriptions.Add(s); }
public void OnError(Exception error) { }
public void OnCompleted() { }
public void Dispose() { lock (_subscriptions) foreach (var s in _subscriptions) s.Dispose(); }
}
private sealed class EventObserver(Action> onNext) : IObserver>
{
public void OnNext(KeyValuePair value) => onNext(value);
public void OnError(Exception error) { }
public void OnCompleted() { }
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProListTests : ListTestsBase
{
protected override bool IsPro => true;
public MsSqlProListTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLiteralStructureIdsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLiteralStructureIdsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProLiteralStructureIdsTests : LiteralStructureIdsTestsBase
{
public MsSqlProLiteralStructureIdsTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLongBaseFilterTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLongBaseFilterTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProLongBaseFilterTests : LongBaseFilterTestsBase
{
public MsSqlProLongBaseFilterTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaintenanceTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaintenanceTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProMaintenanceTests : MaintenanceTestsBase
{
public MsSqlProMaintenanceTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaterializationFidelityTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaterializationFidelityTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProMaterializationFidelityTests : MaterializationFidelityTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaterializerConversionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaterializerConversionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProMaterializerConversionTests : ProMaterializerConversionTestsBase
{
public MsSqlProMaterializerConversionTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTargetAddressingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTargetAddressingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProMigrationTargetAddressingTests : MigrationTargetAddressingTestsBase
{
public MsSqlProMigrationTargetAddressingTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProMigrationTests : MigrationTestsBase
{
public MsSqlProMigrationTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTransformArithmeticTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTransformArithmeticTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProMigrationTransformArithmeticTests : MigrationTransformArithmeticTestsBase
{
public MsSqlProMigrationTransformArithmeticTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNestedDictionaryFilterTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNestedDictionaryFilterTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProNestedDictionaryFilterTests : NestedDictionaryFilterTestsBase
{
public MsSqlProNestedDictionaryFilterTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNullComparisonTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNullComparisonTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProNullComparisonTests : NullComparisonTestsBase
{
public MsSqlProNullComparisonTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNullableCollectionsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNullableCollectionsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProNullableCollectionsTests : NullableCollectionsTestsBase
{
public MsSqlProNullableCollectionsTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOlderModelTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOlderModelTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProOlderModelTests : OlderModelTestsBase
{
public MsSqlProOlderModelTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOrderAbsentValueTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOrderAbsentValueTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProOrderAbsentValueTests : OrderAbsentValueTestsBase
{
public MsSqlProOrderAbsentValueTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOrderingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOrderingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProOrderingTests : OrderingTestsBase
{
public MsSqlProOrderingTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPageValuesGraphTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPageValuesGraphTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProPageValuesGraphTests : PageValuesGraphTestsBase
{
public MsSqlProPageValuesGraphTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProProQueryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProProQueryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProProQueryTests : ProQueryTestsBase
{
public MsSqlProProQueryTests(MsSqlProFixture fixture) : base(fixture.Redb, isPro: true) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProProjectionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProProjectionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProProjectionTests : ProjectionTestsBase
{
public MsSqlProProjectionTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override bool ReadsOnlyProjectedRows => true;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropertyRenameTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropertyRenameTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProPropertyRenameTests : PropertyRenameTestsBase
{
public MsSqlProPropertyRenameTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheHeaderTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheHeaderTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProPropsCacheHeaderTests : PropsCacheHeaderTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheSkipValidationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheSkipValidationTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProPropsCacheSkipValidationTests : PropsCacheSkipValidationTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheTransactionKeepTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheTransactionKeepTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Pro.Extensions;
using redb.Core.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProPropsCacheTransactionKeepTests : PropsCacheTransactionKeepTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheTransactionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheTransactionTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Pro.Extensions;
using redb.Core.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProPropsCacheTransactionTests : PropsCacheTransactionTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsDepthBoundaryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsDepthBoundaryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProPropsDepthBoundaryTests : PropsDepthBoundaryTestsBase
{
public MsSqlProPropsDepthBoundaryTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPvtPrefilterEquivalenceTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPvtPrefilterEquivalenceTests.cs
----
using redb.Core.Models.Contracts;
using redb.Core.Models.Entities;
using redb.Core.Query;
using redb.Core.Query.Aggregation;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Helpers;
using redb.Tests.Integration.Models;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProPvtPrefilterEquivalenceTests : PvtPrefilterEquivalenceTestsBase
{
public MsSqlProPvtPrefilterEquivalenceTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
/// See .
[Fact]
public Task UnfilteredExtremes_FirstEntryOfTheIndex_SameAnswers() => UnfilteredExtremes_FirstEntryOfTheIndex_SameAnswersAsync();
/// See .
[Fact]
public Task AllWithoutFilter_ProbeThenCounts_SameAnswers() => AllWithoutFilter_ProbeThenCounts_SameAnswersAsync();
///
/// An OR of narrow branches stays on the aggregate form, where the row prefilter reads every
/// branch from the index of values; as streams it was checked above every object of the scheme
/// (examples, three string branches: 1 694 ms against 95 ms). A narrow leaf in the top-level AND
/// keeps the streams. Asserted on the SQL, and the answer must not change.
///
[Fact]
public async Task Streams_NarrowOrGoesToRowPrefilter_NarrowAndKeepsStreams()
{
await TestDataFactory.SeedEmployees(Redb, 40);
var restore = Redb.Configuration.EnablePvtPrefilter;
try
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
IRedbQueryable NarrowOr() => Redb.Query()
.Where(e => e.Department == "Engineering" || e.Position == "Developer" || e.LastName == "Smith")
.OrderByRedb(o => o.Id).Take(100);
var narrowOr = await NarrowOr().ToSqlStringAsync();
narrowOr.Should().Contain("Streams not applied, the filter is an OR of narrow branches");
narrowOr.Should().Contain("-- PVT prefilter: Row form, 3 branch(es)");
var narrowAnd = await Redb.Query()
.Where(e => e.Department == "Engineering" && (e.Age > 30 || e.Position == "Developer"))
.OrderByRedb(o => o.Id).Take(100)
.ToSqlStringAsync();
narrowAnd.Should().Contain("-- PVT form: Streams,",
"an equality in the top-level AND is pushed into its stream");
var on = (await NarrowOr().ToListAsync()).Select(r => r.id).ToList();
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false);
var off = (await NarrowOr().ToListAsync()).Select(r => r.id).ToList();
on.Should().Equal(off, "the form changes the plan, not the answer");
}
finally
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
///
/// A narrow leaf on an indexed column (a number here) drives the streams off the index of values, the trash subtracted:
/// a count, an existence check, a page, a grouping, an aggregate. A text leaf does not: _String has no index of values on
/// SQL Server. Next to a filter on the object's own fields that is wide by its shape (an id range) the leaf lifts FORCE
/// ORDER and the index hint; next to one narrow by its shape (an IN list of ids) the forced order stays. An object in the
/// trash holds the value of the leaf, and a page also requires a field absent. Every answer must equal the one with the
/// prefilter off.
///
[Fact]
public async Task DrivingLeaf_IndexedLeafOnly_TrashSubtracted_SameAnswers()
{
var ids = await TestDataFactory.SeedEmployees(Redb, 40);
var victim = ids[1];
var age = (await Redb.Query().WhereRedb(o => o.Id == victim).ToListAsync()).Single().Props.Age;
await Redb.SoftDeleteAsync(new[] { victim, ids[7] });
var some = ids.Skip(10).Take(15).ToList();
const string driven = "FROM (SELECT dv._id_object AS _id";
const string trash = "NOT IN (SELECT t._id FROM _objects t WHERE t._id_scheme = -10)";
var restore = Redb.Configuration.EnablePvtPrefilter;
try
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
IRedbQueryable Aged() => Redb.Query().Where(e => e.Age == age);
var page = await Aged().Take(10).ToSqlStringAsync();
page.Should().Contain(driven).And.Contain(trash).And.NotContain("FORCE ORDER");
(await Aged().GroupBy(e => e.Department).ToSqlStringAsync(g => new { g.Key, C = Agg.Count(g) }))
.Should().Contain(driven, "a grouping reads its objects off the leaf as well");
(await Aged().ToAggregateSqlStringAsync(x => new { S = Agg.Sum(x.Props.Salary) }))
.Should().Contain(driven, "an aggregate reads its objects off the leaf as well");
(await Redb.Query().Where(e => e.Department == "Engineering").Take(10).ToSqlStringAsync())
.Should().NotContain(driven, "a text leaf has no index of values to drive from");
var range = await Aged().WhereRedb(o => o.Id > 0).Take(10).ToSqlStringAsync();
range.Should().NotContain(driven, "the objects drive under WhereRedb").And.NotContain("FORCE ORDER")
.And.NotContain("WITH (INDEX(", "a range of ids is wide by its shape, the leaf lifts the forced order");
(await Aged().WhereRedb(o => some.Contains(o.Id)).Take(10).ToSqlStringAsync())
.Should().Contain("FORCE ORDER", "an IN list of ids is narrow by its shape and keeps the forced order");
(await Redb.Query().Where(e => e.Department == "Engineering").WhereRedb(o => o.Id > 0).Take(10).ToSqlStringAsync())
.Should().Contain("FORCE ORDER", "a text leaf does not lift the forced order");
static string Ids(IEnumerable rows) => string.Join(",", rows.Select(r => r.Id));
static string Groups(IEnumerable rows) => string.Join(",", rows.Select(r => r!.ToString()).OrderBy(s => s, StringComparer.Ordinal));
async Task AnswersAsync() => string.Join("; ", new[]
{
$"count {await Aged().CountAsync()}",
$"any {await Aged().AnyAsync()}",
$"page {Ids(await Aged().Take(10).ToListAsync())}",
$"by salary {Ids(await Aged().OrderBy(e => e.Salary).ThenByRedb(o => o.Id).Take(5).ToListAsync())}",
$"absent {Ids(await Aged().Where(e => e.EmployeeCode == null).Take(10).ToListAsync())}",
$"group {Groups(await Aged().GroupBy(e => e.Department).SelectAsync(g => new { g.Key, C = Agg.Count(g) }))}",
$"sum {(await Aged().AggregateAsync(x => new { S = Agg.Sum(x.Props.Salary) })).S}",
$"range {await Aged().WhereRedb(o => o.Id > 0).CountAsync()}",
$"in list {await Aged().WhereRedb(o => some.Contains(o.Id)).CountAsync()}",
$"range group {Groups(await Aged().WhereRedb(o => o.Id > 0).GroupBy(e => e.Department).SelectAsync(g => new { g.Key, C = Agg.Count(g) }))}",
});
var on = await AnswersAsync();
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false);
var off = await AnswersAsync();
on.Should().Be(off, "driving off the leaf and lifting the forced order change the plan, not the answer");
on.Should().NotStartWith("count 0", "the seed has live employees of the victim's age");
(await Redb.Query().WhereRedb(o => o.Id == victim).CountAsync()).Should().Be(0, "the victim is in the trash");
}
finally
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
///
/// A page sorted by a Props field and then by others (ThenBy) is led by the first field as a batch:
/// the walk fills a table variable, the streams fill it when the walk did not. Without ThenBy the
/// streams stay, SQL Server walks the index on its own there. Compared by the sequence of all keys,
/// ThenBy Id included.
///
[Fact]
public async Task LeadingForm_ThenBy_SameKeysAsAggregateForm()
{
await TestDataFactory.SeedEmployees(Redb, 40);
var restore = Redb.Configuration.EnablePvtPrefilter;
try
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
IRedbQueryable Page(int skip) => Redb.Query()
.Where(e => e.Salary > 0m && e.Age >= 20)
.OrderByDescending(e => e.Salary).ThenBy(e => e.Age).ThenBy(e => e.LastName)
.Skip(skip).Take(10);
IRedbQueryable ById() => Redb.Query()
.Where(e => e.Age >= 20)
.OrderBy(e => e.Age).ThenByRedb(o => o.Id)
.Take(10);
var sql = await Page(0).ToSqlStringAsync();
sql.Should().Contain("-- PVT leading form:");
sql.Should().Contain("@pvt_bound", "with ThenBy the walk reads the run it stops in to the end");
var withoutThenBy = await Redb.Query()
.Where(e => e.Salary > 0m && e.Age >= 20)
.OrderByDescending(e => e.Salary).Take(10)
.ToSqlStringAsync();
withoutThenBy.Should().NotContain("-- PVT leading form:", "without ThenBy SQL Server walks the index itself");
foreach (var skip in new[] { 0, 5 })
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
var on = (await Page(skip).ToListAsync()).Select(r => (r.Props.Salary, r.Props.Age, r.Props.LastName)).ToList();
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false);
var off = (await Page(skip).ToListAsync()).Select(r => (r.Props.Salary, r.Props.Age, r.Props.LastName)).ToList();
on.Should().Equal(off, $"the leading form changes the plan, not the order (Skip {skip})");
}
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
(await ById().ToSqlStringAsync()).Should().Contain("-- PVT leading form:");
var onIds = (await ById().ToListAsync()).Select(r => r.Id).ToList();
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false);
var offIds = (await ById().ToListAsync()).Select(r => r.Id).ToList();
onIds.Should().Equal(offIds, "ThenBy Id orders the run of equal ages by id in both forms");
}
finally
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
///
/// With ThenBy the walk of the leading form reads on to the end of the run of equal sort values it
/// stops in. Take 10 walks 1 000 entries: 5 objects at the top value, then a run of 1 200 equal values
/// whose smallest titles sit past the first thousand entries. A run longer than twice the walk (2 100
/// objects) leaves the page to the streams. Both pages are compared with the prefilter off.
///
[Fact]
public async Task LeadingForm_ThenBy_RunOfEqualValuesAtTheBound()
{
const long top = 9_000_100, run = 9_000_090, longRun = 9_000_080;
var objects = new List>();
void Add(long value, int count)
{
// Titles fall as the objects are created, so the first titles of a run are its last entries.
for (var i = 0; i < count; i++)
objects.Add(new RedbObject
{
name = $"run-{value}-{i}",
Props = new SimpleProps { Title = $"t{value}-{count - i:D5}", OptionalNumber = value }
});
}
Add(top, 5);
Add(run, 1200);
Add(longRun, 2100);
await Redb.SaveAsync(objects);
var restore = Redb.Configuration.EnablePvtPrefilter;
try
{
IRedbQueryable Run() => Redb.Query()
.Where(p => p.OptionalNumber >= run)
.OrderByDescending(p => p.OptionalNumber).ThenBy(p => p.Title)
.Take(10);
IRedbQueryable LongRun() => Redb.Query()
.Where(p => p.OptionalNumber >= longRun)
.OrderBy(p => p.OptionalNumber).ThenBy(p => p.Title)
.Take(10);
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
(await Run().ToSqlStringAsync()).Should().Contain("-- PVT leading form:");
foreach (var (name, page) in new[] { ("run", (Func>)Run), ("long run", LongRun) })
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true);
var on = (await page().ToListAsync()).Select(r => (r.Props.OptionalNumber, r.Props.Title)).ToList();
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false);
var off = (await page().ToListAsync()).Select(r => (r.Props.OptionalNumber, r.Props.Title)).ToList();
on.Should().HaveCount(10);
on.Should().Equal(off, $"the leading form changes the plan, not the order ({name})");
}
}
finally
{
Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore);
}
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPvtPrefilterListItemTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPvtPrefilterListItemTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProPvtPrefilterListItemTests : PvtPrefilterListItemTestsBase
{
public MsSqlProPvtPrefilterListItemTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProQueryOrderTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProQueryOrderTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProQueryOrderTests : QueryOrderTestsBase
{
public MsSqlProQueryOrderTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProQueryPlannerBlockTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProQueryPlannerBlockTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProQueryPlannerBlockTests : QueryPlannerBlockTestsBase
{
public MsSqlProQueryPlannerBlockTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRareRangePagesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRareRangePagesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProRareRangePagesTests : RareRangePagesTestsBase
{
public MsSqlProRareRangePagesTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProReaderConnectionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProReaderConnectionTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProReaderConnectionTests : ReaderConnectionTestsBase
{
protected override string SlowScalarSql => "WAITFOR DELAY '00:00:02'; SELECT CAST(1 AS bigint)";
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRedundantArrayGuardTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRedundantArrayGuardTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProRedundantArrayGuardTests : RedundantArrayGuardTestsBase
{
public MsSqlProRedundantArrayGuardTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProReferenceListSaveTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProReferenceListSaveTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProReferenceListSaveTests : ReferenceListSaveTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRegexQueryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRegexQueryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProRegexQueryTests : RegexQueryTestsBase
{
public MsSqlProRegexQueryTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRowMapperKindsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRowMapperKindsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProRowMapperKindsTests : RowMapperKindsTestsBase
{
public MsSqlProRowMapperKindsTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override string KindsSql => @"SELECT CAST(1 AS bigint) AS _id, CAST(7 AS bigint) AS count, CAST(NULL AS bigint) AS maybe_long,
CAST(12.50 AS decimal(18,2)) AS amount, CAST(1.5 AS float) AS from_double, CAST(0.25 AS float) AS ratio, CAST(1 AS bit) AS flag,
CAST('6f1d0c3e-2b4a-4c8e-9a51-3d2f7e8b9c01' AS uniqueidentifier) AS key_value,
CAST('2026-01-02T03:04:05+00:00' AS datetimeoffset) AS when_at, CAST(NULL AS datetime2) AS day, 0x0102 AS bytes,
'abc' AS NAME, 'shown' AS display_name, CAST('2026-03-04T00:00:00' AS datetime2) AS first_seen, 'x' AS zzz";
protected override string EnumSql => "SELECT 2 AS kind";
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveGraphHashTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveGraphHashTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProSaveGraphHashTests : SaveGraphHashTestsBase
{
public MsSqlProSaveGraphHashTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveInterceptorTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveInterceptorTests.cs
----
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Models.Configuration;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProSaveInterceptorTests : SaveInterceptorTestsBase
{
protected override string ConnectionStringName => "MSSql";
protected override PropsSaveStrategy Strategy => PropsSaveStrategy.ChangeTracking;
protected override void AddRedbServices(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options, string connectionString)
=> options.UseMsSql(connectionString);
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveLockScopeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveLockScopeTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Pro.Extensions;
using redb.Core.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProSaveLockScopeTests : SaveLockScopeTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemaUpgradeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemaUpgradeTests.cs
----
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// MSSQL Pro never opted out of the module deployment the way the PostgreSQL and SQLite Pro
/// services did, so this suite starts green - it exists to keep it that way: the upgrade contract
/// belongs to every tier, and the two providers that skipped it left existing databases without the
/// V4 columns. Owns its own database and login.
///
public class MsSqlProSchemaUpgradeTests : redb.Tests.Integration.Tests.MsSql.MsSqlSchemaUpgradeTests
{
public MsSqlProSchemaUpgradeTests(SchemaUpgradeCleanup cleanup) : base(cleanup) { }
protected override string DatabaseName => $"redb_upgrade_pro_{RunSuffix}";
protected override string FreshDatabaseName => $"redb_upgrade_pro_fresh_{RunSuffix}";
protected override string RestrictedLogin => $"redb_noddl_pro_{RunSuffix}";
protected override string ContainedDatabaseName => $"redb_upgrade_pro_contained_{RunSuffix}";
protected override void AddRedbServices(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
// Resolves to the Pro overload through this file's using of redb.MSSql.Pro.Extensions.
protected override void UseProvider(RedbOptionsBuilder options, string connectionString)
=> options.UseMsSql(connectionString);
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeLoadValidationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeLoadValidationTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProSchemeLoadValidationTests : SchemeLoadValidationTestsBase
{
public MsSqlProSchemeLoadValidationTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeNamingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeNamingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProSchemeNamingTests : SchemeNamingTestsBase
{
public MsSqlProSchemeNamingTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeRenameTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeRenameTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProSchemeRenameTests : SchemeRenameTestsBase
{
public MsSqlProSchemeRenameTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSmallSaveTimingTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSmallSaveTimingTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
using Xunit.Abstractions;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProSmallSaveTimingTests : SmallSaveTimingTestsBase
{
public MsSqlProSmallSaveTimingTests(MsSqlProFixture fixture, ITestOutputHelper output) : base(fixture.ServiceProvider, output) { }
protected override string? PlanCacheReportSql => MsSql.MsSqlPlanCache.InsertReport;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProStringMatchContractTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProStringMatchContractTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProStringMatchContractTests : MsSqlStringMatchContractTestsBase
{
public MsSqlProStringMatchContractTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSubSecondUpdateTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSubSecondUpdateTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Models.Configuration;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProSubSecondUpdateTests : SubSecondUpdateTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override PropsSaveStrategy SaveStrategy => PropsSaveStrategy.ChangeTracking;
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSyncLoadTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSyncLoadTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProSyncLoadTests : ProSyncLoadTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTagsFieldTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTagsFieldTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTagsFieldTests : TagsFieldTestsBase
{
public MsSqlProTagsFieldTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTemporalRoundTripTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTemporalRoundTripTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTemporalRoundTripTests : TemporalRoundTripTestsBase
{
public MsSqlProTemporalRoundTripTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTimeTicksTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTimeTicksTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTimeTicksTests : TimeTicksTestsBase
{
public MsSqlProTimeTicksTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTrashPurgeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTrashPurgeTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTrashPurgeTests : TrashPurgeTestsBase
{
public MsSqlProTrashPurgeTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTrashedReferenceTargetTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTrashedReferenceTargetTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Core.Pro.Extensions;
using redb.MSSql.Pro.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
public class MsSqlProTrashedReferenceTargetTests : TrashedReferenceTargetTestsBase
{
protected override void Register(IServiceCollection services, Action configure)
=> services.AddRedbPro(configure);
protected override bool ProPropsCache => true;
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!;
options.UseMsSql(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeAggregateTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeAggregateTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTreeAggregateTests : TreeAggregateTestsBase
{
public MsSqlProTreeAggregateTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeDistinctTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeDistinctTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTreeDistinctTests : TreeDistinctTestsBase
{
public MsSqlProTreeDistinctTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeLevelAnalyticsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeLevelAnalyticsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTreeLevelAnalyticsTests : TreeLevelAnalyticsTestsBase
{
public MsSqlProTreeLevelAnalyticsTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeOrderAndPreviewTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeOrderAndPreviewTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTreeOrderAndPreviewTests : TreeOrderAndPreviewTestsBase
{
public MsSqlProTreeOrderAndPreviewTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeQueryShapesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeQueryShapesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTreeQueryShapesTests : TreeQueryShapesTestsBase
{
public MsSqlProTreeQueryShapesTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTreeTests : ProTreeTestsBase
{
public MsSqlProTreeTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTypeChangeTicksAndKeysTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTypeChangeTicksAndKeysTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProTypeChangeTicksAndKeysTests : TypeChangeTicksAndKeysTestsBase
{
public MsSqlProTypeChangeTicksAndKeysTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
protected override string TextType => "NVARCHAR(100)";
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUniqueKeyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUniqueKeyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProUniqueKeyTests : UniqueKeyTestsBase
{
public MsSqlProUniqueKeyTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override string BoolTrue => "1";
// ChangeTracking: see PostgresProUniqueKeyTests.
protected override bool KeySwapMustPass => false;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUnregisteredTreeTargetTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUnregisteredTreeTargetTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProUnregisteredTreeTargetTests : UnregisteredTreeTargetTestsBase
{
public MsSqlProUnregisteredTreeTargetTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUserConfigurationServiceTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUserConfigurationServiceTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProUserConfigurationServiceTests : UserConfigurationServiceTestsBase
{
public MsSqlProUserConfigurationServiceTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValueOnlyObjectSaveTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValueOnlyObjectSaveTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProValueOnlyObjectSaveTests : ValueOnlyObjectSaveTestsBase
{
public MsSqlProValueOnlyObjectSaveTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValueUniqueTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValueUniqueTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProValueUniqueTests : ValueUniqueTestsBase
{
public MsSqlProValueUniqueTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValuesFkIndexesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValuesFkIndexesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProValuesFkIndexesTests : ValuesFkIndexesTestsBase
{
public MsSqlProValuesFkIndexesTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
protected override async Task IndexExistsAsync(string indexName)
=> await Redb.Context.ExecuteScalarAsync(
"SELECT COUNT(*) FROM sys.indexes WHERE name = '{0}'".Replace("{0}", indexName)) > 0;
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWhereTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWhereTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProWhereTests : WhereTestsBase
{
public MsSqlProWhereTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWholeSchemeGroupingHintTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWholeSchemeGroupingHintTests.cs
----
using redb.Core;
using redb.Core.Models.Entities;
using redb.Core.Query.Aggregation;
using redb.Core.Query.Window;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Helpers;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSqlPro;
///
/// A GroupBy over the whole scheme on the streams source (planner on) closes with hash joins: with two or more fields
/// the optimizer otherwise joined their value rows many-to-many through worktables (E130a). Any condition, the aggregate
/// pivot of the planner-off pass, a window over the groups and a tree keep the statement as it was.
///
[Collection("MsSqlPro")]
public class MsSqlProWholeSchemeGroupingHintTests
{
private const string Hint = "OPTION (HASH JOIN, MAXDOP 1)";
private readonly IRedbService _redb;
public MsSqlProWholeSchemeGroupingHintTests(MsSqlProFixture fixture) => _redb = fixture.Redb;
[Fact]
public async Task WholeSchemeGrouping_TakesTheHashJoinHint_OnlyOnTheStreamsSource()
{
await _redb.SyncSchemeAsync();
var sql = await _redb.Query()
.GroupBy(e => new { e.Department, e.Position })
.ToSqlStringAsync(g => new { g.Key.Department, g.Key.Position, Total = Agg.Sum(g, e => e.Salary), Count = Agg.Count(g) });
if (ProTestOptions.PvtPrefilter)
sql.TrimEnd().Should().EndWith(Hint);
else
sql.Should().NotContain("HASH JOIN", "the aggregate pivot lost with hash joins (1.7 s -> 6.3 s)");
}
[Fact]
public async Task WholeSchemeGroupingWithHaving_TakesTheHint_OnlyOnTheStreamsSource()
{
await _redb.SyncSchemeAsync();
var sql = await _redb.Query()
.GroupBy(e => e.Department)
.Having(g => Agg.Count(g) > 5)
.ToSqlStringAsync(g => new { Department = g.Key, Count = Agg.Count(g) });
if (ProTestOptions.PvtPrefilter)
sql.TrimEnd().Should().EndWith(Hint);
else
sql.Should().NotContain("HASH JOIN");
}
[Fact]
public async Task GroupingWithAWhere_KeepsItsStatement()
{
await _redb.SyncSchemeAsync();
var sql = await _redb.Query()
.Where(e => e.Salary > 60000m)
.GroupBy(e => new { e.Department, e.Position })
.ToSqlStringAsync(g => new { g.Key.Department, g.Key.Position, Count = Agg.Count(g) });
sql.Should().NotContain("HASH JOIN");
}
[Fact]
public async Task GroupingWithABaseFieldCondition_KeepsItsStatement()
{
await _redb.SyncSchemeAsync();
var sql = await _redb.Query()
.WhereRedb(o => o.Id > 0)
.GroupBy(e => new { e.Department, e.Position })
.ToSqlStringAsync(g => new { g.Key.Department, g.Key.Position, Count = Agg.Count(g) });
sql.Should().NotContain("HASH JOIN");
}
[Fact]
public async Task WindowOverTheGroups_KeepsItsStatement()
{
await _redb.SyncSchemeAsync();
var sql = await _redb.Query()
.GroupBy(e => e.Department)
.WithWindow(w => w.OrderByDesc(g => Agg.Sum(g, e => e.Salary)))
.ToSqlStringAsync(g => new { Department = g.Key, Total = Agg.Sum(g, e => e.Salary), Rank = Win.Rank() });
sql.Should().NotContain("HASH JOIN");
}
[Fact]
public async Task TreeGrouping_KeepsItsStatement()
{
await _redb.SyncSchemeAsync();
var root = new TreeRedbObject
{
name = "grp-hint-root-" + Guid.NewGuid().ToString("N")[..8],
Props = TestDataFactory.CreateEmployee(0).Props
};
root.id = await _redb.SaveAsync(root);
var sql = await _redb.TreeQuery(root.id)
.GroupBy(e => new { e.Department, e.Position })
.ToSqlStringAsync(g => new { g.Key.Department, g.Key.Position, Count = Agg.Count(g) });
sql.Should().NotContain("HASH JOIN");
}
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWideEqualityLeadsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWideEqualityLeadsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProWideEqualityLeadsTests : WideEqualityLeadsTestsBase
{
public MsSqlProWideEqualityLeadsTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWindowTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWindowTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.MsSqlPro;
[Collection("MsSqlPro")]
public class MsSqlProWindowTests : ProWindowTestsBase
{
public MsSqlProWindowTests(MsSqlProFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAbsentValuesTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresAbsentValuesTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresAbsentValuesTests : AbsentValuesTestsBase
{
public PostgresAbsentValuesTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregatePathTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregatePathTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresAggregatePathTests : AggregatePathTestsBase
{
public PostgresAggregatePathTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregatePreviewTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregatePreviewTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresAggregatePreviewTests : FreeAggregatePreviewTestsBase
{
public PostgresAggregatePreviewTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregationOverArrayTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregationOverArrayTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresAggregationOverArrayTests : AggregationOverArrayTestsBase
{
public PostgresAggregationOverArrayTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregationTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresAggregationTests : AggregationTestsBase
{
public PostgresAggregationTests(PostgresFixture fixture) : base(fixture.Redb, isPro: false) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAmbientTransactionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresAmbientTransactionTests.cs
----
using redb.Core.Data;
using redb.Postgres.Data;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresAmbientTransactionTests : AmbientTransactionTestsBase
{
public PostgresAmbientTransactionTests(PostgresFixture fixture) : base(fixture.ServiceProvider) { }
protected override string CreateProbeTableSql =>
"CREATE TABLE IF NOT EXISTS ambient_tx_rows (tag varchar(100) NOT NULL)";
protected override string SlowStatementSql => "SELECT 1 FROM pg_sleep(2)";
protected override IRedbConnection CreateStandaloneConnection(IServiceProvider services, bool differentSessionSettings)
=> new NpgsqlRedbConnection(NpgsqlDataSourceFactory.Create(
ConnString("Postgres"), stringCollation: null, lazyReferences: differentSessionSettings));
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAnalyticsTelemetryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresAnalyticsTelemetryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresAnalyticsTelemetryTests : AnalyticsTelemetryTestsBase
{
public PostgresAnalyticsTelemetryTests(PostgresFixture fixture) : base(fixture.Redb) { }
protected override int CommandsPerCall => 2;
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAnyExistsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresAnyExistsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresAnyExistsTests : FreeAnyExistsTestsBase
{
public PostgresAnyExistsTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayAnyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayAnyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresArrayAnyTests : ArrayAnyTestsBase
{
public PostgresArrayAnyTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayGroupByDeepTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayGroupByDeepTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresArrayGroupByDeepTests : ArrayGroupByDeepTestsBase
{
public PostgresArrayGroupByDeepTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayGroupModuleGuardTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayGroupModuleGuardTests.cs
----
using redb.Core;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.Postgres;
///
/// A14: the free module's array grouping refuses, with a reason, what it cannot answer instead of reading it as a
/// field with no rows: an unknown '$' token, '$element' on an array of classes, a field of an array of simple values,
/// a field the elements do not have, a dictionary in the array path. The core refuses these forms before they reach
/// SQL, so the function is called directly - the SQL is the public surface for callers that submit the JSON themselves.
///
[Collection("Postgres")]
public class PostgresArrayGroupModuleGuardTests
{
private readonly IRedbService _redb;
public PostgresArrayGroupModuleGuardTests(PostgresFixture fixture) => _redb = fixture.Redb;
private async Task BuildAsync(string arrayPath, string groupByJson)
{
var scheme = await _redb.SyncSchemeAsync();
return await _redb.Context.ExecuteScalarAsync(
"SELECT pvt_build_array_groupby_sql(" + scheme.Id + ", $1::text, NULL::jsonb, $2::jsonb, NULL::jsonb)",
new object[] { arrayPath, groupByJson });
}
[Theory]
[InlineData("Contacts", "[{\"field\":\"$foo\",\"alias\":\"x\"}]", "*\"$foo\" is not a field of the elements of \"Contacts\"*")]
[InlineData("Contacts", "[{\"field\":\"$element\",\"alias\":\"x\"}]", "*\"$element\" names the element itself*")]
[InlineData("Skills", "[{\"field\":\"Name\",\"alias\":\"x\"}]", "*simple values and have no field \"Name\"*")]
[InlineData("Contacts.Metadata", "[{\"field\":\"Type\",\"alias\":\"x\"}]", "*\"Type\" is not a field of the elements of \"Contacts.Metadata\"*")]
[InlineData("PhoneDirectory", "[{\"field\":\"$element\",\"alias\":\"x\"}]", "*dictionary*")]
[InlineData("HomeAddress", "[{\"field\":\"City\",\"alias\":\"x\"}]", "*\"HomeAddress\" is not an array*")]
public async Task WhatItCannotAnswer_IsRefusedWithAReason(string arrayPath, string groupByJson, string message)
{
var act = async () => await BuildAsync(arrayPath, groupByJson);
(await act.Should().ThrowAsync()).Which.Message.Should().Match(message);
}
[Fact]
public async Task AnInnerArrayAndTheElementOfASimpleArray_AreBuilt()
{
(await BuildAsync("Contacts.Metadata", "[{\"field\":\"Label\",\"alias\":\"Label\"}]")).Should().Contain("GROUP BY");
(await BuildAsync("Skills", "[{\"field\":\"$element\",\"alias\":\"Skill\"}]")).Should().Contain("GROUP BY");
}
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayOfClassesAnyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayOfClassesAnyTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresArrayOfClassesAnyTests : ArrayOfClassesAnyTestsBase
{
public PostgresArrayOfClassesAnyTests(PostgresFixture fixture) : base(fixture.Redb) { }
protected override bool ReadsAnyOverClasses => false;
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresArrayTests : ArrayTestsBase
{
public PostgresArrayTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresBareRedbObjectFieldTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresBareRedbObjectFieldTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresBareRedbObjectFieldTests : BareRedbObjectFieldTestsBase
{
public PostgresBareRedbObjectFieldTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresBaseFieldNameCollisionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresBaseFieldNameCollisionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresBaseFieldNameCollisionTests : BaseFieldNameCollisionTestsBase
{
public PostgresBaseFieldNameCollisionTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresBugRegressionTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresBugRegressionTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresBugRegressionTests : BugRegressionTestsBase
{
public PostgresBugRegressionTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresBytesRoundTripTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresBytesRoundTripTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresBytesRoundTripTests : BytesRoundTripTestsBase
{
public PostgresBytesRoundTripTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCacheBehaviorTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresCacheBehaviorTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresCacheBehaviorTests : CacheBehaviorTestsBase
{
public PostgresCacheBehaviorTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCancellationTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresCancellationTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresCancellationTests : CancellationTestsBase
{
public PostgresCancellationTests(PostgresFixture fixture) : base(fixture.Redb) { }
protected override string? SleepSql => "SELECT pg_sleep(30)";
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresColdSchemeLinkedObjectTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresColdSchemeLinkedObjectTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.Postgres.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
public class PostgresColdSchemeLinkedObjectTests : ColdSchemeLinkedObjectTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!;
options.UsePostgres(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresColdSchemeTreeFilterTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresColdSchemeTreeFilterTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.Postgres.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
public class PostgresColdSchemeTreeFilterTests : ColdSchemeTreeFilterTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!;
options.UsePostgres(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCollectionFilterAnalyticsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresCollectionFilterAnalyticsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresCollectionFilterAnalyticsTests : CollectionFilterAnalyticsTestsBase
{
public PostgresCollectionFilterAnalyticsTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresComputedComparisonTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresComputedComparisonTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresComputedComparisonTests : ComputedComparisonTestsBase
{
public PostgresComputedComparisonTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrencyStressTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrencyStressTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresConcurrencyStressTests : ConcurrencyStressTestsBase
{
public PostgresConcurrencyStressTests(PostgresFixture fixture)
: base(fixture.Redb, fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentDeleteCountTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentDeleteCountTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresConcurrentDeleteCountTests : ConcurrentDeleteCountTestsBase
{
public PostgresConcurrentDeleteCountTests(PostgresFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { }
protected override async Task HoldRowAsync(long objectId) => await RowHolders.PostgresAsync(objectId);
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentDeleteListTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentDeleteListTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.Postgres.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
public class PostgresConcurrentDeleteListTests : ConcurrentDeleteListTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!;
options.UsePostgres(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentWritersTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentWritersTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresConcurrentWritersTests : ConcurrentWritersTestsBase
{
public PostgresConcurrentWritersTests(PostgresFixture fixture) : base(fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConnectionTeardownTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresConnectionTeardownTests.cs
----
using System.Globalization;
using redb.Core.Data;
using redb.Postgres.Data;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresConnectionTeardownTests : ConnectionTeardownTestsBase
{
protected override IRedbConnection CreateConnection()
=> new NpgsqlRedbConnection(ConnString("Postgres"));
protected override string SleepSql(double seconds)
=> $"SELECT COUNT(*) FROM pg_sleep({seconds.ToString(CultureInfo.InvariantCulture)})";
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConstantPredicateTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresConstantPredicateTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresConstantPredicateTests : ConstantPredicateTestsBase
{
public PostgresConstantPredicateTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCrudTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresCrudTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresCrudTests : CrudTestsBase
{
public PostgresCrudTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCtSaveInvariantsTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresCtSaveInvariantsTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresCtSaveInvariantsTests : CtSaveInvariantsTestsBase
{
public PostgresCtSaveInvariantsTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDbInfoTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresDbInfoTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Extensions;
using redb.Postgres.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
public class PostgresDbInfoTests : DbInfoTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!;
options.UsePostgres(cs);
}
protected override string VersionMarker => "PostgreSQL";
protected override string SizeInBytesSql => "SELECT pg_database_size(current_database())";
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDecimalRoundTripTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresDecimalRoundTripTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresDecimalRoundTripTests : DecimalRoundTripTestsBase
{
public PostgresDecimalRoundTripTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDeleteBatchCountTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresDeleteBatchCountTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresDeleteBatchCountTests : DeleteBatchCountTestsBase
{
public PostgresDeleteBatchCountTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDeleteSubtreeCountTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresDeleteSubtreeCountTests.cs
----
using Microsoft.Extensions.Configuration;
using redb.Core.Extensions;
using redb.Postgres.Extensions;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
public class PostgresDeleteSubtreeCountTests : DeleteSubtreeCountTestsBase
{
protected override void UseProvider(RedbOptionsBuilder options)
{
var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!;
options.UsePostgres(cs);
}
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDictionaryOrderTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresDictionaryOrderTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresDictionaryOrderTests : DictionaryOrderTestsBase
{
public PostgresDictionaryOrderTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDictionaryTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresDictionaryTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresDictionaryTests : DictionaryTestsBase
{
public PostgresDictionaryTests(PostgresFixture fixture) : base(fixture.Redb) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDisposedScopeGuardTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresDisposedScopeGuardTests.cs
----
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.Postgres;
[Collection("Postgres")]
public class PostgresDisposedScopeGuardTests : DisposedScopeGuardTestsBase
{
public PostgresDisposedScopeGuardTests(PostgresFixture fixture) : base(fixture.ServiceProvider) { }
}
Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresExportForeignKeyTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Postgres/PostgresExportForeignKeyTests.cs
----
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Npgsql;
using redb.Core;
using redb.Core.Extensions;
using redb.Core.Models.Entities;
using redb.Export.Providers;
using redb.Export.Services;
using redb.Postgres.Extensions;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.Postgres;
///
/// redb.Export loads PostgreSQL with the foreign key triggers off, because the file order needs it: roles point at
/// objects that come later, children may come before their parents. Switching the triggers back on checks nothing,
/// so a file with a reference to a row it does not hold loaded silently, while SQL Server refused the same file.
/// The import now checks every key of the redb tables at the end and refuses such a file by name. Each test runs on
/// scratch databases of its own, dropped afterwards.
///
public class PostgresExportForeignKeyTests : IAsyncLifetime
{
private const long Missing = 999_999_999;
private string _server = null!;
private readonly List _databases = [];
private readonly List _files = [];
public Task InitializeAsync()
{
var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
_server = config.GetConnectionString("Postgres")!;
return Task.CompletedTask;
}
public async Task DisposeAsync()
{
NpgsqlConnection.ClearAllPools();
foreach (var database in _databases)
await ExecuteAsync(Maintenance(), $"DROP DATABASE IF EXISTS \"{database}\" WITH (FORCE)");
foreach (var file in _files)
File.Delete(file);
}
[Fact]
public async Task ASerialImport_OfAFileWithAMissingParent_IsRefusedByKeyName_AndChangesNothing()
{
var (file, childId) = await ExportWithMissingParentAsync();
var target = await NewTargetWithOneObjectAsync();
var key = await ParentKeyNameAsync(target);
var before = await ScalarAsync(target, "SELECT count(*) FROM _objects");
var importing = async () => await ImportAsync(target, file, parallelism: 1);
var refusal = await importing.Should().ThrowAsync();
refusal.Which.Message.Should()
.Contain($"{key}: 1 row(s) of _objects point at a missing row of _objects (_id)")
.And.Contain($"_id = {childId}, _id_parent = {Missing}")
.And.Contain("Nothing was imported; the database is unchanged.");
(await ScalarAsync(target, "SELECT count(*) FROM _objects")).Should().Be(before,
"the refusal rolls back the whole import, the cleaning included");
(await ScalarAsync(target, "SELECT count(*) FROM _objects WHERE _name = 'already-here'")).Should().Be(1);
}
[Fact]
public async Task AParallelImport_OfAFileWithAMissingParent_IsRefusedByKeyName_AndSaysTheRowsAreWritten()
{
var (file, childId) = await ExportWithMissingParentAsync();
var target = await NewTargetWithOneObjectAsync();
var key = await ParentKeyNameAsync(target);
var importing = async () => await ImportAsync(target, file, parallelism: 2);
var refusal = await importing.Should().ThrowAsync();
refusal.Which.Message.Should()
.Contain($"{key}: 1 row(s) of _objects point at a missing row of _objects (_id)")
.And.Contain($"_id = {childId}, _id_parent = {Missing}")
.And.Contain("The parallel import has already written its rows");
(await ScalarAsync(target, "SELECT count(*) FROM pg_indexes WHERE tablename IN ('_objects', '_values')"))
.Should().BeGreaterThan(0, "the indexes are rebuilt before the check, so a refused parallel import leaves them in place");
}
[Fact]
public async Task AFileExportedWithSchemes_WhoseObjectPointsIntoASchemeLeftOut_IsRefused_NamingTheReference()
{
var source = await NewDatabaseAsync("src");
long parentId, childId;
await using (var provider = Build(source))
{
var redb = provider.GetRequiredService();
await redb.InitializeAsync(ensureCreated: true);
await redb.SyncSchemeAsync();
await redb.SyncSchemeAsync();
parentId = await redb.SaveAsync(new RedbObject { name = "parent-left-out", Props = new CityProps { Name = "c" } });
childId = await redb.SaveAsync(new RedbObject { name = "child-exported", parent_id = parentId, Props = new SimpleProps { Title = "t" } });
}
var simpleScheme = await ScalarAsync(source, "SELECT min(_id) FROM _schemes WHERE _name LIKE '%SimpleProps%'");
var file = await ExportAsync(source, [simpleScheme]);
var target = await NewTargetWithOneObjectAsync();
var key = await ParentKeyNameAsync(target);
var importing = async () => await ImportAsync(target, file, parallelism: 1);
var refusal = await importing.Should().ThrowAsync();
refusal.Which.Message.Should()
.Contain("--schemes")
.And.Contain($"{key}: 1 row(s) of _objects point at a missing row of _objects (_id)")
.And.Contain($"_id = {childId}, _id_parent = {parentId}");
}
[Theory]
[InlineData(1)]
[InlineData(2)]
public async Task AWholeFile_WithChildrenBeforeTheirParents_StillImports(int parallelism)
{
var source = await NewDatabaseAsync("src");
long childId, parentId;
await using (var provider = Build(source))
{
var redb = provider.GetRequiredService();
await redb.InitializeAsync(ensureCreated: true);
await redb.SyncSchemeAsync();
// The child gets the lower id, so the export writes it before its parent, possibly in another batch.
var child = new RedbObject { name = "child", Props = new SimpleProps { Title = "c" } };
childId = await redb.SaveAsync(child);
parentId = await redb.SaveAsync(new RedbObject { name = "parent", Props = new SimpleProps { Title = "p" } });
}
await ExecuteAsync(source, $"UPDATE _objects SET _id_parent = {parentId} WHERE _id = {childId}");
var file = await ExportAsync(source, null);
var target = await NewTargetWithOneObjectAsync();
await ImportAsync(target, file, parallelism);
(await ScalarAsync(target, $"SELECT _id_parent FROM _objects WHERE _id = {childId}")).Should().Be(parentId,
"a reference the file holds both ends of passes the check, whatever the order of the rows");
}
/// Exports a database whose one object points at a parent that is not there.
private async Task<(string File, long ChildId)> ExportWithMissingParentAsync()
{
var source = await NewDatabaseAsync("src");
long childId;
await using (var provider = Build(source))
{
var redb = provider.GetRequiredService();
await redb.InitializeAsync(ensureCreated: true);
await redb.SyncSchemeAsync