public void UpdateVirtualDocument_Noops_UnknownDocument()
        {
            // Arrange
            var manager       = new DefaultLSPDocumentManager(JoinableTaskContext, UriProvider, LSPDocumentFactory, ChangeTriggers);
            var changedCalled = false;

            manager.Changed += (sender, args) =>
            {
                changedCalled = true;
            };
            var changes = new[] { new TextChange(new TextSpan(1, 1), string.Empty) };

            // Act
            manager.UpdateVirtualDocument <TestVirtualDocument>(Uri, changes, 123);

            // Assert
            Assert.False(changedCalled);
        }
        public void TrackDocument_TriggersDocumentAdded()
        {
            // Arrange
            var manager       = new DefaultLSPDocumentManager(JoinableTaskContext, UriProvider, LSPDocumentFactory, ChangeTriggers);
            var changedCalled = false;

            manager.Changed += (sender, args) =>
            {
                changedCalled = true;
                Assert.Null(args.Old);
                Assert.Same(LSPDocumentSnapshot, args.New);
                Assert.Equal(LSPDocumentChangeKind.Added, args.Kind);
            };

            // Act
            manager.TrackDocument(TextBuffer);

            // Assert
            Assert.True(changedCalled);
        }
        public void UpdateVirtualDocument_Noops_NoChangesSameVersion()
        {
            // Arrange
            var manager = new DefaultLSPDocumentManager(JoinableTaskContext, UriProvider, LSPDocumentFactory, ChangeTriggers);

            manager.TrackDocument(TextBuffer);
            var changedCalled = false;

            manager.Changed += (sender, args) =>
            {
                changedCalled = true;
            };
            var changes = Array.Empty <TextChange>();

            // Act
            manager.UpdateVirtualDocument <TestVirtualDocument>(Uri, changes, 123);

            // Assert
            Assert.False(changedCalled);
        }
        public void UpdateVirtualDocument_InvokesVirtualDocumentChanged()
        {
            // Arrange
            var manager = new DefaultLSPDocumentManager(JoinableTaskContext, UriProvider, LSPDocumentFactory, ChangeTriggers);

            manager.TrackDocument(TextBuffer);
            var changedCalled = false;

            manager.Changed += (sender, args) =>
            {
                changedCalled = true;
                Assert.Same(LSPDocumentSnapshot, args.Old);
                Assert.NotSame(LSPDocumentSnapshot, args.New);
                Assert.Equal(LSPDocumentChangeKind.VirtualDocumentChanged, args.Kind);
            };
            var changes = new[] { new TextChange(new TextSpan(1, 1), string.Empty) };

            // Act
            manager.UpdateVirtualDocument <TestVirtualDocument>(Uri, changes, 123);

            // Assert
            Assert.True(changedCalled);
        }