public async Task ResourceModified_WhenFileChanges_IsFired() { var fileWatcher = new FileWatcher(ValidWatchablePath); using (var monitoredFileWatcher = fileWatcher.Monitor()) { File.WriteAllText(TestTxtPath, File.ReadAllText(TestTxtPath) + "s"); await Task.Delay(1000); monitoredFileWatcher.Should().Raise(nameof(fileWatcher.ResourceModified)); } }
public async Task Stops_IsCalled_StopsRaisingEvents() { ResetTestFileData(); try { var fileWatcher = new FileWatcher(ValidWatchablePath); fileWatcher.Stop(); using (var monitoredFileWatcher = fileWatcher.Monitor()) { File.WriteAllText(TestTxtPath, File.ReadAllText(TestTxtPath) + "s"); await Task.Delay(1000); monitoredFileWatcher.Should().NotRaise(nameof(fileWatcher.ResourceModified)); } } finally { ResetTestFileData(); } }