public async Task TokenFiredOnDeletion() { using (var root = new DisposableFileSystem()) { using (var fileSystemWatcher = new MockFileSystemWatcher(root.RootPath)) { using (var physicalFilesWatcher = new PhysicalFilesWatcher(root.RootPath + Path.DirectorySeparatorChar, fileSystemWatcher)) { using (var provider = new PhysicalFileProvider(root.RootPath, physicalFilesWatcher)) { var name = Guid.NewGuid().ToString(); var token = provider.Watch(name); fileSystemWatcher.CallOnDeleted(new FileSystemEventArgs(WatcherChangeTypes.Deleted, root.RootPath, name)); await Task.Delay(WaitTimeForTokenToFire); Assert.True(token.HasChanged); } } } } }
public async Task TokensFiredOnFileDeleted() { using (var root = new DisposableFileSystem()) { var fileName = Guid.NewGuid().ToString(); var fileLocation = Path.Combine(root.RootPath, fileName); using (var fileSystemWatcher = new MockFileSystemWatcher(root.RootPath)) { using (var physicalFilesWatcher = new PhysicalFilesWatcher(root.RootPath + Path.DirectorySeparatorChar, fileSystemWatcher)) { using (var provider = new PhysicalFileProvider(root.RootPath, physicalFilesWatcher)) { var token = provider.Watch(fileName); Assert.NotNull(token); Assert.False(token.HasChanged); Assert.True(token.ActiveChangeCallbacks); fileSystemWatcher.CallOnDeleted(new FileSystemEventArgs(WatcherChangeTypes.Deleted, root.RootPath, fileName)); await Task.Delay(WaitTimeForTokenToFire); Assert.True(token.HasChanged); } } } } }