Inheritance: BaseAdapter, IRepositoryAdapter
Ejemplo n.º 1
0
 public void GetIdentifier_ShouldReturnNotImplementedException()
 {
     using (ShimsContext.Create())
     {
         ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
         SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
         skyDriveAdapter.GetIdentifier(null, null);
     }
 }
Ejemplo n.º 2
0
 public void PostFile_ShouldReturnArgumentNullException_WhenFileIsNull()
 {
     using (ShimsContext.Create())
     {
         ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
         SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
         PublishSkyDriveFileModel publishFileModel = new PublishSkyDriveFileModel();
         skyDriveAdapter.PostFile(publishFileModel);
     }
 }
Ejemplo n.º 3
0
        public void PostFile_ShouldReturnArgumentException_WhenFileNameHasWhitespaces()
        {
            using (ShimsContext.Create())
            {
                ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
                SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
                PublishSkyDriveFileModel publishFileModel = new PublishSkyDriveFileModel()
                {
                    File = new DataFile() { FileName = " " }
                };

                skyDriveAdapter.PostFile(publishFileModel);
            }
        }
Ejemplo n.º 4
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());
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public void PostFile_ShouldReturnExceptionMessage_WhenFileUploadThrowsError()
        {
            SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
            PublishSkyDriveFileModel publishFileModel = new PublishSkyDriveFileModel()
            {
                File = new DataFile() { FileName = "SomeFileName", FileContent = new byte[1] },
                AuthToken = new AuthToken()
            };

            OperationStatus operationStatus;
            string errorMessage = "Some error message";
            using (ShimsContext.Create())
            {
                ShimSkyDriveAdapter.AllInstances.UploadFilePublishSkyDriveFileModel = (sda, psdfm) => { throw new Exception(errorMessage); return string.Empty; };
                operationStatus = skyDriveAdapter.PostFile(publishFileModel);
            }
        }
Ejemplo n.º 7
0
        public void PostFile_ShouldReturnSucceededStatus_WhenFileUploadIsSuccessful()
        {
            OperationStatus operationStatus;
            string fileId = "1234";
            using (ShimsContext.Create())
            {
                ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
                SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
                PublishSkyDriveFileModel publishFileModel = new PublishSkyDriveFileModel()
                {
                    File = new DataFile() { FileName = "SomeFileName", FileContent = new byte[1] },
                    AuthToken = new AuthToken()
                };

                ShimSkyDriveAdapter.AllInstances.UploadFilePublishSkyDriveFileModel = (sda, psdfm) => fileId;
                ShimDiagnosticsProvider.AllInstances.WriteInformationTraceTraceEventIdString = (diagnosticsProvider, traceEventId, message) => { };
                operationStatus = skyDriveAdapter.PostFile(publishFileModel);
            }

            Assert.IsTrue(operationStatus.Succeeded);
            Assert.AreEqual(fileId, operationStatus.CustomReturnValues);
        }
Ejemplo n.º 8
0
        public void PostFile_ShouldReturnInvalidAccessTokenErrorMessage_WhenAccessTokenIsNull()
        {
            using (ShimsContext.Create())
            {
                ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
                SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
                PublishSkyDriveFileModel publishFileModel = new PublishSkyDriveFileModel()
                {
                    File = new DataFile() { FileName = "SomeFileName", FileContent = new byte[1] }
                };

                skyDriveAdapter.PostFile(publishFileModel);
            }
        }
Ejemplo n.º 9
0
        public void PostFile_ShouldReturnArgumentException_WhenFileContentLengthIsZero()
        {
            using (ShimsContext.Create())
            {
                ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
                SkyDriveAdapter skyDriveAdapter = new SkyDriveAdapter();
                PublishSkyDriveFileModel publishFileModel = new PublishSkyDriveFileModel()
                {
                    File = new DataFile() { FileName = "SomeFileName", FileContent = new byte[0] }
                };

                var operationStatus = skyDriveAdapter.PostFile(publishFileModel);
            }
        }