示例#1
0
        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);
                });
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }