Added two further tests to test GetDirectories and GetFiles in case no directory exists.

This commit is contained in:
verhoek
2018-11-01 12:55:10 +01:00
parent 84edc2c91e
commit 706dd6b8e8
+30
View File
@@ -66,5 +66,35 @@ namespace Duplicati.UnitTest
var filePathRoot = SystemIO.IO_WIN.GetPathRoot(filePath);
Assert.AreEqual(root + Util.DirectorySeparatorString, filePathRoot);
}
[Test]
public void TestGetFilesWhenDirectoryDoesNotExist()
{
var pathRoot = Utility.IsClientWindows ? "C:\\" : "/";
var longPath = LongPath(pathRoot);
if (SystemIO.IO_OS(Utility.IsClientWindows).DirectoryExists(longPath))
{
return;
}
//In particular don't throw PathTooLongException
Assert.Throws<System.IO.DirectoryNotFoundException>(() => SystemIO.IO_OS(Utility.IsClientWindows).GetFiles(longPath));
}
[Test]
public void TestGetDirectoriesWhenDirectoryDoesNotExist()
{
var pathRoot = Utility.IsClientWindows ? "C:\\" : "/";
var longPath = LongPath(pathRoot);
if (SystemIO.IO_OS(Utility.IsClientWindows).DirectoryExists(longPath))
{
return;
}
//In particular don't throw PathTooLongException
Assert.Throws<System.IO.DirectoryNotFoundException>(() => SystemIO.IO_OS(Utility.IsClientWindows).GetDirectories(longPath));
}
}
}