コード例 #1
0
        public void ResumableUploadObjectWithFailedTimeMoreThanRetryTime()
        {
            var key = OssTestUtils.GetObjectKey(_className);

            try
            {
                var client = new FakeClient(Config.Endpoint, Config.AccessKeyId, Config.AccessKeySecret);
                client.beginFailedIndex = 2;
                client.endFailedIndex   = 100;
                client.currentIndex     = 0;

                client.ResumableUploadObject(_bucketName, key, Config.MultiUploadTestFile, null,
                                             Config.DownloadFolder);
                Assert.IsFalse(true);
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }
            finally
            {
                if (OssTestUtils.ObjectExists(_ossClient, _bucketName, key))
                {
                    _ossClient.DeleteObject(_bucketName, key);
                }
            }
        }
コード例 #2
0
        public void ResumableUploadObjectFirstFailedAndSecondSucceeded()
        {
            var key = OssTestUtils.GetObjectKey(_className);

            var client = new FakeClient(Config.Endpoint, Config.AccessKeyId, Config.AccessKeySecret);

            try
            {
                client.beginFailedIndex = 2;
                client.endFailedIndex   = 100;

                client.ResumableUploadObject(_bucketName, key, Config.MultiUploadTestFile, null,
                                             Config.DownloadFolder);
                Assert.IsTrue(false);
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }

            try
            {
                client.beginFailedIndex = 0;
                client.endFailedIndex   = 0;
                client.currentIndex     = 1;

                var result = client.ResumableUploadObject(_bucketName, key, Config.MultiUploadTestFile, null,
                                                          Config.DownloadFolder);
                Assert.IsTrue(OssTestUtils.ObjectExists(_ossClient, _bucketName, key));
                Assert.IsTrue(result.ETag.Length > 0);
            }
            finally
            {
                if (OssTestUtils.ObjectExists(_ossClient, _bucketName, key))
                {
                    _ossClient.DeleteObject(_bucketName, key);
                }
            }
        }