Skip to content
Permalink
Browse files

DirectoryWatcherBase - AfterSubscriptionDisposeSubscribeAgainAndUpdate

  • Loading branch information
bobbymcr committed Feb 10, 2020
1 parent 2904336 commit 5efe3e4945671c703deeb9314a4874f8a28964c1
@@ -125,13 +125,32 @@ public void UpdateTwoAfterOneSubscriptionDispose()
}

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");
}

[TestMethod]
public void AfterSubscriptionDisposeSubscribeAgainAndUpdate()
{
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("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().HaveCount(2).And.ContainInOrder(
@"X:\root\file1.txt",
@"X:\root\file2.txt");
}

private sealed class FakeDirectoryWatcher : DirectoryWatcherBase
{
public FakeDirectoryWatcher(DirectoryInfo path)

0 comments on commit 5efe3e4

Please sign in to comment.
You can’t perform that action at this time.