public SettingsViewModel(AppSettings settings, AppContracts contracts, ICoverService coverService, Core.ILog logger) { _Settings = settings; _Contracts = contracts; _CoverService = coverService; _Logger = logger; DisplayName = string.Format("Settings - {0}", _Contracts.ApplicationName); CacheSize = Helper.MakeNiceSize(_CoverService.CacheSize()); }
public void ClearCache() { try { _CoverService.ClearCache(); CacheSize = Helper.MakeNiceSize(_CoverService.CacheSize()); } catch (Exception exc) { _Logger.WarnException("Failed to clear cover cache", exc); } CanClearCache = false; }
public async Task TestClearCache() { _coverService.CacheSize().Returns(1000); Assert.True(_settingsViewModel.CanClearCache); await _settingsViewModel.ClearCache(); _coverService.Received(1).ClearCache(); Assert.Equal("1000.00 B", _settingsViewModel.CacheSize); Assert.True(_settingsViewModel.CanClearCache); }
public SettingsViewModel(AppContracts contracts, ICoverService coverService, ILog logger, HotKeyViewModel hotKeyViewModel, ISpotifyController spotifyController, AutorunService autorunService, JsonPersister <AppSettings> persister) { _settings = persister.Instance; _contracts = contracts; _coverService = coverService; _logger = logger; _spotifyController = spotifyController; _autorunService = autorunService; _persister = persister; HotKeyViewModel = hotKeyViewModel; DisplayName = $"Settings - {_contracts.ApplicationName}"; CacheSize = Helper.MakeNiceSize(_coverService.CacheSize()); }
public async Task ClearCache() { CanClearCache = false; try { await Task.Run(() => _coverService.ClearCache()); CacheSize = Helper.MakeNiceSize(_coverService.CacheSize()); } catch (Exception exc) { _logger.WarnException("Failed to clear cover cache", exc); } finally { CanClearCache = true; } }