public void FilesChanged_WithSpecificFlags_InvokesChangedHandler_WithExpectedArguments(uint fileChangeFlag, int expectedKind)
        {
            // Arrange
            var  filePath = TestProjectData.SomeProjectImportFile.FilePath;
            uint cookie;
            var  fileChangeService = new Mock <IVsFileChangeEx>();

            fileChangeService
            .Setup(f => f.AdviseFileChange(It.IsAny <string>(), It.IsAny <uint>(), It.IsAny <IVsFileChangeEvents>(), out cookie))
            .Returns(VSConstants.S_OK);
            var tracker = new VisualStudioFileChangeTracker(filePath, Dispatcher, ErrorReporter, fileChangeService.Object);

            var called = false;

            tracker.Changed += (sender, args) =>
            {
                called = true;
                Assert.Same(sender, tracker);
                Assert.Equal(filePath, args.FilePath);
                Assert.Equal((FileChangeKind)expectedKind, args.Kind);
            };

            // Act
            tracker.FilesChanged(fileCount: 1, filePaths: new[] { filePath }, fileChangeFlags: new[] { fileChangeFlag });

            // Assert
            Assert.True(called);
        }
Beispiel #2
0
        public async Task FilesChanged_WithSpecificFlags_InvokesChangedHandler_WithExpectedArguments(uint fileChangeFlag, int expectedKind)
        {
            // Arrange
            var filePath          = TestProjectData.SomeProjectImportFile.FilePath;
            var fileChangeService = Mock.Of <IVsAsyncFileChangeEx>(MockBehavior.Strict);
            var tracker           = new VisualStudioFileChangeTracker(filePath, ErrorReporter, fileChangeService, Dispatcher, JoinableTaskFactory.Context);

            var called = false;

            tracker.Changed += (sender, args) =>
            {
                called = true;
                Assert.Same(sender, tracker);
                Assert.Equal(filePath, args.FilePath);
                Assert.Equal((FileChangeKind)expectedKind, args.Kind);
            };

            // Act
            tracker.FilesChanged(fileCount: 1, filePaths: new[] { filePath }, fileChangeFlags: new[] { fileChangeFlag });
            await tracker._fileChangedTask;

            // Assert
            Assert.True(called);
        }