public async Task WatcherObservable_GetObservable_CreateEvent() { String monitorPath = ""; // Set monitorPath to the path that is updated when it is changed var asyncObs = watcherObservable.GetObservable() .Select(eventPath => monitorPath = eventPath) .FirstAsync().ToTask(); //Invoke Created Event on Mock String newRoot = "SomeRoot"; String newPath = "SomePath"; String newFullPath = String.Format("{0}\\{1}", newRoot, newPath); var args = new FileSystemEventArgs(WatcherChangeTypes.Created, newRoot, newPath); mock.OnCreated(args); var obs = await asyncObs; Assert.That(monitorPath, Is.EqualTo(newFullPath)); }
public async Task WatcherIntegrationTest_WritingNewFile() { List <String> monitoredPaths = new List <String>(); var timer = Observable.Timer(TimeSpan.FromMilliseconds(500)); var asyncObs = watcherObservable.GetObservable() .Select(eventPath => { monitoredPaths.Add(eventPath); return(monitoredPaths); }) .TakeUntil(timer) // Force the observable to complete on timer expiration .ToTask(); var monitoredFile = Path.Combine(TempPath, "Monitored.Txt"); File.WriteAllText(monitoredFile, "foo"); var obs = await asyncObs; Assert.That(monitoredPaths.Count, Is.EqualTo(1)); Assert.That(monitoredPaths[0], Is.EqualTo(monitoredFile)); }