Пример #1
0
        public void FileGetDownloadTest()
        {
            GetDownloadRequest request = new GetDownloadRequest();

            request.path      = Path.Combine(dataFolder, "TestFile.pdf");
            request.storage   = storageName;
            request.versionId = null;
            var response = FileApi.GetDownload(request);

            Assert.IsNotNull(response);
        }
Пример #2
0
        public void FilePutCreateTest()
        {
            string           path    = Path.Combine(dataFolder, "folder2/TestFile1.pdf");
            PutCreateRequest request = new PutCreateRequest();

            request.path      = Path.Combine(dataFolder, "folder4/TestFile1.pdf");
            request.File      = FileApi.GetDownload(new GetDownloadRequest(path, null, storageName));
            request.storage   = destStorageName;
            request.versionId = null;
            var response = FileApi.PutCreate(request);

            Assert.AreEqual(200, response.Code);
        }
        public void IfTokenIsNotValidRefreshTokenShouldBeSuccessfully()
        {
            // Arrange
            var api =
                new FileApi(
                    new Configuration
            {
                AppKey     = AppKey,
                AppSid     = AppSid,
                ApiBaseUrl = AppUrl,
                AuthType   = AuthType.OAuth2,
                DebugMode  = true
            });

            using (var stream = this.ToStream("content"))
            {
                var request = new GetDownloadRequest();
                request.path    = Path.Combine(dataFolder, "TestFile.pdf");
                request.storage = storageName;
                api.GetDownload(request);

                Thread.Sleep(2000);
                stream.Flush();
                stream.Position = 0;

                var mockFactory       = new MockFactory();
                var traceListenerMock = mockFactory.CreateMock <TraceListener>();
                Trace.Listeners.Add(traceListenerMock.MockObject);

                traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("grant_type=refresh_token"));
                traceListenerMock.Expects.AtLeastOne.Method(p => p.WriteLine(string.Empty)).With(Is.Anything);

                // Act
                api.GetDownload(request);

                // Assert
                mockFactory.VerifyAllExpectationsHaveBeenMet();
            }
        }