private static void Main(string[] args) { WatchDirectory watchDir = new WatchDirectory(); ThreadPool.QueueUserWorkItem((e) => { watchDir.StartDirectoryWatcher(); }); var key = Console.ReadKey(); watchDir.Stop(); }
public void Watcher_StartDirectoryWatcher_ShouldHandleEvent() { // Arrange var watchDirectory = new WatchDirectory(_fileProcessorMoq.Object); // Act ThreadPool.QueueUserWorkItem((e) => { Thread.Sleep(2000); using (var file = File.CreateText(Path.Combine(watchDirectory.WorkDirectory, "test.txt"))) { file.WriteLine("Hello from test method: Watcher_StartDirectoryWatcher_ShouldHandleEvent "); } Thread.Sleep(1000); watchDirectory.Stop(); }); watchDirectory.StartDirectoryWatcher(); // Assert _fileProcessorMoq.Verify(x => x.Process(It.IsAny <string>())); }