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 <noreply@anthropic.com>
This commit is contained in:
Libby 2026-11-12 01:21:51 +00:00
commit f3b62a7ee7

View file

@ -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<GapDoc>(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()
{