public void HandleFileChanged() { tempFile = TempFileUtil.CreateTempXmlFile("FileChangedWatcherTest", "foo.xml", "<derek><zoolander/></derek>"); using (FileChangedWatcher watcher = new FileChangedWatcher(tempFile)) { watcher.OnFileChanged += new FileSystemEventHandler(FileChanged); UpdateFile("<rob><schneider/></rob>"); Assert.AreEqual(1, filechangedCount); UpdateFile("<joseph><conrad/></joseph"); Assert.AreEqual(2, filechangedCount); } }
public void HandleFileMove() { tempFile = TempFileUtil.GetTempFilePath("FileChangedWatcherTest", "foo.xml"); using (FileChangedWatcher watcher = new FileChangedWatcher(tempFile)) { watcher.OnFileChanged += new FileSystemEventHandler(FileChanged); string file = TempFileUtil.CreateTempXmlFile("FileChangedWatcherTest", "bar.xml", "<adam><sandler /></adam>"); new FileInfo(file).MoveTo(tempFile); Assert.IsTrue(monitor.WaitOne(5000, false)); monitor.Reset(); Assert.AreEqual(1, filechangedCount); } }