public async Task RecursePath_Directories() { // Given const string rootPath = "/"; const string homePath = "/home"; const string userPath = "/home/user1"; var rootSubDirs = new[] { homePath, "/etc", "/tmp" }; var homeSubDirs = new[] { userPath }; _fileSystemService.GetDirectories(rootPath).Returns(rootSubDirs); _fileSystemService.GetDirectories(homePath).Returns(homeSubDirs); // When await _fileWalker.RecursePath(rootPath); // Then await _fileSystemService.Received(1).GetDirectories(rootPath); await _fileSystemService.Received(1).GetDirectories(homePath); await _fileSystemService.Received(1).GetDirectories(rootPath); await _fileSystemService.Received(1).GetDirectories(homePath); }
public async Task RecursePath_FilterFileByExtension(string extensionFilter, string file, bool wanted) { // Given _configService.GetFilterExtension().Returns(new[] { extensionFilter }); var fileWalker = new FileWalker(_compareService, _configService, _fileSystemService); _fileSystemService.GetFiles("/").Returns(new[] { file }); _configService.GetFilterExtension().Returns(new[] { extensionFilter }); _fileSystemService.HasAccess(file).Returns(true); _fileSystemService.IsLink(file).Returns(false); // When await fileWalker.RecursePath("/"); // Then _compareService.Received(wanted ? 1 : 0).AddFile(file); }