Skip to content
Permalink
Browse files

DirectoryWatcherBase - SubscribeNullCallback

  • Loading branch information
bobbymcr committed Feb 10, 2020
1 parent 0b756e4 commit 1dd3fff386121d0a4f857c2d4aa1e78dc538ffda
@@ -31,6 +31,11 @@ public IDisposable Subscribe(string file, Action<FileInfo> onUpdate)
throw new ArgumentNullException(nameof(file));
}

if (onUpdate == null)
{
throw new ArgumentNullException(nameof(onUpdate));
}

FileInfo fullPath = new FileInfo(Path.Combine(this.path, file));
string key = fullPath.FullName;
Action onDispose = () => this.subscriptions.TryRemove(key, out _);
@@ -189,6 +189,17 @@ public void SubscribeNullFile()
act.Should().Throw<ArgumentNullException>().Which.ParamName.Should().Be("file");
}

[TestMethod]
public void SubscribeNullCallback()
{
DirectoryWatcherBase watcherBase = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root"));
Action<FileInfo> onUpdate = null;

Action act = () => watcherBase.Subscribe("file1.txt", onUpdate);

act.Should().Throw<ArgumentNullException>().Which.ParamName.Should().Be("onUpdate");
}

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

0 comments on commit 1dd3fff

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