I have a class that watches files using the following method:
public FileWatcher(List<string> dirsToWatch, string filter, OnChange onChange)
{
OnChangeEnt = onChange;
foreach (var dir in dirsToWatch)
{
var watcher = new FileSystemWatcher(dir);
watcher.Filter = filter;
watcher.Changed += new FileSystemEventHandler(onChange);
watcher.Created += new FileSystemEventHandler(onChange);
watcher.Renamed += new RenamedEventHandler(OnChangeHandler);
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.FileName;
watcher.IncludeSubdirectories = true;
watcher.EnableRaisingEvents = true;
_watchers.Add(watcher);
}
}
I just wanted to know how I would unit test this method to get 100% coverage. Any help would be truly appreciated.Thanks