From 338035eacb5f329d9072af2b3ef7eb2b8326f7c1 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 27 Oct 2026 07:46:17 +0100 Subject: [PATCH] Tests: a record under an id its entry only lists is published by that entry Kills the Stryker survivor FirstOrDefault to First in PublishedBy. Co-Authored-By: Claude Sonnet 5.5 --- .../RestampOnWriteTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/GameCult.Caching.Tests/RestampOnWriteTests.cs b/tests/GameCult.Caching.Tests/RestampOnWriteTests.cs index e7ce437a..1a24fd0c 100644 --- a/tests/GameCult.Caching.Tests/RestampOnWriteTests.cs +++ b/tests/GameCult.Caching.Tests/RestampOnWriteTests.cs @@ -493,6 +493,24 @@ namespace GameCult.Caching.Tests Assert.That(Snapshot(path).Records.Single(record => record.Key == "note").SchemaId, Is.EqualTo(NarrowRegistry.GetRequired().SchemaId)); } + // A record stored under an id its catalog entry only lists (no entry owns it) is published by that entry, and the type that + // reads the entry whole owns the record: a cache and a cacheless writer alike restamp it. + [TestCase(false)] + [TestCase(true)] + public void ARecordUnderAnIdOnlyListedIsPublishedByTheEntryListingIt(bool cacheless) + { + const string listedOnly = "tests.restamp.listedonly"; + var path = SeedRenamed(listsNarrow: true, alsoLists: listedOnly); + var snapshot = Snapshot(path); + foreach (var record in snapshot.Records) + record.SchemaId = listedOnly; + File.WriteAllBytes(path, CultDocumentMessagePackSerialization.SerializeSnapshot(snapshot)); + + WriteNarrow(path, cacheless); + + Assert.That(Snapshot(path).Records.Single(record => record.Key == "note").SchemaId, Is.EqualTo(NarrowRegistry.GetRequired().SchemaId)); + } + // A raw record write names no registry, so its one entry is the claimant: it reads a renamed entry that lists its id, or has // its schema name, and nothing else. [TestCase(true, "tests.restamp_note_renamed", true)]