DiagnosticsHandlerTests.cs 1.3 KB
Newer Older
D
David Barbet 已提交
1 2 3 4 5
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System;
using System.Linq;
using System.Threading.Tasks;
D
tests.  
David Barbet 已提交
6
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
D
Dayton Ellwanger 已提交
7
using Microsoft.VisualStudio.LanguageServices.LiveShare.Protocol;
D
David Barbet 已提交
8
using Xunit;
D
tests.  
David Barbet 已提交
9
using LSP = Microsoft.VisualStudio.LanguageServer.Protocol;
D
David Barbet 已提交
10

11
namespace Microsoft.VisualStudio.LanguageServices.LiveShare.UnitTests
D
David Barbet 已提交
12
{
D
tests.  
David Barbet 已提交
13
    public class DiagnosticsHandlerTests : AbstractLiveShareRequestHandlerTests
D
David Barbet 已提交
14
    {
D
David Barbet 已提交
15
        [Fact(Skip = "Need easy way to export analyzers for testing.")]
D
David Barbet 已提交
16 17 18 19 20 21 22
        public async Task TestDiagnosticsAsync()
        {
            var markup =
@"class A
{
    void M()
    {
D
tests.  
David Barbet 已提交
23
        {|diagnostic:var|} i = 1;
D
David Barbet 已提交
24 25 26
    }
}";
            var (solution, ranges) = CreateTestSolution(markup);
D
tests.  
David Barbet 已提交
27 28
            var workspace = (TestWorkspace)solution.Workspace;

D
David Barbet 已提交
29 30
            var diagnosticLocation = ranges["diagnostic"].First();

D
David Barbet 已提交
31
            var _ = await TestHandleAsync<TextDocumentParams, LSP.Diagnostic[]>(solution, CreateTestDocumentParams(diagnosticLocation.Uri));
D
David Barbet 已提交
32 33 34 35 36 37 38 39 40
        }

        private static TextDocumentParams CreateTestDocumentParams(Uri uri)
            => new TextDocumentParams()
            {
                TextDocument = CreateTextDocumentIdentifier(uri)
            };
    }
}