-
-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Hi. If I have a mock FileSystemWatcherMock with NotifyFilters = NotifyFilters.DirectoryName, and I call DirectoryMock.Move to rename a folder inside the watched location, then the Renamed event isn't raised. It is only raised if I have NotifyFilters = NotifyFilters.FileName set, which is wrong.
I believe this is due to https://github.com/Testably/Testably.Abstractions/blob/main/Source/Testably.Abstractions.Testing/Storage/InMemoryStorage.cs#L1031:
ChangeDescription fileSystemChange =
_fileSystem.ChangeHandler.NotifyPendingChange(WatcherChangeTypes.Renamed,
container.Type,
NotifyFilters.FileName,
destination,
source);
Here NotifyFilters.FileName is hard-coded, whereas other calls use ToNotifyFilters(container.Type).
In a slightly different scenario, if I call DirectoryMock.Move to move a folder out of the watched location, then no event is raised. It should raise the Deleted event in this case. This doesn't seem to be related to NotifyFilters though. It's because FileSystemWatcherMock.MatchesFilter only considers the new path, not the old path:
Testably.Abstractions/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherMock.cs
Lines 359 to 365 in df2e064
| else if (!string.Equals( | |
| _fileSystem.Execute.Path.GetDirectoryName(changeDescription.Path), | |
| fullPath, | |
| _fileSystem.Execute.StringComparisonMode)) | |
| { | |
| return false; | |
| } |
Thanks again for your efforts.