Path: redb-route/tests/redb.Route.Tests.Core/Integration/RedbQueryBaseFieldsIntegrationTests.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Core/Integration/RedbQueryBaseFieldsIntegrationTests.cs
----
using redb.Core;
using redb.Core.Attributes;
using redb.Core.Models.Entities;
using redb.Route.Abstractions;
using redb.Route.Core;
using redb.Route.RedbCore.Extensions;
namespace redb.Route.Tests.Core.Integration;
/// A props type for the query probes: a run tag and a rank.
[RedbScheme("Route Query Probe")]
public sealed class QueryProbeProps
{
public string? Tag { get; set; }
public int Rank { get; set; }
}
///
/// RedbQuery(whereRedb:, orderByRedb:) against a real database: the base-field condition
/// reaches the provider's SQL and filters there, combined with a props condition. Subclassed per
/// provider. Every object carries this instance's tag and hangs under its own parent, so
/// parallel runs over the shared test database never see each other's rows.
///
public abstract class RedbQueryBaseFieldsIntegrationTests : IAsyncLifetime
{
private readonly IRedbService _redb;
private readonly string _tag = Guid.NewGuid().ToString("N");
private readonly Guid _key = Guid.NewGuid();
private readonly List _created = [];
private long _parent;
private long _first;
private long _second;
protected RedbQueryBaseFieldsIntegrationTests(IRedbService redb) => _redb = redb;
public async Task InitializeAsync()
{
await _redb.SyncSchemeAsync();
_parent = await Save(new RedbObject(new QueryProbeProps { Tag = _tag, Rank = 0 }));
_first = await Save(new RedbObject(new QueryProbeProps { Tag = _tag, Rank = 1 })
{ ParentId = _parent, ValueGuid = _key, ValueString = "A-" + _tag });
_second = await Save(new RedbObject(new QueryProbeProps { Tag = _tag, Rank = 2 })
{ ParentId = _parent, ValueGuid = Guid.NewGuid(), ValueString = "B-" + _tag });
}
public async Task DisposeAsync()
{
// Children first, then the parent.
foreach (var id in Enumerable.Reverse(_created))
await _redb.DeleteAsync(id);
}
private async Task Save(RedbObject entity)
{
var id = await _redb.SaveAsync(entity);
_created.Add(id);
return id;
}
private async Task>> Run(Action query,
params (string Key, object? Value)[] headers)
=> (await RunRaw(query, headers)).Should().BeOfType>>().Subject;
private async Task