protected override bool TraceErrorsOnly => true; // This type adds nothing in terms of tracing. So configure it to trace errors only. /// <summary> /// Initializes a new instance of the <see cref="ReadOnlyFileSystemContentSession" /> class. /// </summary> public ReadOnlyFileSystemContentSession(string name, FileSystemContentStoreInternal store, ImplicitPin implicitPin) : base(name) { Store = store; _pinContext = Store.CreatePinContext(); _implicitPin = implicitPin; }
public async Task AddPinThrowsOnDisposedPinContext() { var context = new Context(Logger); using (var taskTracker = new BackgroundTaskTracker(nameof(PinContextTests), context)) { try { var pinContext = new PinContext(taskTracker, contentHashes => { }); pinContext.AddPin(ContentHash.Random()); await pinContext.DisposeAsync(); Action addPinAction = () => pinContext.AddPin(ContentHash.Random()); addPinAction.Should().Throw <ObjectDisposedException>(); } finally { await taskTracker.ShutdownAsync(context); } } }
public async Task AddPinAccumulatesDuplicates() { var context = new Context(Logger); using (var taskTracker = new BackgroundTaskTracker(nameof(PinContextTests), context)) { try { ContentHash hash1 = ContentHash.Random(); ContentHash hash2 = ContentHash.Random(); var hashCounts = new ConcurrentDictionary <ContentHash, int> { [hash1] = 0, [hash2] = 0 }; using (var pinContext = new PinContext(taskTracker, pinCounts => { foreach (var pinCount in pinCounts) { hashCounts[pinCount.Key] = pinCount.Value; } })) { pinContext.AddPin(hash2); pinContext.AddPin(hash1); pinContext.AddPin(hash2); } hashCounts[hash1].Should().Be(1); hashCounts[hash2].Should().Be(2); } finally { await taskTracker.ShutdownAsync(context); } } }
public Task <IEnumerable <Indexed <PinResult> > > PinAsync(Context context, IReadOnlyList <ContentHash> contentHashes, PinContext pinContext) { throw new NotImplementedException(); }
public Task <PinResult> PinAsync(Context context, ContentHash contentHash, PinContext pinContext) { throw new NotImplementedException(); }
protected async Task PutRandomAndPinAsync(FileSystemContentStoreInternal store, int contentSize, PinContext pinContext) { PutResult putResult = await store.PutRandomAsync(Context, contentSize); putResult.ShouldBeSuccess(); PinResult pinResult = await store.PinAsync(Context, putResult.ContentHash, pinContext); pinResult.ShouldBeSuccess(); }