增加Progress的IsFinished函数;修改解压ZIP的重试逻辑以及中途取消解压的参数
This commit is contained in:
5 files changed
+35
-29
No files matched your search
@@ -46,7 +46,7 @@ public class ProgressTest : TestBase {
|
||||
progress.Set(0.75, skiped: true);
|
||||
|
||||
await Assert.That(changedCount).IsEqualTo(2);
|
||||
await Assert.That(Math.Abs(progress.GetIncrement() - 2.0 / 3) < 0.000001).IsTrue();
|
||||
await Assert.That(Math.Abs(progress.GetIncreasing() - 2.0 / 3) < 0.000001).IsTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -7,10 +7,10 @@ public class FileUtilsTest : TestWithFolder {
|
||||
[Arguments("GB Encoding.zip")]
|
||||
[Arguments("UTF8 Encoding.zip")]
|
||||
public async Task 解压_ReadZip(string testFile) {
|
||||
double progress = 0;
|
||||
string output = Path.Combine(tempFolder, "Extracted");
|
||||
FileUtils.ExtractToDirectory(GetTestFile(testFile), output, p => progress = p);
|
||||
await Assert.That(progress).IsEqualTo(1);
|
||||
var p = new ProgressProvider();
|
||||
FileUtils.ExtractToDirectory(GetTestFile(testFile), output, p: p);
|
||||
await Assert.That(p.IsFinished).IsTrue();
|
||||
await Assert.That(DirectoryUtils.Exists(Path.Combine(output, "文件夹"))).IsTrue();
|
||||
await Assert.That(DirectoryUtils.Exists(Path.Combine(output, "空文件夹"))).IsFalse();
|
||||
await Assert.That(File.ReadAllText(PathUtils.ToExtendedFormat(Path.Combine(output, "fabricloader.log")))).Contains("FabricLoader");
|
||||
@@ -20,10 +20,10 @@ public class FileUtilsTest : TestWithFolder {
|
||||
[Test]
|
||||
[Arguments("GZ.gz", "LTCat")]
|
||||
public async Task 解压_ReadGz(string testFile, string containsText) {
|
||||
double progress = 0;
|
||||
string output = Path.Combine(tempFolder, "Extracted");
|
||||
FileUtils.ExtractToDirectory(GetTestFile(testFile), output, p => progress = p);
|
||||
await Assert.That(progress).IsEqualTo(1);
|
||||
var p = new ProgressProvider();
|
||||
FileUtils.ExtractToDirectory(GetTestFile(testFile), output, p: p);
|
||||
await Assert.That(p.IsFinished).IsTrue();
|
||||
await Assert.That(File.ReadAllText(PathUtils.ToExtendedFormat(Path.Combine(output, PathUtils.GetFileNameWithoutExtension(testFile))))).Contains(containsText);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ public class TaskUtilsTest : TestBase {
|
||||
], progress);
|
||||
|
||||
await Assert.That(ReferenceEquals(firstProgress, secondProgress)).IsFalse();
|
||||
await Assert.That(progress.GetIncrement()).IsEqualTo(0.5);
|
||||
await Assert.That(progress.GetIncreasing()).IsEqualTo(0.5);
|
||||
continueSecond.SetResult(null);
|
||||
var results = await whenAll;
|
||||
await Assert.That(string.Join(",", results)).IsEqualTo("1,2");
|
||||
await Assert.That(progress.GetIncrement()).IsEqualTo(1);
|
||||
await Assert.That(progress.GetIncreasing()).IsEqualTo(1);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user