/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Features/TestUtilities/SolutionExplorer/AbstractSolutionExplorerSymbolTreeItemProviderTests.cs
46 строк
2 KB
Jared Parsons
Port remaining unit test projects to Linux (#83153)
17 апр 2026, 19:00
Не верифицирован
17 апр 2026, 19:00
8b511b9
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SolutionExplorer; using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Test.Utilities.SolutionExplorer; public abstract class AbstractSolutionExplorerSymbolTreeItemProviderTests { protected abstract TestWorkspace CreateWorkspace(string code); protected async Task TestNode<TNode>( string code, string expected, bool returnNamespaces = false) where TNode : SyntaxNode { using var workspace = CreateWorkspace(code); var testDocument = workspace.Documents.Single(); var document = workspace.CurrentSolution.Projects.Single().Documents.Single(); var root = await document.GetRequiredSyntaxRootAsync(CancellationToken.None); var service = document.GetRequiredLanguageService<ISolutionExplorerSymbolTreeItemProvider>(); var node = root.DescendantNodesAndSelf().OfType<TNode>().First(); var diagnostics = node.GetDiagnostics(); Assert.Empty(diagnostics); var items = service.GetItems(document.Id, node, returnNamespaces, CancellationToken.None); var actual = string.Join("\r\n", items); AssertEx.SequenceEqual( expected.Trim().Split(["\r\n", "\n"], StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()), items.Select(i => i.ToString())); AssertEx.SequenceEqual( testDocument.SelectedSpans, items.Select(i => i.ItemSyntax.NavigationToken.Span)); } }