public async Task WatchSmokeAsync() { var fs = new TestFileSystem(); fs.FileSystemWatcher = new TestFSWatcherFactory(); fs.Directory.CreateDirectory("sqls"); fs.File.WriteAllText(@"sqls\test.sdmap", "sql Hello{Hello}"); DbConnectionExtensions.SetSqlDirectoryAndWatch(@"sqls", fs); fs.File.WriteAllText(@"sqls\test.sdmap", "sql Hello{Hello2}"); fs.FileSystemWatcher.TheOnlyWatcher.FireChange(WatcherChangeTypes.Changed, "sqls", "test.sdmap"); await Task.Delay(30); var text = DbConnectionExtensions.EmitSql("Hello", null); Assert.Equal("Hello2", text); }
public void WatchSmoke() { Directory.CreateDirectory("sqls"); var tempFile = @"sqls\test.sdmap"; File.WriteAllText(tempFile, "sql Hello{Hello}"); DbConnectionExtensions.SetSqlDirectoryAndWatch(@".\sqls"); try { File.WriteAllText(tempFile, "sql Hello{Hello2}"); Thread.Sleep(30); var text = DbConnectionExtensions.EmitSql("Hello", null); Assert.Equal("Hello2", text); } finally { File.Delete(tempFile); Directory.Delete("sqls"); } }