Caching tests: the open verdict is asserted where the store is attached

AddBackingStore pulls, so a file the reader refuses throws on attach, outside
the assertion. Wrap attach and pull together.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 02:11:40 +02:00
commit 4b3c76e418

View file

@ -66,11 +66,16 @@ namespace GameCult.Caching.Tests
File.WriteAllBytes(path, File.ReadAllBytes(Path.Combine(VectorRoot(), vector)));
using var cache = new CultCache();
cache.AddBackingStore(new SingleFileMessagePackBackingStore(path));
void Open()
{
cache.AddBackingStore(new SingleFileMessagePackBackingStore(path));
cache.PullAllBackingStoresAsync().GetAwaiter().GetResult();
}
if (reads)
Assert.DoesNotThrow(() => cache.PullAllBackingStoresAsync().GetAwaiter().GetResult());
Assert.DoesNotThrow(Open);
else
Assert.That(() => cache.PullAllBackingStoresAsync().GetAwaiter().GetResult(), Throws.Exception);
Assert.That(Open, Throws.Exception);
}
[TestCaseSource(nameof(Vectors))]