C2a test: a preset id and a loaded record holding one mark the store

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-29 19:59:52 +02:00
commit dfde61aba3

View file

@ -691,6 +691,24 @@ namespace GameCult.Caching.Tests
Assert.That(HeaderOf(marked), Is.EqualTo("cultcache.store.v3"), "a file already marked on disk stays marked");
}
[Test]
public void AnIdAlreadyThereMarksTheStoreAndSoDoesARecordLoadedHoldingOne()
{
var preset = PathOf("preset.cc");
using (var cache = Open(preset))
cache.Commit(batch => batch.Upsert(typeof(IdDeck), new IdDeck { Name = "p", Reels = { new IdReel { Id = HexA } } }, new CultRecordKey("p")));
Assert.That(HeaderOf(preset), Is.EqualTo("cultcache.store.v3"), "the deck minted nothing, and still holds an id");
// The deck reloads holding ids it did not mint; a whole-store flush of a store now holding only that deck and an empty one.
using (var cache = Open(preset))
{
cache.UpsertAsync(typeof(IdDeck), EmptyDeck("e"), new CultRecordKey("e")).GetAwaiter().GetResult();
cache.FlushAllBackingStores();
}
Assert.That(HeaderOf(preset), Is.EqualTo("cultcache.store.v3"), "a loaded record's ids count");
}
[Test]
public void ADirectoryStoreIsMarkedByTheIdsItWritesAndAnEmptyDeckDoesNotMarkIt()
{