public SearchForFileAndFolders ( string searchPath, List |
||
searchPath | string | |
queryCollection | List |
|
directorySeparatorChar | char | |
Результат | List |
public List<string> SearchForFileAndFolders(string searchPath, List<string> queryCollection, char directorySeparatorChar)
{
if((searchPath ?? string.Empty).Length == 2)
{
queryCollection = GetFilesAndFoldersFromDrive(searchPath, queryCollection, directorySeparatorChar);
queryCollection = GetComputerNamesOnNetwork(searchPath, queryCollection);
}
else
{
queryCollection = GetAllFilesAndFolders(searchPath, queryCollection, directorySeparatorChar);
}
return queryCollection;
}
public void FileSystemQuery_SearchForFileAndFolders_DriveSearchPath_ExpectCurrentValues() { //------------Setup for test-------------------------- var dir = new Mock<IDirectory>(); dir.Setup(a => a.GetFileSystemEntries(It.IsAny<string>())).Returns(new[] { "a", "b", "c" }); dir.Setup(a => a.Exists(It.IsAny<string>())).Returns(true); var query = new FileSystemQuery(dir.Object, new DirectoryEntryFactory(), new ShareCollectionFactory()); var files = new List<string> { "non" }; files = query.SearchForFileAndFolders(@"c:", files, '\\'); //------------Assert Results------------------------- Assert.AreEqual(files.Count, 3); Assert.AreEqual("a", files[0]); Assert.AreEqual("b", files[1]); Assert.AreEqual("c", files[2]); }