Repository navigation
Expand file tree
/
Copy pathDocumentSymbolHandlerTests.cs
More file actions
94 lines (79 loc) · 3.37 KB
/
Copy pathDocumentSymbolHandlerTests.cs
File metadata and controls
94 lines (79 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.PowerShell.EditorServices.Handlers;
using Microsoft.PowerShell.EditorServices.Services;
using Microsoft.PowerShell.EditorServices.Test.Shared;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using Xunit;
namespace PowerShellEditorServices.Test.Language
{
[Trait("Category", "Symbols")]
public class DocumentSymbolHandlerTests
{
private readonly WorkspaceService workspace;
private readonly ConfigurationService configuration;
private readonly PsesDocumentSymbolHandler documentSymbolHandler;
public DocumentSymbolHandlerTests()
{
workspace = new WorkspaceService(NullLoggerFactory.Instance);
configuration = new ConfigurationService();
documentSymbolHandler = new PsesDocumentSymbolHandler(
NullLoggerFactory.Instance,
workspace,
configuration);
}
[Fact]
public async Task ExcludesParametersWhenParameterOutlineIsDisabled()
{
configuration.CurrentSettings.EnableParameterOutline = false;
string filePath = TestUtilities.GetSharedPath(
"Symbols/DocumentSymbolParameters.ps1");
SymbolInformationOrDocumentSymbolContainer result =
await documentSymbolHandler.Handle(
new DocumentSymbolParams
{
TextDocument = new TextDocumentIdentifier(
DocumentUri.FromFileSystemPath(filePath))
},
CancellationToken.None);
DocumentSymbol function = result
.Select(symbol => symbol.DocumentSymbol)
.Single(symbol => symbol.Name.Contains("New-MyFunc"));
Assert.DoesNotContain(
function.Children,
symbol => symbol.Name.Contains("$MyString"));
Assert.DoesNotContain(
function.Children,
symbol => symbol.Name.Contains("$MyLooselyTypedParam"));
}
[Fact]
public async Task IncludesParametersWhenParameterOutlineIsEnabled()
{
configuration.CurrentSettings.EnableParameterOutline = true;
string filePath = TestUtilities.GetSharedPath(
"Symbols/DocumentSymbolParameters.ps1");
SymbolInformationOrDocumentSymbolContainer result =
await documentSymbolHandler.Handle(
new DocumentSymbolParams
{
TextDocument = new TextDocumentIdentifier(
DocumentUri.FromFileSystemPath(filePath))
},
CancellationToken.None);
DocumentSymbol function = result
.Select(symbol => symbol.DocumentSymbol)
.Single(symbol => symbol.Name.Contains("New-MyFunc"));
Assert.Contains(
function.Children,
symbol => symbol.Name.Contains("$MyString"));
Assert.Contains(
function.Children,
symbol => symbol.Name.Contains("$MyLooselyTypedParam"));
}
}
}