Example #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);
            });
        }
Example #2
0
        public void DownloadFile(FilePayload filePayload)
        {
            loggingService.LogVerbose($"Attempting to download file: {dateTimeService.DateTimeNow()}");

            IWebClient webClient = null;

            try
            {
                webClient = webClientFactory.Create();
                SetUpFileDownload(filePayload, webClient);
                DownloadFile(filePayload, webClient);
            }
            finally
            {
                webClientFactory.Release(webClient);
            }

            loggingService.LogVerbose($"File download complete: {dateTimeService.DateTimeNow()}");
        }