Fixed usings in unit tests

This commit is contained in:
Kenneth Skovhede
2024-03-03 15:41:49 +01:00
parent 2ce049cecb
commit d7f027b9e2
15 changed files with 90 additions and 105 deletions
+20 -21
View File
@@ -1,23 +1,23 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
@@ -25,7 +25,6 @@ using System.Linq;
using Duplicati.Library.Interface;
using Duplicati.Library.Main;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
+1 -2
View File
@@ -1,4 +1,4 @@
// Copyright (C) 2024, The Duplicati Team
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,7 +25,6 @@ using System.IO;
using System.Linq;
using System.Collections.Generic;
using Duplicati.Library.Interface;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
-1
View File
@@ -24,7 +24,6 @@ using System.Linq;
using Duplicati.Library.Interface;
using Duplicati.Library.Main;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
-1
View File
@@ -31,7 +31,6 @@ using Duplicati.Library.Main.Volumes;
using NUnit.Framework;
using IFileEntry = Duplicati.Library.Interface.IFileEntry;
using Utility = Duplicati.Library.Utility.Utility;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
+1 -2
View File
@@ -1,4 +1,4 @@
// Copyright (C) 2024, The Duplicati Team
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -27,7 +27,6 @@ using Duplicati.Library.Common.IO;
using Duplicati.Library.Interface;
using Duplicati.Library.Utility;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
+1 -2
View File
@@ -1,4 +1,4 @@
// Copyright (C) 2024, The Duplicati Team
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,7 +25,6 @@ using NUnit.Framework;
using System.Linq;
using System.Collections.Generic;
using Duplicati.Library.Interface;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
+1 -2
View File
@@ -1,4 +1,4 @@
// Copyright (C) 2024, The Duplicati Team
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,7 +23,6 @@ using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
+20 -21
View File
@@ -29,7 +29,6 @@ using Duplicati.Library.Main;
using Duplicati.Library.Utility;
using NUnit.Framework;
using Utility = Duplicati.Library.Utility.Utility;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
@@ -51,10 +50,10 @@ namespace Duplicati.UnitTest
const string asterisk = "*";
string dirWithAsterisk = Path.Combine(this.DATAFOLDER, asterisk);
// Windows does not support literal asterisks in paths.
if (!Platform.IsClientWindows)
{
SystemIO.IO_OS.DirectoryCreate(dirWithAsterisk);
TestUtils.WriteFile(SystemIO.IO_OS.PathCombine(dirWithAsterisk, file), new byte[] {0});
if (!Platform.IsClientWindows)
{
SystemIO.IO_OS.DirectoryCreate(dirWithAsterisk);
TestUtils.WriteFile(SystemIO.IO_OS.PathCombine(dirWithAsterisk, file), new byte[] {0});
directories.Add(dirWithAsterisk);
questionMarkWildcardShouldMatchCount++;
verbatimAsteriskShouldMatchCount++;
@@ -63,11 +62,11 @@ namespace Duplicati.UnitTest
const string questionMark = "?";
string dirWithQuestionMark = Path.Combine(this.DATAFOLDER, questionMark);
// Windows does not support literal question marks in paths.
if (!Platform.IsClientWindows)
{
SystemIO.IO_OS.DirectoryCreate(dirWithQuestionMark);
TestUtils.WriteFile(SystemIO.IO_OS.PathCombine(dirWithQuestionMark, file), new byte[] { 1 });
directories.Add(dirWithQuestionMark);
if (!Platform.IsClientWindows)
{
SystemIO.IO_OS.DirectoryCreate(dirWithQuestionMark);
TestUtils.WriteFile(SystemIO.IO_OS.PathCombine(dirWithQuestionMark, file), new byte[] { 1 });
directories.Add(dirWithQuestionMark);
questionMarkWildcardShouldMatchCount++;
}
@@ -75,9 +74,9 @@ namespace Duplicati.UnitTest
// for a '?' wildcard can match on
const string singleCharacterDir = "X";
string dirWithSingleCharacter = Path.Combine(this.DATAFOLDER, singleCharacterDir);
SystemIO.IO_OS.DirectoryCreate(dirWithSingleCharacter);
TestUtils.WriteFile(SystemIO.IO_OS.PathCombine(dirWithSingleCharacter, file), new byte[] { 2 });
directories.Add(dirWithSingleCharacter);
SystemIO.IO_OS.DirectoryCreate(dirWithSingleCharacter);
TestUtils.WriteFile(SystemIO.IO_OS.PathCombine(dirWithSingleCharacter, file), new byte[] { 2 });
directories.Add(dirWithSingleCharacter);
questionMarkWildcardShouldMatchCount++;
const string dir = "dir";
@@ -103,7 +102,7 @@ namespace Duplicati.UnitTest
Assert.AreEqual(0, restoreResults.Errors.Count());
Assert.AreEqual(0, restoreResults.Warnings.Count());
TestUtils.AssertDirectoryTreesAreEquivalent(this.DATAFOLDER, this.RESTOREFOLDER, true, "Restore");
TestUtils.AssertDirectoryTreesAreEquivalent(this.DATAFOLDER, this.RESTOREFOLDER, true, "Restore");
// List results using * should return a match for each directory.
IListResults listResults = c.List(SystemIO.IO_OS.PathCombine(dirWithAsterisk, file));
@@ -114,11 +113,11 @@ namespace Duplicati.UnitTest
listResults = c.List(SystemIO.IO_OS.PathCombine(dirWithQuestionMark, file));
Assert.AreEqual(0, listResults.Errors.Count());
Assert.AreEqual(0, listResults.Warnings.Count());
// List results using ? should return 3 matches in Linux,
// one for the directory with '*' and one for the directory
// with '?', plus one for directory 'X'; but should return
// 1 matches in Windows just for directory 'X'.
Assert.AreEqual(questionMarkWildcardShouldMatchCount, listResults.Files.Count());
// List results using ? should return 3 matches in Linux,
// one for the directory with '*' and one for the directory
// with '?', plus one for directory 'X'; but should return
// 1 matches in Windows just for directory 'X'.
Assert.AreEqual(questionMarkWildcardShouldMatchCount, listResults.Files.Count());
}
SystemIO.IO_OS.DirectoryDelete(this.RESTOREFOLDER, true);
@@ -173,9 +172,9 @@ namespace Duplicati.UnitTest
IBackupResults backupResults = c.Backup(new[] {this.DATAFOLDER}, filter);
Assert.AreEqual(0, backupResults.Errors.Count());
Assert.AreEqual(0, backupResults.Warnings.Count());
Assert.AreEqual(verbatimAsteriskShouldMatchCount, backupResults.ExaminedFiles);
Assert.AreEqual(verbatimAsteriskShouldMatchCount, backupResults.ExaminedFiles);
}
}
}
[Test]
[Category("ProblematicPath")]
+1 -2
View File
@@ -1,4 +1,4 @@
// Copyright (C) 2024, The Duplicati Team
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,7 +28,6 @@ using Duplicati.Library.Interface;
using Duplicati.Library.Main;
using Duplicati.Library.Utility;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
-1
View File
@@ -25,7 +25,6 @@ using System.Linq;
using Duplicati.Library.Interface;
using Duplicati.Library.Main;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
-1
View File
@@ -28,7 +28,6 @@ using Duplicati.Library.Main;
using Duplicati.Library.Main.Database;
using Duplicati.Library.SQLiteHelper;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
+4 -5
View File
@@ -27,7 +27,6 @@ using Duplicati.Library.Common.IO;
using Duplicati.Library.Interface;
using Duplicati.Library.Main;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
@@ -93,9 +92,9 @@ namespace Duplicati.UnitTest
File.WriteAllBytes(filePath, new byte[] {0});
// Protect access rules on the file.
FileSecurity fileSecurity = File.GetAccessControl(filePath);
FileSecurity fileSecurity = new FileInfo(filePath).GetAccessControl();
fileSecurity.SetAccessRuleProtection(true, true);
File.SetAccessControl(filePath, fileSecurity);
new FileInfo(filePath).SetAccessControl(fileSecurity);
Dictionary<string, string> options = new Dictionary<string, string>(this.TestOptions);
using (Controller c = new Controller("file://" + this.TARGETFOLDER, options, null))
@@ -116,7 +115,7 @@ namespace Duplicati.UnitTest
string restoredFilePath = Path.Combine(this.RESTOREFOLDER, "file");
Assert.IsTrue(File.Exists(restoredFilePath));
FileSecurity restoredFileSecurity = File.GetAccessControl(restoredFilePath);
FileSecurity restoredFileSecurity = new FileInfo(restoredFilePath).GetAccessControl();
Assert.IsFalse(restoredFileSecurity.AreAccessRulesProtected);
// Remove the restored file so that the later restore avoids the "Restore completed
@@ -136,7 +135,7 @@ namespace Duplicati.UnitTest
string restoredFilePath = Path.Combine(this.RESTOREFOLDER, "file");
Assert.IsTrue(File.Exists(restoredFilePath));
FileSecurity restoredFileSecurity = File.GetAccessControl(restoredFilePath);
FileSecurity restoredFileSecurity = new FileInfo(restoredFilePath).GetAccessControl();
Assert.IsTrue(restoredFileSecurity.AreAccessRulesProtected);
}
}
+1 -2
View File
@@ -1,4 +1,4 @@
// Copyright (C) 2024, The Duplicati Team
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -27,7 +27,6 @@ using Duplicati.Library.Common;
using Duplicati.Library.Interface;
using Duplicati.Library.Main;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
+20 -21
View File
@@ -1,23 +1,23 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
@@ -27,7 +27,6 @@ using Duplicati.Library.Logging;
using Duplicati.Library.Utility;
using System.Linq;
using Duplicati.Library.Common.IO;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{
+20 -21
View File
@@ -1,23 +1,23 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
@@ -26,7 +26,6 @@ using Duplicati.Library.Interface;
using Duplicati.Library.Main;
using Duplicati.Library.Snapshots;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc;
namespace Duplicati.UnitTest
{