예제 #1
0
		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());
		}
예제 #2
0
 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());
 }
예제 #3
0
 public void ClearCache()
 {
     try {
         _CoverService.ClearCache();
         CacheSize = Helper.MakeNiceSize(_CoverService.CacheSize());
     }
     catch (Exception exc) {
         _Logger.WarnException("Failed to clear cover cache", exc);
     }
     CanClearCache = false;
 }
예제 #4
0
        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);
        }
예제 #5
0
        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());
        }
예제 #6
0
        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;
            }
        }