DownloadFile() public method

Method to download the file from the repository.
public DownloadFile ( string downloadUrl, string authorization, string fileName ) : Microsoft.Research.DataOnboarding.Utilities.Model.DataFile
downloadUrl string
authorization string
fileName string
return Microsoft.Research.DataOnboarding.Utilities.Model.DataFile
Exemplo n.º 1
0
        public void DownloadFile_ShouldReturnNull_WhenThereIsAnExceptionWhileDownloadingFile()
        {
            SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
            DataFile dataFile = null;
            string errorMessage = "Some error message";

            try
            {
                using (ShimsContext.Create())
                {
                    ShimSkyDriveAdapter.AllInstances.DownloadFileStringAuthToken = (sda, fileId, authToken) => { throw new Exception(errorMessage); return new byte[0]; };
                    ShimDiagnosticsProvider.AllInstances.WriteErrorTraceTraceEventIdException = (diagnosticsProvider, traceEventId, message) => { };
                    dataFile = skyDriveAdapter.DownloadFile("DownloadUrl", "Authorization", "SomeFileName.xlsx");
                }
            }
            catch (Exception ex)
            {
                Assert.IsNull(dataFile);
                Assert.AreEqual(errorMessage, ex.Message.ToString());
            }
        }
Exemplo n.º 2
0
        public void DownloadFile_ShouldReturnExcelFile_WhenTheFileTobeDownloadedIsAXlsxFile()
        {
            SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
            DataFile dataFile = null;
            using (ShimsContext.Create())
            {
                ShimSkyDriveAdapter.AllInstances.DownloadFileStringAuthToken = (sda, fileId, authToken) => new byte[0];
                dataFile = skyDriveAdapter.DownloadFile("DownloadUrl", "Authorization", "SomeFileName.xlsx");
            }

            Assert.AreEqual(".xlsx", dataFile.FileExtentsion);
            Assert.AreEqual("SomeFileName.xlsx", dataFile.FileName);
        }