Index CultCache records by document type
This commit is contained in:
parent
ba680020b9
commit
be846415d4
2 changed files with 58 additions and 3 deletions
|
|
@ -806,6 +806,37 @@ namespace GameCult.Caching.Tests
|
|||
Assert.That(cache.Remove(key), Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CultCache_TypedStoredDocumentIndex_Tracks_Upsert_Replacement_And_Removal()
|
||||
{
|
||||
var cache = new CultCache();
|
||||
var key = new CultRecordKey("typed-index:named");
|
||||
await cache.UpsertAsync(typeof(NamedTestEntry), new NamedTestEntry
|
||||
{
|
||||
Name = "indexed",
|
||||
Value = "first"
|
||||
}, key);
|
||||
await cache.UpsertAsync(typeof(AlternateNamedTestEntry), new AlternateNamedTestEntry
|
||||
{
|
||||
Name = "unrelated"
|
||||
}, new CultRecordKey("typed-index:unrelated"));
|
||||
|
||||
var initial = cache.GetStoredDocuments<NamedTestEntry>().Single();
|
||||
Assert.That(initial.Key, Is.EqualTo(key));
|
||||
Assert.That(((NamedTestEntry)initial.Document).Value, Is.EqualTo("first"));
|
||||
|
||||
await cache.UpsertAsync(typeof(NamedTestEntry), new NamedTestEntry
|
||||
{
|
||||
Name = "indexed",
|
||||
Value = "second"
|
||||
}, key);
|
||||
var replaced = cache.GetStoredDocuments<NamedTestEntry>().Single();
|
||||
Assert.That(((NamedTestEntry)replaced.Document).Value, Is.EqualTo("second"));
|
||||
|
||||
Assert.That(cache.Remove(key), Is.True);
|
||||
Assert.That(cache.GetStoredDocuments<NamedTestEntry>(), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CultCache_FlushOnDispose_Persists_When_Enabled()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue