public void UpdateRelevantFileOneSubscriptionDifferentCase() { List <string> updates = new List <string>(); FakeDirectoryWatcher watcher = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root")); DirectoryWatcherBase watcherBase = watcher; watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName)); watcher.Update(@"X:\root\FILE1.txt"); updates.Should().ContainSingle().Which.Should().Be(@"X:\root\file1.txt"); }
public void UpdateIrrelevantFileOneSubscription() { List <string> updates = new List <string>(); FakeDirectoryWatcher watcher = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root")); DirectoryWatcherBase watcherBase = watcher; watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName)); watcher.Update(@"X:\root\not-relevant.txt"); updates.Should().BeEmpty(); }
public void UpdateAfterDispose() { List <string> updates = new List <string>(); FakeDirectoryWatcher watcher = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root")); using (DirectoryWatcherBase watcherBase = watcher) { watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName)); } watcher.Update(@"X:\root\file1.txt"); updates.Should().BeEmpty(); }
public void UpdateTwoFilesTwoSubscriptions() { List <string> updates = new List <string>(); FakeDirectoryWatcher watcher = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root")); DirectoryWatcherBase watcherBase = watcher; watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName)); watcherBase.Subscribe("file2.txt", f => updates.Add(f.FullName)); watcher.Update(@"X:\root\file2.txt"); watcher.Update(@"X:\root\file1.txt"); updates.Should().HaveCount(2).And.ContainInOrder( @"X:\root\file2.txt", @"X:\root\file1.txt"); }
public void UpdateTwoAfterOneSubscriptionDispose() { List <string> updates = new List <string>(); FakeDirectoryWatcher watcher = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root")); DirectoryWatcherBase watcherBase = watcher; using (watcherBase.Subscribe("file1.txt", f => updates.Add(f.FullName))) { } watcherBase.Subscribe("file2.txt", f => updates.Add(f.FullName)); watcher.Update(@"X:\root\file1.txt"); watcher.Update(@"X:\root\file2.txt"); updates.Should().ContainSingle().Which.Should().Be(@"X:\root\file2.txt"); }