private async Task RunImpl ( string method, AccessNeeded accessNeeded, Func <IContentSession, Task> setupFuncAsync, Func <IContentSession, Task> testFuncAsync ) { using (var testDirectory = new DisposableDirectory(FileSystem)) { AbsolutePath rootPath = await EstablishTestContent(testDirectory, accessNeeded); await RunStore(rootPath, CacheName, async session => { if (setupFuncAsync != null) { await setupFuncAsync(session); } var stopwatch = Stopwatch.StartNew(); await testFuncAsync(session); stopwatch.Stop(); var rate = (long)(_itemCount / stopwatch.Elapsed.TotalSeconds); var name = GetType().Name + "." + method; _resultsFixture.AddResults(Output, name, rate, "items/sec", _itemCount); }); } }
private async Task <AbsolutePath> EstablishTestContent(DisposableDirectory testDirectory, AccessNeeded accessNeeded) { AbsolutePath rootPath; if (accessNeeded == AccessNeeded.Write) { if (_initialSize == InitialSize.Full) { _context.Debug("Starting with a full writable store"); await CreatePrepopulatedIfMissing(); await CopyPrepopulatedTo(testDirectory); // Test runs against a writable copy in the test directory. rootPath = testDirectory.Path; } else { _context.Debug("Starting with an empty writable store"); // Test runs against an empty test directory. rootPath = testDirectory.Path; } } else { if (_initialSize == InitialSize.Full) { _context.Debug("Starting with a full read-only store"); await CreatePrepopulatedIfMissing(); // Test runs against the prepopulated directory. rootPath = _prePopulatedRootPath; } else { _context.Debug("Starting with an empty read-only store"); // Test runs against an empty test directory. rootPath = testDirectory.Path; } } return(rootPath); }