public async Task Handle_SimpleComponent_ReturnsResult()
        {
            // Arrange
            int?version = 1;
            var documentVersionCache = Mock.Of <DocumentVersionCache>(
                s => s.TryGetDocumentVersion(It.IsAny <DocumentSnapshot>(), out version) == true,
                MockBehavior.Strict);
            var codeDocument           = TestRazorCodeDocument.Create("<div></div>");
            var documentMappingService = Mock.Of <RazorDocumentMappingService>(
                s => s.GetLanguageKind(codeDocument, It.IsAny <int>()) == RazorLanguageKind.Html, MockBehavior.Strict);

            var componentCodeDocument = TestRazorCodeDocument.Create("<div></div>");
            var droppedUri            = new Uri("file:///c:/path/MyTagHelper.razor");
            var builder = TagHelperDescriptorBuilder.Create("MyTagHelper", "MyAssembly");

            builder.SetTypeNameIdentifier("MyTagHelper");
            var tagHelperDescriptor = builder.Build();

            var uri = new Uri("file://path/test.razor");
            var documentResolver = CreateDocumentResolver(uri.GetAbsoluteOrUNCPath(), codeDocument, droppedUri.GetAbsoluteOrUNCPath(), componentCodeDocument);
            var searchEngine     = Mock.Of <RazorComponentSearchEngine>(
                s => s.TryGetTagHelperDescriptorAsync(It.IsAny <DocumentSnapshot>(), It.IsAny <CancellationToken>()) == Task.FromResult(tagHelperDescriptor),
                MockBehavior.Strict);

            var languageServer = new Mock <ClientNotifierServiceBase>(MockBehavior.Strict);

            var endpoint = new TextDocumentUriPresentationEndpoint(
                Dispatcher,
                documentResolver,
                documentMappingService,
                searchEngine,
                languageServer.Object,
                documentVersionCache,
                TestLanguageServerFeatureOptions.Instance,
                LoggerFactory);

            var parameters = new UriPresentationParams()
            {
                TextDocument = new TextDocumentIdentifier
                {
                    Uri = uri
                },
                Range = new Range
                {
                    Start = new Position(0, 1),
                    End   = new Position(0, 2)
                },
                Uris = new[]
                {
                    droppedUri
                }
            };

            // Act
            var result = await endpoint.Handle(parameters, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal("<MyTagHelper />", result !.DocumentChanges !.Value.First[0].Edits[0].NewText);
        }
        public async Task Handle_UnsupportedCodeDocument_ReturnsNull()
        {
            // Arrange
            int?version = 1;
            var documentVersionCache = Mock.Of <DocumentVersionCache>(
                s => s.TryGetDocumentVersion(It.IsAny <DocumentSnapshot>(), out version) == true,
                MockBehavior.Strict);
            var codeDocument = TestRazorCodeDocument.Create("<div></div>");

            codeDocument.SetUnsupported();
            var uri = new Uri("file://path/test.razor");
            var documentResolver       = CreateDocumentResolver(uri.GetAbsoluteOrUNCPath(), codeDocument);
            var documentMappingService = Mock.Of <RazorDocumentMappingService>(
                s => s.GetLanguageKind(codeDocument, It.IsAny <int>()) == RazorLanguageKind.Html, MockBehavior.Strict);
            var searchEngine = Mock.Of <RazorComponentSearchEngine>(MockBehavior.Strict);

            var responseRouterReturns = new Mock <IResponseRouterReturns>(MockBehavior.Strict);

            responseRouterReturns
            .Setup(l => l.Returning <WorkspaceEdit?>(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new WorkspaceEdit());

            var languageServer = new Mock <ClientNotifierServiceBase>(MockBehavior.Strict);

            languageServer
            .Setup(l => l.SendRequestAsync(LanguageServerConstants.RazorUriPresentationEndpoint, It.IsAny <IRazorPresentationParams>()))
            .ReturnsAsync(responseRouterReturns.Object);

            var endpoint = new TextDocumentUriPresentationEndpoint(
                Dispatcher,
                documentResolver,
                documentMappingService,
                searchEngine,
                languageServer.Object,
                documentVersionCache,
                TestLanguageServerFeatureOptions.Instance,
                LoggerFactory);

            var parameters = new UriPresentationParams()
            {
                TextDocument = new TextDocumentIdentifier
                {
                    Uri = uri
                },
                Range = new Range
                {
                    Start = new Position(0, 1),
                    End   = new Position(0, 2)
                }
            };

            // Act
            var result = await endpoint.Handle(parameters, CancellationToken.None);

            // Assert
            Assert.Null(result);
        }