public async Task Enqueue_PersistsImageQueueAfterEnqueuing() { var imagesToEnqueue = new [] { A.Dummy <ISavedImage>() }; await _sut.Enqueue(imagesToEnqueue); A.CallTo(() => _innerQueue.Enqueue(A <IEnumerable <ISavedImage> > .That.IsSameSequenceAs(imagesToEnqueue))) .MustHaveHappened(Repeated.Exactly.Once) .Then(A.CallTo(() => _persistence.SaveSettings(ImageQueuePersistenceKey, EnqueuedImageIdsJson)).MustHaveHappened()); }
public async Task Rehydrade(Func <SourceQualifiedImageId, ISavedImage> fetchSavedImages) { _logger.Information("Attempting to load queue"); Option <string> persistedQueue = await _persistence.LoadSettings(SettingsKey); await persistedQueue.Match(async s => { _logger.Information("Loaded queue json"); IEnumerable <SourceQualifiedImageId> deserializedQueue = _imageQueueSerializer.Deserialize(s); _logger.Information("Queue deserialized"); await _queue.Clear(); await _queue.Enqueue(deserializedQueue.Select(fetchSavedImages)); }, () => { _logger.Information("Unable to load queue"); return(TaskConstants.Completed); }); }