Path: redb/redb.Tests.Integration/Tests/Base/ComputedComparisonTestsBase.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Base/ComputedComparisonTestsBase.cs
----
using System.Linq.Expressions;
using redb.Core;
using redb.Core.Models.Entities;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.Base;
///
/// A comparison of a field with a computed value answers as LINQ over the same objects does: a value of the caller built
/// from several parts (tag + "-x", a + 1, x ?? "d", a ternary), a field against an expression over fields (A == B + 1),
/// a field against a field (A > B), on either side of the operator. Each of these failed before with "variable 'p' ...
/// is not defined": the side without arithmetic was evaluated as a constant, the field side included.
///
/// Each case runs on four objects of its own and is checked against the same predicate compiled and run in memory.
///
public abstract class ComputedComparisonTestsBase
{
protected readonly IRedbService Redb;
protected ComputedComparisonTestsBase(IRedbService redb) => Redb = redb;
private static List Seeds(string tag) =>
[
new() { Tag = tag, First = "Ann", Last = "Lee", Full = "Ann Lee", A = 3, B = 2, Price = 10.5m, Limit = 21m },
new() { Tag = tag, First = "Bob", Last = "Ray", Full = "Bob X", A = 5, B = 5, Price = 7m, Limit = 7m },
new() { Tag = tag, First = "Cid", Last = "Moe", Full = tag + "-x", A = 1, B = 4, Price = 2.25m, Limit = 3m },
new() { Tag = tag, First = "Dee", Last = "Ito", Full = "Dee-y", A = 9, B = 4, Price = 40m, Limit = 80m },
];
public static IEnumerable