[SuppressMessage("ReSharper", "SuggestBaseTypeForParameter")]// needed for DI public MainViewModel( Configuration config, ShortcutManager shortcutManager, // manually injecting all tabs for now, SourcesViewModel sourcesVm, // might want to replace this if more tabs get added ConfigurationViewModel configuration, DownloaderViewModel downloader, LibraryViewModel library) { DisplayName = WindowTitleBase; TabClosing = OnTabClosing; this.config = config; this.shortcutManager = shortcutManager; CreateShortcuts(); Items.AddRange(new TabViewModelBase[] { library, downloader, sourcesVm, configuration, }); library.ConductWith(this); downloader.ConductWith(this); sourcesVm.ConductWith(this); configuration.ConductWith(this); var tabId = config.State.ActiveTab ?? string.Empty; var tab = Items.FirstOrDefault(t => t.Id == tabId); if (tab != null) { ActivateItem(tab); } }
/// <summary> /// Удалить загрузку из очереди. /// </summary> /// <param name="downloader">Удаляемый загрузчик.</param> public void RemoveDownloader(DownloaderViewModel downloader) { if (this.downloaders.Contains(downloader)) { this.downloaders.Remove(downloader); } }
public void DownloaderViewModel_Should_Implement_INotifyPropertyChanged() { //arrange DownloaderViewModel viewModel = new DownloaderViewModel(mockSysinternalsSuiteDownload.Object); //act INotifyPropertyChanged iNotifyPropertyChanged = viewModel; //assert Assert.IsNotNull(iNotifyPropertyChanged); }
public void DownloaderViewModel_StartDownload_Command_Test() { //arrange DownloaderViewModel viewModel = new DownloaderViewModel(mockSysinternalsSuiteDownload.Object); //act ICommand command = viewModel.StartDownloadCommand; command.Execute("Test"); //assert mockSysinternalsSuiteDownload.Verify(e => e.DownloadFileAsync()); }
public void DownloaderViewModel_Default_Value_Test() { //arrange DownloaderViewModel viewModel = new DownloaderViewModel(mockSysinternalsSuiteDownload.Object); //act //assert Assert.IsFalse(viewModel.IsAddToSystemPathSelected); Assert.IsTrue(viewModel.IsDownloadButtonEnabled); Assert.IsTrue(viewModel.IsExtractToCurrentDirectorySelected); Assert.IsFalse(viewModel.IsExtractToProgramFilesSelected); }
public void Test1_AddDownload_CHANGEVIEW() { var mockedshowmessage = GetMockedshowmessage(); var mockedselectedfile = Getmockedselectedfile(); var mockedIUrlService = GetMockedIUrlService(); var mockedICreateEngine = GetMockedICreateEngine(); var result = new DownloaderViewModel(mockedselectedfile.Object, mockedshowmessage.Object, mockedIUrlService.Object, mockedICreateEngine.Object) { Url = "http://ipv4.download.thinkbroadband.com/50MB.zip" }; // Act result.AddDownload(); result.StartDownload(); // Assert result.AreDownloadDetailsShown.ShouldBeEquivalentTo(true); }
public void Test1_AddDownload_ToList() { // Arrange var mockedshowmessage = GetMockedshowmessage(); var mockedselectedfile = Getmockedselectedfile(); var mockedIUrlService = GetMockedIUrlService(); var mockedICreateEngine = GetMockedICreateEngine(); var result = new DownloaderViewModel(mockedselectedfile.Object, mockedshowmessage.Object, mockedIUrlService.Object, mockedICreateEngine.Object) { Url = "http://ipv4.download.thinkbroadband.com/50MB.zip" }; // Act result.AddDownload(); // Assert result.Downloads.Count().Should().Be(1); }
public ActionResult GetNzbGetDownloadInformation() { if (!Settings.HasSettings) { ViewBag.Error = Resources.Resources.Settings_Missing_NzbGet; return(PartialView("DashletError")); } Logger.Trace("Getting Config"); var formattedUri = UrlHelper.ReturnUri(Settings.IpAddress, Settings.Port).ToString(); try { Logger.Trace("Getting NzbGetStatus"); var statusInfo = Api.GetNzbGetStatus(formattedUri, Settings.Username, Settings.Password); Logger.Trace("Getting Current NZBGetlist"); var downloadInfo = Api.GetNzbGetList(formattedUri, Settings.Username, Settings.Password); var downloadSpeed = statusInfo.Result.DownloadRate / 1024; var model = new DownloaderViewModel { Application = Applications.NzbGet, DownloadSpeed = MemorySizeConverter.SizeSuffix(downloadSpeed), DownloadItem = new List <DownloadItem>() }; var results = downloadInfo.result; Logger.Trace(string.Format("Results count : {0}", results.Count)); foreach (var result in results) { Logger.Trace(string.Format("Going through result {0}", result.NZBName)); var percentage = (result.DownloadedSizeMB / (result.RemainingSizeMB + (double)result.DownloadedSizeMB) * 100); Logger.Trace(string.Format("Percentage : {0}", percentage)); var status = EnumHelper <DownloadStatus> .Parse(result.Status); var progressBar = "progress-bar-danger"; if (status == DownloadStatus.PAUSED || status == DownloadStatus.QUEUED) { progressBar = "progress-bar-warning"; } if (status == DownloadStatus.DOWNLOADING) { progressBar = "progress-bar-success"; } model.DownloadItem.Add( new DownloadItem { FontAwesomeIcon = IconHelper.ChooseIcon(status), DownloadPercentage = Math.Ceiling(percentage).ToString(CultureInfo.CurrentUICulture), DownloadingName = result.NZBName, Status = status, NzbId = result.NZBID, ProgressBarClass = progressBar }); } return(PartialView("_Download", model)); } catch (Exception e) { Logger.Error(e.Message, e); ViewBag.Error = e.Message; return(PartialView("DashletError")); } }
public MainWindow() { InitializeComponent(); DataContext = new DownloaderViewModel(); }
public ActionResult GetSabNzbdDownloadInformation() { if (!Settings.HasSettings) { ViewBag.Error = Resources.Resources.Settings_Missing_SabNzb; return(PartialView("DashletError")); } Logger.Trace("Getting Config"); var formattedUri = UrlHelper.ReturnUri(Settings.IpAddress, Settings.Port).ToString(); try { Logger.Trace("Getting GetSabNzbdQueue"); var statusInfo = Api.GetSabNzbdQueue(formattedUri, Settings.ApiKey); var downloadSpeed = statusInfo.kbpersec; var model = new DownloaderViewModel { Application = Applications.SabNZBD, DownloadSpeed = MemorySizeConverter.SizeSuffix((long)downloadSpeed), DownloadItem = new List <DownloadItem>() }; var results = statusInfo.jobs; Logger.Trace(string.Format("Results count : {0}", results.Count)); foreach (var result in results) { Logger.Trace(string.Format("Going through result {0}", result.id)); var percentage = (result.mbleft / result.mb * 100); Logger.Trace(string.Format("Percentage : {0}", percentage)); var status = EnumHelper <DownloadStatus> .Parse(statusInfo.paused? "PAUSED" : "DOWNLOADING"); var progressBar = Bootstrap.ProgressBarDanger; if (status == DownloadStatus.PAUSED || status == DownloadStatus.QUEUED) { progressBar = Bootstrap.ProgressBarWarning; } if (status == DownloadStatus.DOWNLOADING) { progressBar = Bootstrap.ProgressBarSuccess; } int nzbId; int.TryParse(result.id, out nzbId); model.DownloadItem.Add(new DownloadItem { FontAwesomeIcon = IconHelper.ChooseIcon(status), DownloadPercentage = Math.Ceiling(percentage).ToString(CultureInfo.CurrentUICulture), DownloadingName = result.filename, Status = status, NzbId = nzbId, ProgressBarClass = progressBar }); } return(PartialView("_Download", model)); } catch (Exception e) { Logger.Error(e.Message, e); ViewBag.Error = e.Message; return(PartialView("DashletError")); } }
public Task <DownloaderResult> DownloadAsync(DownloaderViewModel viewModel) => ShowDialogAsync(() => new Downloader(viewModel));