예제 #1
0
        public async Task TestDownloadFileSuccess()
        {
            string downloadDir = Path.GetTempPath();

            Uri source = new Uri("https://file-examples-com.github.io/uploads/2017/10/file-sample_150kB.pdf");

            IFileDownloadUtilities fileDownloadUtilities = new FileDownloadUtilities();

            FileDownloadResult result = await fileDownloadUtilities.DownloadFile(source, downloadDir);

            Assert.IsTrue(result.Success);
            Assert.IsNotNull(result.Source);
            Assert.IsTrue(!String.IsNullOrEmpty(result.TargetDirectory));
            Assert.IsTrue(!String.IsNullOrEmpty(result.LocalFilePath));
            Assert.IsTrue(!String.IsNullOrEmpty(result.Filename));
            Assert.IsTrue(!String.IsNullOrEmpty(result.MimeType));
            Assert.Greater(result.FileSize, 0);
            Assert.IsNotNull(result.DownloadTime);
            Assert.IsNull(result.ErrorDetail);

            //Clean up the file
            File.Delete(result.LocalFilePath);

            Assert.IsFalse(File.Exists(result.LocalFilePath));
        }
예제 #2
0
        public async Task <IList <ImportResult> > PerformImport()
        {
            IList <ImportResult> results = new List <ImportResult>();

            //clean the files
            await CleanEnvironment();

            //Download the zipfile
            FileDownloadResult downloadResult =
                await FileDownloadUtilities.DownloadFile(new Uri(Path.Combine(CsvImportSettings.FtpSource, CsvImportSettings.FacZipFilename)),
                                                         CsvImportSettings.LocalImportDirectory);

            if (downloadResult.Success)
            {
                ZipUtility.UnZipFile(downloadResult.LocalFilePath, downloadResult.TargetDirectory);

                results.Add(await PassthroughImporter.Import());
                results.Add(await FormattedFindingsTextImporter.Import());
                results.Add(await FormattedCapTextImporter.Import());
                results.Add(await FindingTextImporter.Import());
                results.Add(await FindingImporter.Import());
                results.Add(await EinImporter.Import());
                results.Add(await DunImporter.Import());
                results.Add(await CpaImporter.Import());
                results.Add(await CapTextImporter.Import());
                results.Add(await AgencyImporter.Import());
                results.Add(await GeneralImporter.Import());
                results.Add(await CfdaImporter.Import());
            }

            return(results);
        }
예제 #3
0
        public async Task TestDownloadFileFailure()
        {
            string downloadDir = Path.GetTempPath();

            Uri source = new Uri("https://badurl/badfilename.txt");

            IFileDownloadUtilities fileDownloadUtilities = new FileDownloadUtilities();

            FileDownloadResult result = await fileDownloadUtilities.DownloadFile(source, downloadDir);

            Assert.False(result.Success);
            Assert.IsNotNull(result.ErrorDetail);
        }
예제 #4
0
        public async Task TestUnzip()
        {
            //Download a "real life" test file
            IFileDownloadUtilities du = new FileDownloadUtilities();
            await du.DownloadFile(ZipFileUrl, TargetDirectory);

            Assert.IsTrue(File.Exists(Path.Combine(TargetDirectory, ZipFileName)));

            IZipUtility zu = new ZipUtility();

            zu.UnZipFile(Path.Combine(TargetDirectory, ZipFileName), TargetDirectory);

            Assert.IsTrue(File.Exists(Path.Combine(TargetDirectory, UnzippedFilename)));
        }