Esempio n. 1
0
        public async Task Dequeue_PersistsImageQueueAfterDequeuing()
        {
            Option <ISavedImage> expectedDequeuedImage = A.Dummy <ISavedImage>().Some();

            A.CallTo(() => _innerQueue.Dequeue()).Returns(expectedDequeuedImage);

            Option <ISavedImage> dequeuedImage = await _sut.Dequeue();

            dequeuedImage.Should().Be(expectedDequeuedImage);
            A.CallTo(() => _innerQueue.Dequeue()).MustHaveHappened()
            .Then(A.CallTo(() => _persistence.SaveSettings(ImageQueuePersistenceKey, EnqueuedImageIdsJson)).MustHaveHappened());
        }
Esempio n. 2
0
        public async Task <Option <ISavedImage> > Dequeue()
        {
            Option <ISavedImage> dequeuedImage = await _queue.Dequeue();

            await dequeuedImage.Select(_ => PersistLatestQueueState()).ValueOr(Task.FromResult(0));

            return(dequeuedImage);
        }
Esempio n. 3
0
 public void UpdateWallpaperFrom(IImageQueue imageQueue)
 {
     _wallpaperUpdateSubscriptions.Add(Observable
                                       .Interval(TimeSpan.FromSeconds(10)) // TODO: Make this a configurable setting
                                       .SelectMany(i => Observable.FromAsync(_ => imageQueue.Dequeue()))
                                       .SelectMany(o => Observable.FromAsync(_ => o
                                                                             .Map(async i =>
     {
         _logger.Information("Setting wallpaper to {ImageId} from source {SourceId}", i.Id.ImageId.Value, i.Id.SourceId.Value);
         await _wallpaperEnvironment.SetWallpaper(i.Id.SourceId.Value, i.Id.ImageId.Value, _logger);
         _logger.Information("Wallpaper set to {ImageId} from source {SourceId}", i.Id.ImageId.Value, i.Id.SourceId.Value);
     })
                                                                             .ValueOr(TaskConstants.Completed)))
                                       .Subscribe());
 }