private void When_unlocking_bytes_in_stream_it_must_not_raise_events() { // Arrange const string directoryToWatch = @"c:\some"; string filePath = Path.Combine(directoryToWatch, "file.txt"); FakeFileSystem fileSystem = new FakeFileSystemBuilder() .IncludingBinaryFile(filePath, BufferFactory.Create(4096)) .Build(); using (IFileStream stream = fileSystem.File.Open(filePath, FileMode.Open)) { stream.Lock(0, 256); using (FakeFileSystemWatcher watcher = fileSystem.ConstructFileSystemWatcher(directoryToWatch)) { watcher.NotifyFilter = TestNotifyFilters.All; watcher.IncludeSubdirectories = true; using (var listener = new FileSystemWatcherEventListener(watcher)) { // Act stream.Unlock(0, 256); watcher.FinishAndWaitForFlushed(MaxTestDurationInMilliseconds); // Assert listener.EventsCollected.Should().BeEmpty(); } } } }