提交 b61d04d1 编写于 作者: C Cyrus Najmabadi

Make more tests async.

上级 fab93a0f
......@@ -110,7 +110,7 @@ protected async Task NotSupported_ExtractMethodAsync(string codeWithMarker)
var semanticDocument = await SemanticDocument.CreateAsync(document, CancellationToken.None);
var validator = new CSharpSelectionValidator(semanticDocument, testDocument.SelectedSpans.Single(), options);
var selectedCode = validator.GetValidSelectionAsync(CancellationToken.None).Result;
var selectedCode = await validator.GetValidSelectionAsync(CancellationToken.None);
if (!succeed && selectedCode.Status.FailedWithNoBestEffortSuggestion())
{
return null;
......
......@@ -17,7 +17,7 @@ protected async Task CheckAsync(string initial, string final, bool specialCaseSy
using (var workspace = await CSharpWorkspaceFactory.CreateWorkspaceFromFileAsync(initial))
{
var document = workspace.CurrentSolution.GetDocument(workspace.Documents.First().Id);
var newRoot = OrganizeImportsService.OrganizeImportsAsync(document, specialCaseSystem).Result.GetSyntaxRootAsync().Result;
var newRoot = await (await OrganizeImportsService.OrganizeImportsAsync(document, specialCaseSystem)).GetSyntaxRootAsync();
Assert.Equal(final.NormalizeLineEndings(), newRoot.ToFullString());
}
}
......
......@@ -21,7 +21,7 @@ private async Task TestAsync(string fileContents, params OutliningSpan[] expecte
var workspace = await TestWorkspaceFactory.CreateWorkspaceFromFilesAsync(WorkspaceKind.MetadataAsSource, LanguageNames.CSharp, null, null, fileContents);
var outliningService = workspace.Services.GetLanguageServices(LanguageNames.CSharp).GetService<IOutliningService>();
var document = workspace.CurrentSolution.Projects.Single().Documents.Single();
var actualOutliningSpans = outliningService.GetOutliningSpansAsync(document, CancellationToken.None).Result.Where(s => s != null).ToArray();
var actualOutliningSpans = (await outliningService.GetOutliningSpansAsync(document, CancellationToken.None)).Where(s => s != null).ToArray();
Assert.Equal(expectedSpans.Length, actualOutliningSpans.Length);
for (int i = 0; i < expectedSpans.Length; i++)
......
......@@ -114,7 +114,7 @@ private async Task VerifyWithMscorlib45Async(string markup, Action<object>[] exp
workspace.GetService<IGlyphService>(),
workspace.GetService<ClassificationTypeMap>());
var state = provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None).Result;
var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
if (state != null)
{
WaitForDocumentationComment(state.Content);
......@@ -271,7 +271,7 @@ private async Task VerifyWithReferenceWorkerAsync(string xmlString, params Actio
workspace.GetService<IGlyphService>(),
workspace.GetService<ClassificationTypeMap>());
var state = provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None).Result;
var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
if (state != null)
{
WaitForDocumentationComment(state.Content);
......
......@@ -286,16 +286,16 @@ private IQuickInfoProvider CreateProvider(TestWorkspace workspace)
workspace.GetService<ClassificationTypeMap>());
}
protected override void AssertNoContent(
protected override async Task AssertNoContentAsync(
TestWorkspace workspace,
Document document,
int position)
{
var provider = CreateProvider(workspace);
Assert.Null(provider.GetItemAsync(document, position, CancellationToken.None).Result);
Assert.Null(await provider.GetItemAsync(document, position, CancellationToken.None));
}
protected override void AssertContentIs(
protected override async Task AssertContentIsAsync(
TestWorkspace workspace,
Document document,
int position,
......@@ -303,7 +303,7 @@ private IQuickInfoProvider CreateProvider(TestWorkspace workspace)
string expectedDocumentationComment = null)
{
var provider = CreateProvider(workspace);
var state = provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None).Result;
var state = await provider.GetItemAsync(document, position, cancellationToken: CancellationToken.None);
Assert.NotNull(state);
var viewHostingControl = (ViewHostingControl)((ElisionBufferDeferredContent)state.Content).Create();
......@@ -347,11 +347,11 @@ protected override Task TestInScriptAsync(string code, string expectedContent, s
if (string.IsNullOrEmpty(expectedContent))
{
AssertNoContent(workspace, document, position);
await AssertNoContentAsync(workspace, document, position);
}
else
{
AssertContentIs(workspace, document, position, expectedContent, expectedDocumentationComment);
await AssertContentIsAsync(workspace, document, position, expectedContent, expectedDocumentationComment);
}
}
}
......
......@@ -19,11 +19,11 @@ private async Task TestDelegateAsync(string text, string expectedType)
Document document = await fixture.UpdateDocumentAsync(text, SourceCodeKind.Regular);
var root = document.GetSyntaxTreeAsync().Result.GetRoot();
var root = (await document.GetSyntaxTreeAsync()).GetRoot();
var node = FindExpressionSyntaxFromSpan(root, textSpan);
var typeInference = document.GetLanguageService<ITypeInferenceService>();
var delegateType = typeInference.InferDelegateType(document.GetSemanticModelAsync().Result, node, CancellationToken.None);
var delegateType = typeInference.InferDelegateType(await document.GetSemanticModelAsync(), node, CancellationToken.None);
Assert.NotNull(delegateType);
Assert.Equal(expectedType, delegateType.ToNameDisplayString());
......
......@@ -27,8 +27,8 @@ protected override async Task TestWorkerAsync(Document document, TextSpan textSp
var typeInference = document.GetLanguageService<ITypeInferenceService>();
var inferredType = useNodeStartPosition
? typeInference.InferType(document.GetSemanticModelForSpanAsync(new TextSpan(node?.SpanStart ?? textSpan.Start, 0), CancellationToken.None).Result, node?.SpanStart ?? textSpan.Start, objectAsDefault: true, cancellationToken: CancellationToken.None)
: typeInference.InferType(document.GetSemanticModelForSpanAsync(node?.Span ?? textSpan, CancellationToken.None).Result, node, objectAsDefault: true, cancellationToken: CancellationToken.None);
? typeInference.InferType(await document.GetSemanticModelForSpanAsync(new TextSpan(node?.SpanStart ?? textSpan.Start, 0), CancellationToken.None), node?.SpanStart ?? textSpan.Start, objectAsDefault: true, cancellationToken: CancellationToken.None)
: typeInference.InferType(await document.GetSemanticModelForSpanAsync(node?.Span ?? textSpan, CancellationToken.None), node, objectAsDefault: true, cancellationToken: CancellationToken.None);
var typeSyntax = inferredType.GenerateTypeSyntax();
Assert.Equal(expectedType, typeSyntax.ToString());
}
......
......@@ -44,12 +44,12 @@ protected async Task TestInMethodAndScriptAsync(string code, string expectedCont
string expectedDocumentationComment = null,
CSharpParseOptions parseOptions = null);
protected abstract void AssertNoContent(
protected abstract Task AssertNoContentAsync(
TestWorkspace workspace,
Document document,
int position);
protected abstract void AssertContentIs(
protected abstract Task AssertContentIsAsync(
TestWorkspace workspace,
Document document,
int position,
......
......@@ -38,7 +38,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Editting
Dim doc = GetDocument(initialText, globalImports)
options = If(options, doc.Project.Solution.Workspace.Options)
Dim imported = ImportAdder.AddImportsAsync(doc, options).Result
Dim imported = Await ImportAdder.AddImportsAsync(doc, options)
If importsAddedText IsNot Nothing Then
Dim formatted = Await Formatter.FormatAsync(imported, SyntaxAnnotation.ElasticAnnotation, options)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册