From e8e112ffdb13e1e6e770b548657afca1253c0ec7 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Mon, 12 May 2025 13:05:26 +0200 Subject: [PATCH] Fixed tests --- Duplicati/UnitTest/RestoreHandlerTests.cs | 26 ++++++++--------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/Duplicati/UnitTest/RestoreHandlerTests.cs b/Duplicati/UnitTest/RestoreHandlerTests.cs index d1b52e1dd..4142924d4 100644 --- a/Duplicati/UnitTest/RestoreHandlerTests.cs +++ b/Duplicati/UnitTest/RestoreHandlerTests.cs @@ -171,38 +171,30 @@ namespace Duplicati.UnitTest [Test] [Category("RestoreHandler")] - public void RestoreWithoutLocalData([Values("true", "false")] string noLocalDb, [Values("true", "false")] string noLocalBlocks, [Values("true", "false")] string patchWithLocalBlocks) + public void RestoreWithoutLocalData([Values("true", "false")] string noLocalDb, [Values("true", "false")] string patchWithLocalBlocks) { - string file1Path = Path.Combine(this.DATAFOLDER, "file1"); + var file1Path = Path.Combine(this.DATAFOLDER, "file1"); File.WriteAllBytes(file1Path, new byte[] { 1, 2, 3 }); - string file2Path = Path.Combine(this.DATAFOLDER, "file2"); + var file2Path = Path.Combine(this.DATAFOLDER, "file2"); File.WriteAllBytes(file2Path, new byte[] { 3, 4, 6 }); - string folderPath = Path.Combine(this.DATAFOLDER, "folder"); + var folderPath = Path.Combine(this.DATAFOLDER, "folder"); Directory.CreateDirectory(folderPath); systemIO.FileCopy(file1Path, Path.Combine(folderPath, "file1 copy"), true); using (Controller c = new Controller("file://" + this.TARGETFOLDER, new Dictionary(this.TestOptions), null)) - { - IBackupResults backupResults = c.Backup(new[] { this.DATAFOLDER }); - Assert.AreEqual(0, backupResults.Errors.Count()); - Assert.AreEqual(0, backupResults.Warnings.Count()); - } + TestUtils.AssertResults(c.Backup(new[] { this.DATAFOLDER })); - Dictionary restoreOptions = new Dictionary(this.TestOptions) + var restoreOptions = new Dictionary(this.TestOptions) { ["restore-path"] = this.RESTOREFOLDER, ["no-local-db"] = noLocalDb, - ["no-local-blocks"] = noLocalBlocks, - ["patch-with-local-blocks"] = patchWithLocalBlocks + ["restore-with-local-blocks"] = patchWithLocalBlocks }; + using (Controller c = new Controller("file://" + this.TARGETFOLDER, restoreOptions, null)) - { - IRestoreResults restoreResults = c.Restore(new[] { "*" }); - Assert.AreEqual(0, restoreResults.Errors.Count()); - Assert.AreEqual(0, restoreResults.Warnings.Count()); - } + TestUtils.AssertResults(c.Restore(new[] { "*" })); TestUtils.AssertDirectoryTreesAreEquivalent(this.DATAFOLDER, this.RESTOREFOLDER, true, "Restoring without local data"); }