public void TryGetFromBuffer_PrefersVisualStudioRazorParserIfRazorEditorParserIsAvailable()
        {
            // Arrange
            var properties           = new PropertyCollection();
            var expectedCodeDocument = TestRazorCodeDocument.Create("Hello World");
            var parser = new DefaultVisualStudioRazorParser(expectedCodeDocument);

            properties.AddProperty(typeof(VisualStudioRazorParser), parser);
            var unexpectedCodeDocument = TestRazorCodeDocument.Create("Unexpected");
            var legacyParser           = new RazorEditorParser(unexpectedCodeDocument);

            properties.AddProperty(typeof(RazorEditorParser), legacyParser);
            var textBuffer = new Mock <ITextBuffer>();

            textBuffer.Setup(buffer => buffer.Properties)
            .Returns(properties);
            var provider = new LegacyTextBufferCodeDocumentProvider();

            // Act
            var result = provider.TryGetFromBuffer(textBuffer.Object, out var codeDocument);

            // Assert
            Assert.True(result);
            Assert.Same(expectedCodeDocument, codeDocument);
        }
        public void TryGetFromBuffer_FailsIfNoParserIsAvailable()
        {
            // Arrange
            var properties = new PropertyCollection();
            var textBuffer = new Mock <ITextBuffer>();

            textBuffer.Setup(buffer => buffer.Properties)
            .Returns(properties);
            var provider = new LegacyTextBufferCodeDocumentProvider();

            // Act
            var result = provider.TryGetFromBuffer(textBuffer.Object, out var codeDocument);

            // Assert
            Assert.False(result);
            Assert.Null(codeDocument);
        }