Exemplo n.º 1
0
        public async Task HttpsDontStart()
        {
            var downloadRequest = new DownloadRequest()
            {
                Threads = 2,
                Links   = new System.Collections.Generic.List <LinkSave>
                {
                    new LinkSave {
                        Filename = "file1", Link = "https://someValidLink"
                    },
                    new LinkSave {
                        Filename = "file2", Link = "http://someValidLink"
                    }
                }
            };
            var fileDownloadStatus = new FileDonwladStatus();
            var downloadService    = new DownloaderService(fileDownloadStatus
                                                           , NSubstitute.Substitute.For <Microsoft.Extensions.Configuration.IConfiguration>()
                                                           , NSubstitute.Substitute.For <Microsoft.Extensions.Logging.ILogger <DownloaderService> >());

            Assert.False(downloadService.ValidateHttpLinks(downloadRequest));

            await downloadService.Download(downloadRequest);

            Assert.Empty(fileDownloadStatus.Definitions);
        }
Exemplo n.º 2
0
        public async Task EmptyLinksDontStartDownload()
        {
            var downloadRequest = new DownloadRequest()
            {
                Threads = 2,
                Links   = null
            };
            var fileDownloadStatus = new FileDonwladStatus();
            var downloadService    = new DownloaderService(fileDownloadStatus
                                                           , NSubstitute.Substitute.For <Microsoft.Extensions.Configuration.IConfiguration>()
                                                           , NSubstitute.Substitute.For <Microsoft.Extensions.Logging.ILogger <DownloaderService> >());
            await downloadService.Download(downloadRequest);

            Assert.Empty(fileDownloadStatus.Definitions);
        }
Exemplo n.º 3
0
 public DownloadController(ILogger <DownloadController> logger, DownloaderService downloaderService, FileDonwladStatus status)
 {
     _logger              = logger;
     _downloaderService   = downloaderService;
     _downloadDefinitions = status.Definitions;
 }