Ejemplo n.º 1
0
        public void DownloadFile_WhenErrorOccursDuringDownload_ReleasesWebClient()
        {
            webClientMock.When(client => client.DownloadFile(Arg.Any <Uri>(), Arg.Any <string>()))
            .Do(callInfo => { throw new Exception(); });

            Assert.Throws <Exception>(() => systemUnderTest.DownloadFile(filePayload));

            Received.InOrder(() =>
            {
                webClientMock.DownloadFile(filePayload.DownloadUri, filePayload.DownloadFilePath);
                webClientFactoryMock.Release(webClientMock);
            });
        }
 public void Download(string SrourcePath, string DestinationDirectory, DownloadInfo info = null)
 {
     try
     {
         client.DownloadFile(SrourcePath, DestinationDirectory + "\\" + Helper.GetFileName(SrourcePath));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public void DownloadPages(string path, string url)
        {
            if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException();
            }

            var fileDownloaded = _webClient.DownloadFile(path, url);

            if (fileDownloaded)
            {
                _dBRepository.SaveDetailsToDB(url, path);
            }
        }
Ejemplo n.º 4
0
 private void DownloadImage(Uri posterURL, string posterDestination)
 {
     WebClient.DownloadFile(posterURL, posterDestination);
 }
Ejemplo n.º 5
0
 private void DownloadFile(FilePayload filePayload, IWebClient webClient)
 {
     webClient.DownloadFile(filePayload.DownloadUri, filePayload.DownloadFilePath);
 }
Ejemplo n.º 6
0
        private string[] GetStockData(string ticker, string queryParameters)
        {
            var stockData = webClient.DownloadFile(ticker, queryParameters);

            return(stockData.Split(','));
        }
Ejemplo n.º 7
0
 public static void DownloadFile(this IWebClient client, Uri address)
 {
     client.DownloadFile(address, PathUtilities.SanitizePath(PathUtilities.GetFilename(address.AbsoluteUri), SanitizePathOptions.StripInvalidFilenameChars));
 }