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); } }
private void DownloadImage(Uri posterURL, string posterDestination) { WebClient.DownloadFile(posterURL, posterDestination); }
private void DownloadFile(FilePayload filePayload, IWebClient webClient) { webClient.DownloadFile(filePayload.DownloadUri, filePayload.DownloadFilePath); }
private string[] GetStockData(string ticker, string queryParameters) { var stockData = webClient.DownloadFile(ticker, queryParameters); return(stockData.Split(',')); }
public static void DownloadFile(this IWebClient client, Uri address) { client.DownloadFile(address, PathUtilities.SanitizePath(PathUtilities.GetFilename(address.AbsoluteUri), SanitizePathOptions.StripInvalidFilenameChars)); }