public void Detect_file_change() { const string FILENAME = "test.txt"; File.WriteAllText(FILENAME, "a"); var sut = new Filesystem("template.cs"); var timestamp = File.GetLastWriteTime(FILENAME); var result = sut.FileHasChanged(FILENAME, ref timestamp); Assert.IsFalse(result); timestamp = timestamp.Subtract(TimeSpan.FromSeconds(5)); result = sut.FileHasChanged(FILENAME, ref timestamp); Assert.IsTrue(result); }
private void PollFileForChanges(string filename, Action onChanged) { var fileTimestamp = DateTime.MinValue; _tim.Start(() => { if (_fs.FileHasChanged(filename, ref fileTimestamp)) { onChanged(); } }); _tim.Wait(); }