Esempio n. 1
0
        public void Update_Replace()
        {
            // Arrange
            var textBuffer = new TestTextBuffer(new StringTextSnapshot("original"));
            var replace    = new VisualStudioTextChange(0, textBuffer.CurrentSnapshot.Length, "replaced text");
            var document   = new TestVirtualDocument(Uri, textBuffer);

            // Act
            document.Update(new[] { replace }, hostDocumentVersion: 1);

            // Assert
            var text = textBuffer.CurrentSnapshot.GetText();

            Assert.Equal(replace.NewText, text);
        }
Esempio n. 2
0
        public void Update_Delete()
        {
            // Arrange
            var textBuffer = new TestTextBuffer(new StringTextSnapshot("Hello World"));
            var delete     = new VisualStudioTextChange(6, 5, string.Empty);
            var document   = new TestVirtualDocument(Uri, textBuffer);

            // Act
            document.Update(new[] { delete }, hostDocumentVersion: 1);

            // Assert
            var text = textBuffer.CurrentSnapshot.GetText();

            Assert.Equal("Hello ", text);
        }
Esempio n. 3
0
        public void Update_Insert()
        {
            // Arrange
            var insert     = new VisualStudioTextChange(0, 0, "inserted text");
            var textBuffer = new TestTextBuffer(StringTextSnapshot.Empty);
            var document   = new TestVirtualDocument(Uri, textBuffer);

            // Act
            document.Update(new[] { insert }, hostDocumentVersion: 1);

            // Assert
            var text = textBuffer.CurrentSnapshot.GetText();

            Assert.Equal(insert.NewText, text);
        }
Esempio n. 4
0
        public void Update_MultipleEdits()
        {
            // Arrange
            var textBuffer = new TestTextBuffer(new StringTextSnapshot("Hello World"));
            var replace    = new VisualStudioTextChange(6, 5, "Replaced");
            var delete     = new VisualStudioTextChange(0, 6, string.Empty);

            using var document = new TestVirtualDocument(Uri, textBuffer);

            // Act
            document.Update(new[] { replace, delete }, hostDocumentVersion: 1, state: null);

            // Assert
            var text = textBuffer.CurrentSnapshot.GetText();

            Assert.Equal("Replaced", text);
        }