partial void ShowStream(NSObject sender) { if (eventStream != null) { eventStream.Show(); } }
public void SetExclusionPathsTest() { var watchDirPath = Path.Combine(dirPath, "WatchDir"); var watchDir = Directory.CreateDirectory(watchDirPath); var unWatchDirPath = Path.Combine(dirPath, "UnwatchDir"); var unWatchDir = Directory.CreateDirectory(unWatchDirPath); // Passing empty array returns a false Assert.IsFalse(fsEventStream.SetExclusionPaths(new string [] { }), "SetExclusionPaths empty array failed"); // Excluding the unWatchDirPath from the watcher so any event inside it doesn't get var exclusionPaths = new string [] { Path.Combine(fsEventStream.PathsBeingWatched [0], "UnwatchDir"), Path.Combine(fsEventStream.PathsBeingWatched [0], "UnwatchDir") }; Assert.IsTrue(fsEventStream.SetExclusionPaths(exclusionPaths), "SetExclusionPaths failed"); Assert.True(true); FileStream fileToWatch = File.Create(Path.Combine(watchDirPath, "TempFileToWatch.txt")); FileStream fileToExclude = File.Create(Path.Combine(unWatchDirPath, "TempFileToExclude.txt")); fileToWatch.Close(); fileToExclude.Close(); var taskCompletionSource = new TaskCompletionSource <FSEventStreamEventsArgs> (); FSEventStreamEventsArgs args = null; TestRuntime.RunAsync(TimeSpan.FromSeconds(30), async() => { fsEventStream.Events += (sender, eventArgs) => { taskCompletionSource.SetResult(eventArgs); }; fsEventStream.ScheduleWithRunLoop(CFRunLoop.Current); fsEventStreamStarted = fsEventStream.Start(); File.AppendAllText(Path.Combine(unWatchDirPath, "TempFileToExclude.txt"), "Adding to excluded file!"); File.AppendAllText(Path.Combine(watchDirPath, "TempFileToWatch.txt"), "Adding to included file!"); args = await taskCompletionSource.Task.ConfigureAwait(false); }, () => watchedFileChanged); fsEventStream.Show(); Assert.IsNotNull(args, "Null args"); // Assert that only one event is triggered and that the path is that of the watched file Assert.AreEqual(args.Events.Length, 1, "More events triggered"); Assert.AreEqual(Path.Combine(fsEventStream.PathsBeingWatched [0], "WatchDir", "TempFileToWatch.txt"), args.Events [0].Path, "Watched file not triggered"); }