public async Task MapSpans_WithinRange_ReturnsMapping()
        {
            // Arrange
            var called = false;

            var textSpan = new TextSpan(1, 10);
            var spans    = new TextSpan[] { textSpan };

            var documentSnapshot = new Mock <LSPDocumentSnapshot>();

            documentSnapshot.SetupGet(doc => doc.Uri).Returns(MockDocumentUri);

            var textSnapshot = new StringTextSnapshot(MockGeneratedContent, 1);

            var textSpanAsRange = textSpan.AsLSPRange(SourceTextGenerated);
            var mappedRange     = new Range()
            {
                Start = new Position(2, 1),
                End   = new Position(2, 11)
            };

            var documentMappingProvider = new Mock <LSPDocumentMappingProvider>();
            var mappingResult           = new RazorMapToDocumentRangesResponse()
            {
                Ranges = new Range[] { mappedRange }
            };

            documentMappingProvider.Setup(dmp => dmp.MapToDocumentRangesAsync(It.IsAny <RazorLanguageKind>(), It.IsAny <Uri>(), It.IsAny <Range[]>(), It.IsAny <CancellationToken>()))
            .Callback <RazorLanguageKind, Uri, Range[], CancellationToken>((languageKind, Uri, ranges, ct) =>
            {
                Assert.Equal(RazorLanguageKind.CSharp, languageKind);
                Assert.Equal(MockDocumentUri, Uri);
                Assert.Single(ranges, textSpanAsRange);
                called = true;
            })
            .Returns(Task.FromResult(mappingResult));

            var service = new CSharpSpanMappingService(documentMappingProvider.Object, documentSnapshot.Object, textSnapshot);

            var expectedSpan         = mappedRange.AsTextSpan(SourceTextRazor);
            var expectedLinePosition = SourceTextRazor.Lines.GetLinePositionSpan(expectedSpan);
            var expectedFilePath     = MockDocumentUri.LocalPath;
            var expectedResult       = (expectedFilePath, expectedLinePosition, expectedSpan);

            // Act
            var result = await service.MapSpansAsyncTest(spans, SourceTextGenerated, SourceTextRazor).ConfigureAwait(false);

            // Assert
            Assert.True(called);
            Assert.Single(result, expectedResult);
        }
        public async Task MapSpans_OutsideRange_ReturnsEmpty()
        {
            // Arrange
            var called = false;

            var textSpan = new TextSpan(10, 10);
            var spans    = new TextSpan[] { textSpan };

            var documentSnapshot = new Mock <LSPDocumentSnapshot>();

            documentSnapshot.SetupGet(doc => doc.Uri).Returns(MockDocumentUri);

            var textSnapshot = new StringTextSnapshot(MockGeneratedContent, 1);

            var textSpanAsRange = textSpan.AsLSPRange(SourceTextGenerated);

            var documentMappingProvider = new Mock <LSPDocumentMappingProvider>();

            documentMappingProvider.Setup(dmp => dmp.MapToDocumentRangesAsync(It.IsAny <RazorLanguageKind>(), It.IsAny <Uri>(), It.IsAny <Range[]>(), It.IsAny <CancellationToken>()))
            .Callback <RazorLanguageKind, Uri, Range[], CancellationToken>((languageKind, Uri, ranges, ct) =>
            {
                Assert.Equal(RazorLanguageKind.CSharp, languageKind);
                Assert.Equal(MockDocumentUri, Uri);
                Assert.Single(ranges, textSpanAsRange);
                called = true;
            })
            .Returns(Task.FromResult <RazorMapToDocumentRangesResponse>(null));

            var service = new CSharpSpanMappingService(documentMappingProvider.Object, documentSnapshot.Object, textSnapshot);

            // Act
            var result = await service.MapSpansAsyncTest(spans, SourceTextGenerated, SourceTextRazor).ConfigureAwait(false);

            // Assert
            Assert.True(called);
            Assert.Empty(result);
        }