From f3b62a7ee7114d3da2bb52ebd557a7bec08afb2b Mon Sep 17 00:00:00 2001 From: Libby Date: Thu, 12 Nov 2026 01:21:51 +0000 Subject: [PATCH] SlotReadOnlyTests: restore the Explained assertion lost with a debug line; an unheld key a store lists foreign is not writable The assertion went out with 0dfc437b. The new test kills mutant M13 (the unheld branch answering true), which survived without it. Co-Authored-By: Claude Opus 5.5 --- .../GameCult.Caching.Tests/SlotReadOnlyTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/GameCult.Caching.Tests/SlotReadOnlyTests.cs b/tests/GameCult.Caching.Tests/SlotReadOnlyTests.cs index 3f3bcd15..3d0e650d 100644 --- a/tests/GameCult.Caching.Tests/SlotReadOnlyTests.cs +++ b/tests/GameCult.Caching.Tests/SlotReadOnlyTests.cs @@ -313,6 +313,7 @@ namespace GameCult.Caching.Tests reader.AddBackingStore(Store()); var unread = Stored(reader, Marked).UnreadSlots; Assert.That(unread, Is.Not.Null, "the store kind decodes through the marking path"); + Assert.That(unread!.Explained, Is.True, "depth 0 and reported by the catalog comparison"); Assert.That(unread.TypeName, Is.EqualTo(nameof(NarrowDoc))); Assert.That(unread.SlotCount, Is.EqualTo(3)); Assert.That(unread.DeclaredCount, Is.EqualTo(2)); @@ -580,6 +581,21 @@ namespace GameCult.Caching.Tests Assert.That(refusal.Message, Does.Contain("read-only backing store")); } + // A key the cache does not hold, but a store carries as a foreign record: the store's removal check refuses it. + [Test] + public void IsWritableIsFalseForAnUnheldKeyAStoreListsForeign() + { + var path = Path.Combine(_directory, "foreign.cc"); + using (var writer = Open(path, GapRegistry)) + Assert.That(writer.Commit(batch => batch.Upsert(new GapDoc { Name = "g" }, new CultRecordHandle(Marked))), Is.True); + + using var cache = Open(path, SurfaceRegistry); + Assert.That(cache.GetStored(Marked), Is.Null, "the cache does not hold a record no registered type reads"); + Assert.That(cache.IsWritable(Marked), Is.False); + AssertWriteAgrees(cache, Marked, () => cache.Commit(batch => batch.Remove(Marked))); + Assert.That(cache.IsWritable(Unheld), Is.True); + } + [Test] public void IsWritableIsFalseForARecordNoAttachedStoreIsHomeTo() {