From da9290d576721736a174a34937f6afb85e312f62 Mon Sep 17 00:00:00 2001 From: bris <864617621@qq.com> Date: Fri, 13 Aug 2021 17:04:16 +0800 Subject: [PATCH] restore some unitTest setting --- QCloudCSharpSDK/COSXMLTests/ObjectTest.cs | 29 ++++++++++++++++----- QCloudCSharpSDK/COSXMLTests/QCloudServer.cs | 12 ++++----- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/QCloudCSharpSDK/COSXMLTests/ObjectTest.cs b/QCloudCSharpSDK/COSXMLTests/ObjectTest.cs index d6cee9e..c15591d 100644 --- a/QCloudCSharpSDK/COSXMLTests/ObjectTest.cs +++ b/QCloudCSharpSDK/COSXMLTests/ObjectTest.cs @@ -1211,7 +1211,8 @@ public void TestDownloadTaskInteractive() public void TestDownloadResumableTask() { //执行请求 - GetObjectRequest getRequest = new GetObjectRequest(bucket, "exampleobject", localDir, "exampleobject"); + GetObjectRequest getRequest = new GetObjectRequest(bucket, "bigObject1619585110", localDir, "bigObject1619585110"); + getRequest.LimitTraffic(8 * 1024 * 1024); COSXMLDownloadTask downloadTask = new COSXMLDownloadTask(getRequest); downloadTask.SetResumableDownload(true); @@ -1220,14 +1221,30 @@ public void TestDownloadResumableTask() downloadTask.progressCallback = delegate (long completed, long total) { progrss = completed * 100.0 / total; - Console.WriteLine(String.Format("progress = {0:##.##}%", progrss)); + // Console.WriteLine(String.Format("progress = {0:##.##}%", progrss)); }; - Task task = transferManager.DownloadAsync(downloadTask); + var asyncTask = transferManager.DownloadAsync(downloadTask); - Thread.Sleep(200); - Console.WriteLine(task.Result.GetResultInfo()); - Assert.True(task.Result.IsSuccessful()); + asyncTask = downloadTask.AsyncTask(); + asyncTask.Wait(); + + if (downloadTask.State() != TaskState.Completed && downloadTask.State() != TaskState.Failed) + { + Console.WriteLine("downloadTask.State() = " + downloadTask.State()); + Console.WriteLine("localFileCrc64 = " + downloadTask.GetLocalFileCrc64()); + if (progrss < 100) + { + downloadTask.Cancel(); + } + + Thread.Sleep(500); + } + else + { + Console.WriteLine("localFileCrc64 = " + downloadTask.GetLocalFileCrc64()); + Thread.Sleep(500); + } } [Test()] diff --git a/QCloudCSharpSDK/COSXMLTests/QCloudServer.cs b/QCloudCSharpSDK/COSXMLTests/QCloudServer.cs index c5bf63d..0718c02 100644 --- a/QCloudCSharpSDK/COSXMLTests/QCloudServer.cs +++ b/QCloudCSharpSDK/COSXMLTests/QCloudServer.cs @@ -48,19 +48,19 @@ private QCloudServer() QLog.SetLogLevel(Level.V); uin = "3472213910"; - appid = "1251668577"; + appid = "1252246555"; bucketVersioning = "dotnet-ut-versioning-1252246555"; regionForBucketVersioning = "ap-beijing"; - bucketForObjectTest = "examplebucket-0706-1251668577"; + bucketForObjectTest = "dotnet-ut-obj-1252246555"; bucketForLoggingTarget = "dotnet-ut-logging-target-1252246555"; region = "ap-guangzhou"; - secretId = Environment.GetEnvironmentVariable("SECRET_ID"); - secretKey = Environment.GetEnvironmentVariable("SECRET_KEY"); + secretId = Environment.GetEnvironmentVariable("COS_KEY"); + secretKey = Environment.GetEnvironmentVariable("COS_SECRET"); if (secretId == null) { - secretId = Environment.GetEnvironmentVariable("SECRET_ID", EnvironmentVariableTarget.Machine); - secretKey = Environment.GetEnvironmentVariable("SECRET_KEY", EnvironmentVariableTarget.Machine); + secretId = Environment.GetEnvironmentVariable("COS_KEY", EnvironmentVariableTarget.Machine); + secretKey = Environment.GetEnvironmentVariable("COS_SECRET", EnvironmentVariableTarget.Machine); } CosXmlConfig config = new CosXmlConfig.Builder()