public async void FileIndexingEvents_FileMovedToWatchedDirectory_Raised(string eventName) { var engine = SearchEngineFactory.New(); var tcs = new TaskCompletionSource <bool>(); using (var sourceFolder = new TestFolder()) { using (var file = new TestFile("foo", sourceFolder.Path)) { var fileName = file.Name; using (var destFolder = new TestFolder()) { var destFolderPath = destFolder.Path; using (new TestFile("bar", destFolderPath)) { engine.Add(destFolderPath); await Task.Delay(100); engine.AddHandler(eventName, args => { tcs.TrySetResult(Path.GetFullPath($"{destFolderPath}\\{fileName}") == args.Path); }); file.Move(destFolderPath); Assert.True(await tcs.Task); } } } } }
public async void FileIndexingEvents_NotIndexedFileMovedToSubFolder_Raised(string eventName) { var engine = SearchEngineFactory.New(); var tcs = new TaskCompletionSource <bool>(); using (var folder = new TestFolder()) { var folderPath = folder.Path; using (var file = new TestFile("foo", folderPath)) { var fileName = file.Name; using (var subFolder = new TestFolder(folderPath)) { var subFolderPath = subFolder.Path; engine.Add(subFolderPath); await Task.Delay(300); engine.AddHandler(eventName, args => { var expectedPath = Path.GetFullPath($"{subFolderPath}\\{fileName}"); tcs.TrySetResult(expectedPath == args.Path); }); file.Move(subFolderPath); Assert.True(await tcs.Task); } } } }
public async void FileRemovingEvents_FileMovedToFolder_Raised(string eventName) { var engine = SearchEngineFactory.New(); var tcs = new TaskCompletionSource <bool>(); using (var folder = new TestFolder()) { var folderPath = folder.Path; using (var file = new TestFile("foo", folderPath)) { var filePath = file.Path; using (var subFolder = new TestFolder(folderPath)) { var subFolderPath = subFolder.Path; engine.Add(folderPath); await Task.Delay(100); engine.AddHandler(eventName, args => { tcs.TrySetResult(Path.GetFullPath(filePath) == args.Path); }); file.Move(subFolderPath); Assert.True(await tcs.Task); } } } }