Exemple #1
0
        public async Task Setup()
        {
            // This might setup a synchronization context (eg in the case of webforms), but we don't want that context around for the duration of the setup
            // since the main thread is likely to be blocking at this point
            await _setup.SetupQuickUseControl(_quickUseOptions.ToList());

            _logger.Information("Setup quick use controls");

            // Run the rest on a different thread to avoid any static environmental contexts (eg WindowsFormsSynchronizationContext) setup by the _setup.SetupQuickUseControl method
            await Task.Run(async() =>
            {
                await _imageQueue.Rehydrade(_imageRepository.LoadImage);
                _logger.Information("Image queue loaded from persistence");
                _imageQueue.StartQueuingSavedImages(_saver.StartSavingImages(_imageSources));
                _logger.Information("Image queue connecting to image sources");
                await _imageSourceConfigurations.RehydrateSources();
                _logger.Information("Image sources loaded from persistence");
                _wallpaperUpdater.UpdateWallpaperFrom(_imageQueue);
                _logger.Information("Wallpaper updates connected to image queue");
                foreach (IImageSourceConfiguration source in _testingSources.GetTestingSourceConfigurations())
                {
                    await _imageSourceConfigurations.Add(source);
                }
                _logger.Information("Application started");
            }).ConfigureAwait(false); // Avoid deadlocking the main thread, which may be blocking on the result of this method
        }
Exemple #2
0
        public async Task Setup_Called_InitializedServices()
        {
            await _wallrApplication.Setup();

            A.CallTo(() => _setup.SetupQuickUseControl(A <IReadOnlyList <IQuickUseOption> > .That.IsSameSequenceAs(_quickUseOptions)))
            .MustHaveHappened(Repeated.Exactly.Once)
            .Then(A.CallTo(() => _imageQueue.Rehydrade(_imageRepository.LoadImage))
                  .MustHaveHappened(Repeated.Exactly.Once))
            .Then(A.CallTo(() => _imageQueue.StartQueuingSavedImages(_savedImages))
                  .MustHaveHappened(Repeated.Exactly.Once))
            .Then(A.CallTo(() => _imageSourceConfigurations.RehydrateSources())
                  .MustHaveHappened(Repeated.Exactly.Once))
            .Then(A.CallTo(() => _wallpaperUpdater.UpdateWallpaperFrom(_imageQueue))
                  .MustHaveHappened(Repeated.Exactly.Once));
        }