Path: redb/redb.Tests.Integration/Tests/Base/ValueOnlyObjectSaveTestsBase.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. 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/ValueOnlyObjectSaveTestsBase.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Base; /// /// An object without Props - a scheme with no properties, or an object saved with Props = null - is a loaded /// object like any other: it lives in its base fields (Identity report REPORT-CORE-UNLOADED-REFERENCE-PROPSLESS-SCHEME, /// 2026-09-17). Hydration never called the Props setter for it, so the "loaded" flag stayed down and the save's /// refusal of unloaded references (fbf4e9f1) took every such object for a reference. What redb materializes as a /// root is loaded by definition; a reference is a stub redb attached a lazy loader to. /// public abstract class ValueOnlyObjectSaveTestsBase { protected readonly IRedbService Redb; protected ValueOnlyObjectSaveTestsBase(IRedbService redb) => Redb = redb; private static string NewTag() => Guid.NewGuid().ToString("N")[..8]; [Fact] public async Task AnObjectOfASchemeWithoutProperties_LoadsAsLoaded_AndSavesAgain() { await Redb.SyncSchemeAsync(); var tag = NewTag(); var id = await Redb.SaveAsync(new RedbObject { name = $"flag-{tag}", Props = new ValueOnlyProps() }); var loaded = (await Redb.LoadAsync(id))!; loaded.IsPropsLoaded.Should().BeTrue("what redb materialized as a root is loaded, Props or no Props"); loaded.name = $"flag-{tag}-renamed"; await Redb.SaveAsync(loaded); (await Redb.LoadAsync(id))!.name.Should().Be($"flag-{tag}-renamed"); } [Fact] public async Task AnObjectOfASchemeWithoutProperties_FromAQuery_SavesAgain() { await Redb.SyncSchemeAsync(); var tag = NewTag(); var id = await Redb.SaveAsync(new RedbObject { name = $"queried-{tag}", Props = new ValueOnlyProps() }); var queried = (await Redb.Query().ToListAsync()).Single(o => o.id == id); queried.IsPropsLoaded.Should().BeTrue(); queried.name = $"queried-{tag}-renamed"; await Redb.SaveAsync(queried); (await Redb.LoadAsync(id))!.name.Should().Be($"queried-{tag}-renamed"); } [Fact] public async Task AnObjectSavedWithNullProps_LoadsAsLoaded_AndSavesAgain() { await Redb.SyncSchemeAsync(); var tag = NewTag(); var id = await Redb.SaveAsync(new RedbObject { name = $"nullprops-{tag}", Props = null! }); var loaded = (await Redb.LoadAsync(id))!; loaded.IsPropsLoaded.Should().BeTrue("Props may be null on a loaded object"); loaded.name = $"nullprops-{tag}-renamed"; await Redb.SaveAsync(loaded); (await Redb.LoadAsync(id))!.name.Should().Be($"nullprops-{tag}-renamed"); } }