public async Task MixSyncModes(SynchronizationMode fromSyncMode, SynchronizationMode toSyncMode) { var context = new Context(Logger); using (var testDirectory = new DisposableDirectory(FileSystem)) { StrongFingerprint sfp = StrongFingerprint.Random(); ContentHashListWithDeterminism value = new ContentHashListWithDeterminism(ContentHashList.Random(), CacheDeterminism.None); await RunTestAsync( context, testDirectory, async (store, session) => { // Add a value to a store with one sync mode AddOrGetContentHashListResult addResult = await session.AddOrGetContentHashListAsync(context, sfp, value, Token); Assert.True(addResult.Succeeded); Assert.Null(addResult.ContentHashListWithDeterminism.ContentHashList); }, testDir => CreateSQLiteMemoizationStore(testDirectory.Path, fromSyncMode)); await RunTestAsync( context, testDirectory, async (store, session) => { // Make sure the same value can still be read from another sync mode GetContentHashListResult getResult = await session.GetContentHashListAsync(context, sfp, Token); getResult.ShouldBeSuccess(); Assert.Equal(value, getResult.ContentHashListWithDeterminism); // Make sure a new value can be written in another sync mode StrongFingerprint newSfp = StrongFingerprint.Random(); ContentHashListWithDeterminism newValue = new ContentHashListWithDeterminism(ContentHashList.Random(), CacheDeterminism.None); AddOrGetContentHashListResult addResult = await session.AddOrGetContentHashListAsync(context, newSfp, newValue, Token); Assert.True(addResult.Succeeded); Assert.Null(addResult.ContentHashListWithDeterminism.ContentHashList); }, testDir => CreateSQLiteMemoizationStore(testDirectory.Path, toSyncMode)); } }
public Task EvictionInLruOrder() { var context = new Context(Logger); return(RunTestAsync(context, async session => { // Write more than MaxRowCount items so the first ones should fall out. var strongFingerprints = Enumerable.Range(0, (int)MaxRowCount + 3).Select(i => StrongFingerprint.Random()).ToList(); foreach (var strongFingerprint in strongFingerprints) { await session.AddOrGetContentHashListAsync( context, strongFingerprint, new ContentHashListWithDeterminism(ContentHashList.Random(), CacheDeterminism.None), Token).ShouldBeSuccess(); _clock.Increment(); } // Make sure store purging completes. await((ReadOnlySQLiteMemoizationSession)session).PurgeAsync(context); // Check the first items written have fallen out. for (var i = 0; i < 3; i++) { GetContentHashListResult r = await session.GetContentHashListAsync(context, strongFingerprints[i], Token); r.Succeeded.Should().BeTrue(); r.ContentHashListWithDeterminism.ContentHashList.Should().BeNull(); } // Check the rest are still present. for (var i = 3; i < strongFingerprints.Count; i++) { GetContentHashListResult r = await session.GetContentHashListAsync(context, strongFingerprints[i], Token); r.Succeeded.Should().BeTrue(); r.ContentHashListWithDeterminism.ContentHashList.Should().NotBeNull(); } })); }