/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/EditorFeatures/TestUtilities/ReassignedVariable/AbstractReassignedVariableTests.cs
45 строк
2 KB
Tomáš Matoušek
Move TestWorkspace to Workspace test layer, add EditorTestWorkspace to EditorFeatures layer (#71407)
09 янв 2024, 18:51
Не верифицирован
09 янв 2024, 18:51
3157d16
Код
Авторство
О чём код?
// 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.Collections.Immutable; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.ReassignedVariable; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Xunit; namespace Microsoft.CodeAnalysis.Editor.UnitTests.ReassignedVariable; [UseExportProvider] public abstract class AbstractReassignedVariableTests { protected abstract EditorTestWorkspace CreateWorkspace(string markup); protected async Task TestAsync(string markup) { using var workspace = CreateWorkspace(markup); var project = workspace.CurrentSolution.Projects.Single(); var language = project.Language; var documents = project.Documents.ToImmutableArray(); for (var i = 0; i < documents.Length; i++) { var document = documents[i]; var text = await document.GetTextAsync(); var service = document.GetRequiredLanguageService<IReassignedVariableService>(); var textSpans = ImmutableArray.Create(new TextSpan(0, text.Length)); var result = await service.GetLocationsAsync(document, textSpans, CancellationToken.None); var expectedSpans = workspace.Documents[i].SelectedSpans.OrderBy(s => s.Start); var actualSpans = result.OrderBy(s => s.Start); Assert.Equal(expectedSpans, actualSpans); } } }