public void DownloadFiles() { for (int pageNumber = this.pageStart; pageNumber < this.pageEnd; pageNumber++) { View.PageNumber(pageNumber); var filesInfo = this.fileInfoService .DownloadFilesInfo(pageNumber) .ToArray(); ShowLinks(filesInfo); ShowExistinFiles(filesInfo); MultiFileDownloader.DownloadAll(this.taskNumber, filesInfo, downloadPolicy: fileInfo => { View.DownloadFile(fileInfo.Name); this.downloadService.DownloadFile(fileInfo.Link, fileInfo.Name); View.SavedFile(fileInfo.Name); }); } }
public void DownloadAll_WhenUse7FilesInfor_CallDelegatSevenTimes() { var mock = new Collection <int>(); var tasksStub = 5; var filesStub = NotExistingFilesFake(7); MultiFileDownloader.DownloadAll(tasksStub, filesStub, x => mock.Add(0)); Assert.True(mock.Count == 7); }
public void DownloadAll_When3FilesNotExistAnd3FilesExistOnDisk_CallDelegatSixTimes() { var mock = new Collection <int>(); var tasksStub = 3; var filesStub = NotExistingFilesFake(6).ToList(); filesStub.AddRange(ExistingFilesFake(6)); MultiFileDownloader.DownloadAll(tasksStub, filesStub.ToArray(), x => mock.Add(0)); Assert.True(mock.Count == 6); }
public void DownloadAll_WhenAllFilesExistOnDisk_ProcessItInCorrectTime() { var watch = new Stopwatch(); var tasksStub = 1; var filesStub = ExistingFilesFake(3); watch.Start(); MultiFileDownloader.DownloadAll(tasksStub, filesStub, x => SleepFor50Milliseconds()); watch.Stop(); var processTime = watch.ElapsedMilliseconds; Assert.True(processTime < 20); }
public void DownloadAll_When3FilesNotExistAnd3FilesExistOnDisk_ProcessItInCorrectTime() { var watch = new Stopwatch(); var tasksStub = 3; var filesStub = NotExistingFilesFake(6).ToList(); filesStub.AddRange(ExistingFilesFake(6)); watch.Start(); MultiFileDownloader.DownloadAll(tasksStub, filesStub.ToArray(), x => SleepFor50Milliseconds()); watch.Stop(); var processTime = watch.ElapsedMilliseconds; Assert.True(processTime > 99, processTime.ToString()); Assert.True(processTime < 140); }