提交 bdc047b6 编写于 作者: J Jared Parsons

Remove PumpingWait

This removes PumpingWait from our test infrastructure and replaces it with proper await calls on the Task(s) in question.
上级 260090e0
......@@ -43,13 +43,6 @@ public static EventHookupTestState CreateTestState(string markup)
return new EventHookupTestState(XElement.Parse(workspaceXml));
}
public void WaitForAsyncOperations()
{
var waiters = this.Workspace.ExportProvider.GetExportedValues<IAsynchronousOperationWaiter>();
var tasks = waiters.Select(w => w.CreateWaitTask()).ToList();
tasks.PumpingWaitAll();
}
internal void AssertShowing(string expectedText)
{
Assert.NotNull(_commandHandler.EventHookupSessionManager.QuickInfoSession);
......
......@@ -270,13 +270,6 @@ public async Task WaitForAsynchronousOperationsAsync()
await waiters.WaitAllAsync().ConfigureAwait(true);
}
public void WaitForAsynchronousOperations()
{
var waiters = Workspace.ExportProvider.GetExportedValues<IAsynchronousOperationWaiter>();
var tasks = waiters.Select(w => w.CreateWaitTask()).ToList();
tasks.PumpingWaitAll();
}
public void AssertMatchesTextStartingAtLine(int line, string text)
{
var lines = text.Split('\r');
......
......@@ -826,9 +826,9 @@ private void TouchEverything(Solution solution)
{
foreach (var document in project.Documents)
{
document.GetTextAsync().PumpingWait();
document.GetSyntaxRootAsync().PumpingWait();
document.GetSemanticModelAsync().PumpingWait();
document.GetTextAsync().Wait();
document.GetSyntaxRootAsync().Wait();
document.GetSemanticModelAsync().Wait();
}
}
}
......
......@@ -27,7 +27,7 @@ public override void Execute() {
state.SendTypeChars(".Curr")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(displayText:="CurrentDomain")
Await state.AssertSelectedCompletionItem(displayText:="CurrentDomain").ConfigureAwait(True)
state.SendTab()
Assert.Contains("__o = AppDomain.CurrentDomain", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
End Using
......@@ -68,7 +68,7 @@ class C
state.SendTypeCharsToSpecificViewAndBuffer("Cons", view, buffer)
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(displayText:="Console")
Await state.AssertSelectedCompletionItem(displayText:="Console").ConfigureAwait(True)
End Using
End Function
......@@ -104,7 +104,7 @@ class C
state.SendTypeCharsToSpecificViewAndBuffer(" ", view, buffer)
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(displayText:="string", isHardSelected:=True)
Await state.AssertSelectedCompletionItem(displayText:="string", isHardSelected:=True).ConfigureAwait(True)
End Using
End Function
......@@ -141,7 +141,7 @@ class C
state.SendTypeCharsToSpecificViewAndBuffer("#reg", view, buffer)
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(displayText:="region", shouldFormatOnCommit:=True)
Await state.AssertSelectedCompletionItem(displayText:="region", shouldFormatOnCommit:=True).ConfigureAwait(True)
End Using
End Function
......
......@@ -237,12 +237,12 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
Function(i) i.DisplayText = v))
End Function
Public Sub AssertSelectedCompletionItem(Optional displayText As String = Nothing,
Public Async Function AssertSelectedCompletionItem(Optional displayText As String = Nothing,
Optional description As String = Nothing,
Optional isSoftSelected As Boolean? = Nothing,
Optional isHardSelected As Boolean? = Nothing,
Optional shouldFormatOnCommit As Boolean? = Nothing)
WaitForAsynchronousOperations()
Optional shouldFormatOnCommit As Boolean? = Nothing) As Task
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
If isSoftSelected.HasValue Then
Assert.Equal(isSoftSelected.Value, Me.CurrentCompletionPresenterSession.IsSoftSelected)
End If
......@@ -268,7 +268,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
If description IsNot Nothing Then
Assert.Equal(description, Me.CurrentCompletionPresenterSession.SelectedItem.GetDescriptionAsync().Result.GetFullText())
End If
End Sub
End Function
#End Region
......@@ -310,11 +310,6 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
MyBase.SendInvokeSignatureHelp(Sub(a, n) handler.ExecuteCommand(a, n), Sub() Return)
End Sub
Public Sub SendSelectSignatureHelpItemThroughPresenterSession(item As SignatureHelpItem)
WaitForAsynchronousOperations()
CurrentSignatureHelpPresenterSession.SetSelectedItem(item)
End Sub
Public Async Function AssertNoSignatureHelpSession(Optional block As Boolean = True) As Task
If block Then
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
......@@ -347,13 +342,13 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
End Function
Public Function SignatureHelpItemsContainsAll(displayText As String()) As Boolean
WaitForAsynchronousOperations()
AssertNoAsynchronousOperationsRunning()
Return displayText.All(Function(v) CurrentSignatureHelpPresenterSession.SignatureHelpItems.Any(
Function(i) GetDisplayText(i, CurrentSignatureHelpPresenterSession.SelectedParameter.Value) = v))
End Function
Public Function SignatureHelpItemsContainsAny(displayText As String()) As Boolean
WaitForAsynchronousOperations()
AssertNoAsynchronousOperationsRunning()
Return displayText.Any(Function(v) CurrentSignatureHelpPresenterSession.SignatureHelpItems.Any(
Function(i) GetDisplayText(i, CurrentSignatureHelpPresenterSession.SelectedParameter.Value) = v))
End Function
......
......@@ -36,7 +36,7 @@ End Namespace
Await state.AssertCompletionSession().ConfigureAwait(True)
state.SendTypeChars("Curr")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(displayText:="CurrentDomain")
Await state.AssertSelectedCompletionItem(displayText:="CurrentDomain").ConfigureAwait(True)
state.SendTab()
Assert.Contains("__o = AppDomain.CurrentDomain", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
End Using
......@@ -75,7 +75,7 @@ End Class
state.SendTypeCharsToSpecificViewAndBuffer("Cons", view, buffer)
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(displayText:="Console")
Await state.AssertSelectedCompletionItem(displayText:="Console").ConfigureAwait(True)
End Using
End Function
......@@ -112,7 +112,7 @@ End Class
state.SendTypeCharsToSpecificViewAndBuffer("Str", view, buffer)
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(displayText:="String", isHardSelected:=True)
Await state.AssertSelectedCompletionItem(displayText:="String", isHardSelected:=True).ConfigureAwait(True)
End Using
End Function
End Class
......
......@@ -13,67 +13,10 @@ namespace Roslyn.Test.Utilities
{
public static class WaitHelper
{
/// <summary>
/// This is a hueristic for checking to see if we are in a deadlock state because
/// we are waiting on a Task that may be in the StaTaskScheduler queue from the
/// main thread.
/// </summary>
/// <param name="tasks"></param>
private static void CheckForStaDeadlockInPumpingWait(IEnumerable<Task> tasks)
{
var sta = StaTaskScheduler.DefaultSta;
Debug.Assert(sta.Threads.Length == 1);
if (Thread.CurrentThread != sta.Threads[0])
{
return;
}
if (tasks.Any(x => x.Status == TaskStatus.WaitingForActivation) && sta.IsAnyQueued())
{
throw new InvalidOperationException("PumingWait is likely in a deadlock");
}
}
public static void WaitForDispatchedOperationsToComplete(DispatcherPriority priority)
{
Action action = delegate { };
new FrameworkElement().Dispatcher.Invoke(action, priority);
}
public static void PumpingWait(this Task task)
{
PumpingWaitAll(new[] { task });
}
public static T PumpingWaitResult<T>(this Task<T> task)
{
PumpingWait(task);
return task.Result;
}
public static void PumpingWaitAll(this IEnumerable<Task> tasks)
{
var smallTimeout = TimeSpan.FromMilliseconds(10);
var taskArray = tasks.ToArray();
var done = false;
while (!done)
{
done = Task.WaitAll(taskArray, smallTimeout);
if (!done)
{
WaitForDispatchedOperationsToComplete(DispatcherPriority.ApplicationIdle);
CheckForStaDeadlockInPumpingWait(tasks);
}
}
foreach (var task in tasks)
{
if (task.Exception != null)
{
throw task.Exception;
}
}
}
}
}
// 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.Threading.Tasks;
using Microsoft.VisualStudio.Text;
using Roslyn.Test.Utilities;
using Xunit;
......@@ -39,24 +40,24 @@ private void SetActiveCode(string text)
}
}
private void InsertAndExecuteInputs(params string[] inputs)
private async Task InsertAndExecuteInputs(params string[] inputs)
{
foreach (var input in inputs)
{
InsertAndExecuteInput(input);
await InsertAndExecuteInput(input).ConfigureAwait(true);
}
}
private void InsertAndExecuteInput(string input)
private async Task InsertAndExecuteInput(string input)
{
_window.InsertCode(input);
AssertCurrentSubmission(input);
ExecuteInput();
await ExecuteInput().ConfigureAwait(true);
}
private void ExecuteInput()
private async Task ExecuteInput()
{
((InteractiveWindow)_window).ExecuteInputAsync().PumpingWait();
await ((InteractiveWindow)_window).ExecuteInputAsync().ConfigureAwait(true);
}
private void AssertCurrentSubmission(string expected)
......@@ -67,22 +68,22 @@ private void AssertCurrentSubmission(string expected)
#endregion Helpers
[WpfFact]
public void CheckHistoryPrevious()
public async Task CheckHistoryPrevious()
{
const string inputString = "1 ";
InsertAndExecuteInput(inputString);
await InsertAndExecuteInput(inputString).ConfigureAwait(true);
_operations.HistoryPrevious();
AssertCurrentSubmission(inputString);
}
[WpfFact]
public void CheckHistoryPreviousNotCircular()
public async Task CheckHistoryPreviousNotCircular()
{
//submit, submit, up, up, up
const string inputString1 = "1 ";
const string inputString2 = "2 ";
InsertAndExecuteInput(inputString1);
InsertAndExecuteInput(inputString2);
await InsertAndExecuteInput(inputString1).ConfigureAwait(true);
await InsertAndExecuteInput(inputString2).ConfigureAwait(true);
_operations.HistoryPrevious();
AssertCurrentSubmission(inputString2);
......@@ -94,16 +95,16 @@ public void CheckHistoryPreviousNotCircular()
}
[WpfFact]
public void CheckHistoryPreviousAfterSubmittingEntryFromHistory()
public async Task CheckHistoryPreviousAfterSubmittingEntryFromHistory()
{
//submit, submit, submit, up, up, submit, up, up, up
const string inputString1 = "1 ";
const string inputString2 = "2 ";
const string inputString3 = "3 ";
InsertAndExecuteInput(inputString1);
InsertAndExecuteInput(inputString2);
InsertAndExecuteInput(inputString3);
await InsertAndExecuteInput(inputString1).ConfigureAwait(true);
await InsertAndExecuteInput(inputString2).ConfigureAwait(true);
await InsertAndExecuteInput(inputString3).ConfigureAwait(true);
_operations.HistoryPrevious();
AssertCurrentSubmission(inputString3);
......@@ -111,7 +112,7 @@ public void CheckHistoryPreviousAfterSubmittingEntryFromHistory()
_operations.HistoryPrevious();
AssertCurrentSubmission(inputString2);
ExecuteInput();
await ExecuteInput().ConfigureAwait(true);
//history navigation should start from the last history pointer
_operations.HistoryPrevious();
......@@ -126,15 +127,15 @@ public void CheckHistoryPreviousAfterSubmittingEntryFromHistory()
}
[WpfFact]
public void CheckHistoryPreviousAfterSubmittingNewEntryWhileNavigatingHistory()
public async Task CheckHistoryPreviousAfterSubmittingNewEntryWhileNavigatingHistory()
{
//submit, submit, up, up, submit new, up, up, up
const string inputString1 = "1 ";
const string inputString2 = "2 ";
const string inputString3 = "3 ";
InsertAndExecuteInput(inputString1);
InsertAndExecuteInput(inputString2);
await InsertAndExecuteInput(inputString1).ConfigureAwait(true);
await InsertAndExecuteInput(inputString2).ConfigureAwait(true);
_operations.HistoryPrevious();
AssertCurrentSubmission(inputString2);
......@@ -144,7 +145,7 @@ public void CheckHistoryPreviousAfterSubmittingNewEntryWhileNavigatingHistory()
SetActiveCode(inputString3);
AssertCurrentSubmission(inputString3);
ExecuteInput();
await ExecuteInput().ConfigureAwait(true);
//History pointer should be reset. Previous should now bring up last entry
_operations.HistoryPrevious();
......@@ -162,14 +163,14 @@ public void CheckHistoryPreviousAfterSubmittingNewEntryWhileNavigatingHistory()
}
[WpfFact]
public void CheckHistoryNextNotCircular()
public async Task CheckHistoryNextNotCircular()
{
//submit, submit, down, up, down, down
const string inputString1 = "1 ";
const string inputString2 = "2 ";
const string empty = "";
InsertAndExecuteInput(inputString1);
InsertAndExecuteInput(inputString2);
await InsertAndExecuteInput(inputString1).ConfigureAwait(true);
await InsertAndExecuteInput(inputString2).ConfigureAwait(true);
//Next should do nothing as history pointer is uninitialized and there is
//no next entry. Buffer should be empty
......@@ -190,21 +191,21 @@ public void CheckHistoryNextNotCircular()
AssertCurrentSubmission(inputString2);
//This is to make sure the window doesn't crash
ExecuteInput();
await ExecuteInput().ConfigureAwait(true);
AssertCurrentSubmission(empty);
}
[WpfFact]
public void CheckHistoryNextAfterSubmittingEntryFromHistory()
public async Task CheckHistoryNextAfterSubmittingEntryFromHistory()
{
//submit, submit, submit, up, up, submit, down, down, down
const string inputString1 = "1 ";
const string inputString2 = "2 ";
const string inputString3 = "3 ";
InsertAndExecuteInput(inputString1);
InsertAndExecuteInput(inputString2);
InsertAndExecuteInput(inputString3);
await InsertAndExecuteInput(inputString1).ConfigureAwait(true);
await InsertAndExecuteInput(inputString2).ConfigureAwait(true);
await InsertAndExecuteInput(inputString3).ConfigureAwait(true);
_operations.HistoryPrevious();
AssertCurrentSubmission(inputString3);
......@@ -213,7 +214,7 @@ public void CheckHistoryNextAfterSubmittingEntryFromHistory()
AssertCurrentSubmission(inputString2);
//submit inputString2 again. Should be added at the end of history
ExecuteInput();
await ExecuteInput().ConfigureAwait(true);
//history navigation should start from the last history pointer
_operations.HistoryNext();
......@@ -229,7 +230,7 @@ public void CheckHistoryNextAfterSubmittingEntryFromHistory()
}
[WpfFact]
public void CheckHistoryNextAfterSubmittingNewEntryWhileNavigatingHistory()
public async Task CheckHistoryNextAfterSubmittingNewEntryWhileNavigatingHistory()
{
//submit, submit, up, up, submit new, down, up
const string inputString1 = "1 ";
......@@ -237,8 +238,8 @@ public void CheckHistoryNextAfterSubmittingNewEntryWhileNavigatingHistory()
const string inputString3 = "3 ";
const string empty = "";
InsertAndExecuteInput(inputString1);
InsertAndExecuteInput(inputString2);
await InsertAndExecuteInput(inputString1).ConfigureAwait(true);
await InsertAndExecuteInput(inputString2).ConfigureAwait(true);
_operations.HistoryPrevious();
AssertCurrentSubmission(inputString2);
......@@ -248,7 +249,7 @@ public void CheckHistoryNextAfterSubmittingNewEntryWhileNavigatingHistory()
SetActiveCode(inputString3);
AssertCurrentSubmission(inputString3);
ExecuteInput();
await ExecuteInput().ConfigureAwait(true);
//History pointer should be reset. next should do nothing
_operations.HistoryNext();
......@@ -259,15 +260,15 @@ public void CheckHistoryNextAfterSubmittingNewEntryWhileNavigatingHistory()
}
[WpfFact]
public void CheckUncommittedInputAfterNavigatingHistory()
public async Task CheckUncommittedInputAfterNavigatingHistory()
{
//submit, submit, up, up, submit new, down, up
const string inputString1 = "1 ";
const string inputString2 = "2 ";
const string uncommittedInput = "uncommittedInput";
InsertAndExecuteInput(inputString1);
InsertAndExecuteInput(inputString2);
await InsertAndExecuteInput(inputString1).ConfigureAwait(true);
await InsertAndExecuteInput(inputString2).ConfigureAwait(true);
//Add uncommitted input
SetActiveCode(uncommittedInput);
//Navigate history. This should save uncommitted input
......@@ -279,21 +280,21 @@ public void CheckUncommittedInputAfterNavigatingHistory()
}
[WpfFact]
public void CheckHistoryPreviousAfterReset()
public async Task CheckHistoryPreviousAfterReset()
{
const string resetCommand1 = "#reset";
const string resetCommand2 = "#reset ";
InsertAndExecuteInput(resetCommand1);
InsertAndExecuteInput(resetCommand2);
await InsertAndExecuteInput(resetCommand1).ConfigureAwait(true);
await InsertAndExecuteInput(resetCommand2).ConfigureAwait(true);
_operations.HistoryPrevious(); AssertCurrentSubmission(resetCommand2);
_operations.HistoryPrevious(); AssertCurrentSubmission(resetCommand1);
_operations.HistoryPrevious(); AssertCurrentSubmission(resetCommand1);
}
[WpfFact]
public void TestHistoryPrevious()
public async Task TestHistoryPrevious()
{
InsertAndExecuteInputs("1", "2", "3");
await InsertAndExecuteInputs("1", "2", "3").ConfigureAwait(true);
_operations.HistoryPrevious(); AssertCurrentSubmission("3");
_operations.HistoryPrevious(); AssertCurrentSubmission("2");
......@@ -303,9 +304,9 @@ public void TestHistoryPrevious()
}
[WpfFact]
public void TestHistoryNext()
public async Task TestHistoryNext()
{
InsertAndExecuteInputs("1", "2", "3");
await InsertAndExecuteInputs("1", "2", "3").ConfigureAwait(true);
SetActiveCode("4");
......@@ -322,18 +323,18 @@ public void TestHistoryNext()
}
[WpfFact]
public void TestHistoryPreviousWithPattern_NoMatch()
public async Task TestHistoryPreviousWithPattern_NoMatch()
{
InsertAndExecuteInputs("123", "12", "1");
await InsertAndExecuteInputs("123", "12", "1").ConfigureAwait(true);
_operations.HistoryPrevious("4"); AssertCurrentSubmission("");
_operations.HistoryPrevious("4"); AssertCurrentSubmission("");
}
[WpfFact]
public void TestHistoryPreviousWithPattern_PatternMaintained()
public async Task TestHistoryPreviousWithPattern_PatternMaintained()
{
InsertAndExecuteInputs("123", "12", "1");
await InsertAndExecuteInputs("123", "12", "1").ConfigureAwait(true);
_operations.HistoryPrevious("12"); AssertCurrentSubmission("12"); // Skip over non-matching entry.
_operations.HistoryPrevious("12"); AssertCurrentSubmission("123");
......@@ -341,9 +342,9 @@ public void TestHistoryPreviousWithPattern_PatternMaintained()
}
[WpfFact]
public void TestHistoryPreviousWithPattern_PatternDropped()
public async Task TestHistoryPreviousWithPattern_PatternDropped()
{
InsertAndExecuteInputs("1", "2", "3");
await InsertAndExecuteInputs("1", "2", "3").ConfigureAwait(true);
_operations.HistoryPrevious("2"); AssertCurrentSubmission("2"); // Skip over non-matching entry.
_operations.HistoryPrevious(null); AssertCurrentSubmission("1"); // Pattern isn't passed, so return to normal iteration.
......@@ -351,9 +352,9 @@ public void TestHistoryPreviousWithPattern_PatternDropped()
}
[WpfFact]
public void TestHistoryPreviousWithPattern_PatternChanged()
public async Task TestHistoryPreviousWithPattern_PatternChanged()
{
InsertAndExecuteInputs("10", "20", "15", "25");
await InsertAndExecuteInputs("10", "20", "15", "25").ConfigureAwait(true);
_operations.HistoryPrevious("1"); AssertCurrentSubmission("15"); // Skip over non-matching entry.
_operations.HistoryPrevious("2"); AssertCurrentSubmission("20"); // Skip over non-matching entry.
......@@ -361,9 +362,9 @@ public void TestHistoryPreviousWithPattern_PatternChanged()
}
[WpfFact]
public void TestHistoryNextWithPattern_NoMatch()
public async Task TestHistoryNextWithPattern_NoMatch()
{
InsertAndExecuteInputs("start", "1", "12", "123");
await InsertAndExecuteInputs("start", "1", "12", "123").ConfigureAwait(true);
SetActiveCode("end");
_operations.HistoryPrevious(); AssertCurrentSubmission("123");
......@@ -376,9 +377,9 @@ public void TestHistoryNextWithPattern_NoMatch()
}
[WpfFact]
public void TestHistoryNextWithPattern_PatternMaintained()
public async Task TestHistoryNextWithPattern_PatternMaintained()
{
InsertAndExecuteInputs("start", "1", "12", "123");
await InsertAndExecuteInputs("start", "1", "12", "123").ConfigureAwait(true);
SetActiveCode("end");
_operations.HistoryPrevious(); AssertCurrentSubmission("123");
......@@ -392,9 +393,9 @@ public void TestHistoryNextWithPattern_PatternMaintained()
}
[WpfFact]
public void TestHistoryNextWithPattern_PatternDropped()
public async Task TestHistoryNextWithPattern_PatternDropped()
{
InsertAndExecuteInputs("start", "3", "2", "1");
await InsertAndExecuteInputs("start", "3", "2", "1").ConfigureAwait(true);
SetActiveCode("end");
_operations.HistoryPrevious(); AssertCurrentSubmission("1");
......@@ -408,9 +409,9 @@ public void TestHistoryNextWithPattern_PatternDropped()
}
[WpfFact]
public void TestHistoryNextWithPattern_PatternChanged()
public async Task TestHistoryNextWithPattern_PatternChanged()
{
InsertAndExecuteInputs("start", "25", "15", "20", "10");
await InsertAndExecuteInputs("start", "25", "15", "20", "10").ConfigureAwait(true);
SetActiveCode("end");
_operations.HistoryPrevious(); AssertCurrentSubmission("10");
......@@ -425,9 +426,9 @@ public void TestHistoryNextWithPattern_PatternChanged()
}
[WpfFact]
public void TestHistorySearchPrevious()
public async Task TestHistorySearchPrevious()
{
InsertAndExecuteInputs("123", "12", "1");
await InsertAndExecuteInputs("123", "12", "1").ConfigureAwait(true);
// Default search string is empty.
_operations.HistorySearchPrevious(); AssertCurrentSubmission("1"); // Pattern is captured before this step.
......@@ -437,9 +438,9 @@ public void TestHistorySearchPrevious()
}
[WpfFact]
public void TestHistorySearchPreviousWithPattern()
public async Task TestHistorySearchPreviousWithPattern()
{
InsertAndExecuteInputs("123", "12", "1");
await InsertAndExecuteInputs("123", "12", "1").ConfigureAwait(true);
SetActiveCode("12");
_operations.HistorySearchPrevious(); AssertCurrentSubmission("12"); // Pattern is captured before this step.
......@@ -448,9 +449,9 @@ public void TestHistorySearchPreviousWithPattern()
}
[WpfFact]
public void TestHistorySearchNextWithPattern()
public async Task TestHistorySearchNextWithPattern()
{
InsertAndExecuteInputs("12", "123", "12", "1");
await InsertAndExecuteInputs("12", "123", "12", "1").ConfigureAwait(true);
SetActiveCode("end");
_operations.HistoryPrevious(); AssertCurrentSubmission("1");
......@@ -464,9 +465,9 @@ public void TestHistorySearchNextWithPattern()
}
[WpfFact]
public void TestHistoryPreviousAndSearchPrevious()
public async Task TestHistoryPreviousAndSearchPrevious()
{
InsertAndExecuteInputs("200", "100", "30", "20", "10", "2", "1");
await InsertAndExecuteInputs("200", "100", "30", "20", "10", "2", "1").ConfigureAwait(true);
_operations.HistoryPrevious(); AssertCurrentSubmission("1");
_operations.HistorySearchPrevious(); AssertCurrentSubmission("10"); // Pattern is captured before this step.
......@@ -478,9 +479,9 @@ public void TestHistoryPreviousAndSearchPrevious()
}
[WpfFact]
public void TestHistoryPreviousAndSearchPrevious_ExplicitPattern()
public async Task TestHistoryPreviousAndSearchPrevious_ExplicitPattern()
{
InsertAndExecuteInputs("200", "100", "30", "20", "10", "2", "1");
await InsertAndExecuteInputs("200", "100", "30", "20", "10", "2", "1").ConfigureAwait(true);
_operations.HistoryPrevious(); AssertCurrentSubmission("1");
_operations.HistorySearchPrevious(); AssertCurrentSubmission("10"); // Pattern is captured before this step.
......@@ -492,9 +493,9 @@ public void TestHistoryPreviousAndSearchPrevious_ExplicitPattern()
}
[WpfFact]
public void TestHistoryNextAndSearchNext()
public async Task TestHistoryNextAndSearchNext()
{
InsertAndExecuteInputs("1", "2", "10", "20", "30", "100", "200");
await InsertAndExecuteInputs("1", "2", "10", "20", "30", "100", "200").ConfigureAwait(true);
SetActiveCode("4");
_operations.HistoryPrevious(); AssertCurrentSubmission("200");
......@@ -513,9 +514,9 @@ public void TestHistoryNextAndSearchNext()
}
[WpfFact]
public void TestHistoryNextAndSearchNext_ExplicitPattern()
public async Task TestHistoryNextAndSearchNext_ExplicitPattern()
{
InsertAndExecuteInputs("1", "2", "10", "20", "30", "100", "200");
await InsertAndExecuteInputs("1", "2", "10", "20", "30", "100", "200").ConfigureAwait(true);
SetActiveCode("4");
_operations.HistoryPrevious(); AssertCurrentSubmission("200");
......
......@@ -30,7 +30,7 @@ internal InteractiveWindowTestHost(Action<InteractiveWindow.State> stateChangedH
Evaluator = new TestInteractiveEngine(contentTypeRegistryService);
Window = ExportProvider.GetExport<IInteractiveWindowFactoryService>().Value.CreateWindow(Evaluator);
((InteractiveWindow)Window).StateChanged += stateChangedHandler;
Window.InitializeAsync().PumpingWait();
Window.InitializeAsync().Wait();
}
public static Type[] GetVisualStudioTypes()
......
......@@ -118,10 +118,5 @@ public void EnableActiveTokenTracking(bool enable)
waiter.Value.TrackActiveTokens = enable;
}
}
public void PumpingWait(Task task)
{
task.PumpingWait();
}
}
}
......@@ -26,9 +26,9 @@ class C
Using state = Await CreateCSharpSnippetExpansionNoteTestState(_markup, "interface").ConfigureAwait(True)
state.SendTypeChars("interfac")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:="title" & vbCrLf &
Await state.AssertSelectedCompletionItem(description:="title" & vbCrLf &
"description" & vbCrLf &
String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "interface"))
String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "interface")).ConfigureAwait(True)
End Using
End Function
......@@ -38,8 +38,8 @@ class C
Using state = Await CreateCSharpSnippetExpansionNoteTestState(_markup, "intErfaCE").ConfigureAwait(True)
state.SendTypeChars("interfac")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=$"{String.Format(FeaturesResources.Keyword, "interface")}
{String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "interface")}")
Await state.AssertSelectedCompletionItem(description:=$"{String.Format(FeaturesResources.Keyword, "interface")}
{String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "interface")}").ConfigureAwait(True)
End Using
End Function
......@@ -49,9 +49,9 @@ class C
Using state = Await CreateCSharpSnippetExpansionNoteTestState(_markup, "interfac").ConfigureAwait(True)
state.SendTypeChars("interfac")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:="title" & vbCrLf &
Await state.AssertSelectedCompletionItem(description:="title" & vbCrLf &
"description" & vbCrLf &
String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "interfac"))
String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "interfac")).ConfigureAwait(True)
End Using
End Sub
......@@ -61,7 +61,7 @@ class C
Using state = Await CreateCSharpSnippetExpansionNoteTestState(_markup, "interfaces").ConfigureAwait(True)
state.SendTypeChars("interfac")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "interface"))
Await state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "interface")).ConfigureAwait(True)
End Using
End Sub
......@@ -72,7 +72,7 @@ class C
state.SendTypeChars("DisplayTex")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "InsertionText"))
Await state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "InsertionText")).ConfigureAwait(True)
End Using
End Sub
......@@ -99,7 +99,7 @@ class C
state.SendTypeChars("for")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "for"))
Await state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "for")).ConfigureAwait(True)
End Using
End Function
......
......@@ -22,9 +22,9 @@ End Class]]></document>
Using state = Await CreateVisualBasicSnippetExpansionNoteTestState(_markup, "Interface").ConfigureAwait(True)
state.SendTypeChars("Interfac")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "Interface") & vbCrLf &
Await state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "Interface") & vbCrLf &
VBFeaturesResources.InterfaceKeywordToolTip & vbCrLf &
String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "Interface"))
String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "Interface")).ConfigureAwait(True)
End Using
End Function
......@@ -33,9 +33,9 @@ End Class]]></document>
Using state = Await CreateVisualBasicSnippetExpansionNoteTestState(_markup, "intErfaCE").ConfigureAwait(True)
state.SendTypeChars("Interfac")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "Interface") & vbCrLf &
Await state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "Interface") & vbCrLf &
VBFeaturesResources.InterfaceKeywordToolTip & vbCrLf &
String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "Interface"))
String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "Interface")).ConfigureAwait(True)
End Using
End Function
......@@ -44,8 +44,8 @@ End Class]]></document>
Using state = Await CreateVisualBasicSnippetExpansionNoteTestState(_markup, "Interfac").ConfigureAwait(True)
state.SendTypeChars("Interfac")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "Interface") & vbCrLf &
VBFeaturesResources.InterfaceKeywordToolTip)
Await state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "Interface") & vbCrLf &
VBFeaturesResources.InterfaceKeywordToolTip).ConfigureAwait(True)
End Using
End Function
......@@ -54,8 +54,8 @@ End Class]]></document>
Using state = Await CreateVisualBasicSnippetExpansionNoteTestState(_markup, "Interfaces").ConfigureAwait(True)
state.SendTypeChars("Interfac")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "Interface") & vbCrLf &
VBFeaturesResources.InterfaceKeywordToolTip)
Await state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.Keyword, "Interface") & vbCrLf &
VBFeaturesResources.InterfaceKeywordToolTip).ConfigureAwait(True)
End Using
End Function
......@@ -65,7 +65,7 @@ End Class]]></document>
state.SendTypeChars("DisplayTex")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:="")
Await state.AssertSelectedCompletionItem(description:="").ConfigureAwait(True)
End Using
End Function
......@@ -75,7 +75,7 @@ End Class]]></document>
state.SendTypeChars("DisplayTex")
Await state.AssertCompletionSession().ConfigureAwait(True)
state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "InsertionText"))
Await state.AssertSelectedCompletionItem(description:=String.Format(FeaturesResources.NoteTabTwiceToInsertTheSnippet, "InsertionText")).ConfigureAwait(True)
End Using
End Function
......
......@@ -28,7 +28,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
state.SendTypeChars("arg")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
Assert.Equal("arg", state.GetCurrentViewLineText())
state.AssertCompletionSession()
Await state.AssertCompletionSession().ConfigureAwait(True)
state.SendTab()
Assert.Equal("args", state.GetCurrentViewLineText())
End Using
......@@ -53,7 +53,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
state.SendTypeChars("arg")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
Assert.Equal("arg", state.GetCurrentViewLineText())
state.AssertCompletionSession()
Await state.AssertCompletionSession().ConfigureAwait(True)
state.SendTab()
Assert.Equal("args", state.GetCurrentViewLineText())
End Using
......@@ -78,12 +78,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, True)
state.SendTypeChars("x")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionSession()
state.AssertSelectedCompletionItem("x")
Await state.AssertCompletionSession().ConfigureAwait(True)
Await state.AssertSelectedCompletionItem("x").ConfigureAwait(True)
state.SendBackspace()
state.SendTypeChars("bar")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("bar")
Await state.AssertSelectedCompletionItem("bar").ConfigureAwait(True)
state.SendTab()
Assert.Equal("bar", state.GetCurrentViewLineText())
End Using
......@@ -108,14 +108,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, True)
state.SendTypeChars("bar")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("bar")
Await state.AssertSelectedCompletionItem("bar").ConfigureAwait(True)
state.SendTab()
Assert.Equal("bar", state.GetCurrentViewLineText())
state.SendReturn()
Assert.Equal("", state.GetCurrentViewLineText())
state.SendTypeChars("bar")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("bar")
Await state.AssertSelectedCompletionItem("bar").ConfigureAwait(True)
state.SendTab()
Assert.Equal(" bar", state.GetCurrentViewLineText())
End Using
......@@ -141,22 +141,22 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("foo")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("foo")
Await state.AssertSelectedCompletionItem("foo").ConfigureAwait(True)
state.SendTab()
state.SendTypeChars(".ToS")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("ToString")
Await state.AssertSelectedCompletionItem("ToString").ConfigureAwait(True)
For i As Integer = 0 To 7
state.SendBackspace()
Next
state.SendTypeChars("green")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("green")
Await state.AssertSelectedCompletionItem("green").ConfigureAwait(True)
state.SendTab()
state.SendTypeChars(".ToS")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("ToString")
Await state.AssertSelectedCompletionItem("ToString").ConfigureAwait(True)
End Using
End Function
......@@ -182,7 +182,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("variable")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionItemsContainAll("variable1", "variable2")
Await state.AssertCompletionItemsContainAll("variable1", "variable2").ConfigureAwait(True)
End Using
End Sub
......@@ -208,7 +208,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("variable")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionItemsContainAll("variable1", "variable2")
Await state.AssertCompletionItemsContainAll("variable1", "variable2").ConfigureAwait(True)
End Using
End Sub
......@@ -234,8 +234,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("variable")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionItemsContainNone("variable1")
state.AssertCompletionItemsContainAll("variable2")
Await state.AssertCompletionItemsContainNone("variable1").ConfigureAwait(True)
Await state.AssertCompletionItemsContainAll("variable2").ConfigureAwait(True)
End Using
End Sub
......@@ -261,8 +261,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("variable")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionItemsContainNone("variable1")
state.AssertCompletionItemsContainAll("variable2")
Await state.AssertCompletionItemsContainNone("variable1").ConfigureAwait(True)
Await state.AssertCompletionItemsContainAll("variable2").ConfigureAwait(True)
End Using
End Sub
......@@ -288,8 +288,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("variable")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionItemsContainNone("variable1")
state.AssertCompletionItemsContainAll("variable2")
Await state.AssertCompletionItemsContainNone("variable1").ConfigureAwait(True)
Await state.AssertCompletionItemsContainAll("variable2").ConfigureAwait(True)
End Using
End Sub
......@@ -315,8 +315,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("variable")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionItemsContainNone("variable1")
state.AssertCompletionItemsContainNone("variable2")
Await state.AssertCompletionItemsContainNone("variable1").ConfigureAwait(True)
Await state.AssertCompletionItemsContainNone("variable2").ConfigureAwait(True)
End Using
End Sub
......@@ -340,7 +340,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("new string(")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSignatureHelpSession()
Await state.AssertSignatureHelpSession().ConfigureAwait(True)
End Using
End Sub
......@@ -368,7 +368,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("something(")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSignatureHelpSession()
Await state.AssertSignatureHelpSession().ConfigureAwait(True)
End Using
End Sub
......@@ -397,7 +397,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("something<int>(")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSignatureHelpSession()
Await state.AssertSignatureHelpSession().ConfigureAwait(True)
End Using
End Sub
......@@ -451,7 +451,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("STATICI")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionItemsContainNone("STATICINT")
Await state.AssertCompletionItemsContainNone("STATICINT").ConfigureAwait(True)
End Using
End Sub
......@@ -477,7 +477,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Using state = TestState.CreateCSharpTestState(text, False)
state.SendTypeChars("1")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertNoCompletionSession()
Await state.AssertNoCompletionSession().ConfigureAwait(True)
End Using
End Sub
......@@ -632,7 +632,7 @@ $$</Document>
state.SendTypeChars("arg")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
Assert.Equal("arg", state.GetCurrentViewLineText())
state.AssertCompletionSession()
Await state.AssertCompletionSession().ConfigureAwait(True)
state.SendTab()
Assert.Equal("args", state.GetCurrentViewLineText())
End Using
......@@ -670,11 +670,11 @@ $$</Document>
Private Async Function VerifyCompletionAndDotAfter(item As String, state As TestState) As Threading.Tasks.Task
state.SendTypeChars(item)
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(item)
Await state.AssertSelectedCompletionItem(item).ConfigureAwait(True)
state.SendTab()
state.SendTypeChars(".")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionSession()
Await state.AssertCompletionSession().ConfigureAwait(True)
For i As Integer = 0 To item.Length
state.SendBackspace()
Next
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Completion
Imports Microsoft.CodeAnalysis.Editor
......@@ -194,25 +195,25 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
End Sub
Public Overloads Sub SendSelectCompletionItemThroughPresenterSession(item As CompletionItem)
WaitForAsynchronousOperations()
AssertNoAsynchronousOperationsRunning()
CurrentCompletionPresenterSession.SetSelectedItem(item)
End Sub
Public Sub AssertNoCompletionSession(Optional block As Boolean = True)
Public Async Function AssertNoCompletionSession(Optional block As Boolean = True) As Task
If block Then
WaitForAsynchronousOperations()
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
End If
Assert.Null(Me.CurrentCompletionPresenterSession)
End Sub
End Function
Public Sub AssertCompletionSession()
WaitForAsynchronousOperations()
Public Async Function AssertCompletionSession() As Task
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
Assert.NotNull(Me.CurrentCompletionPresenterSession)
End Sub
End Function
Public Sub AssertCompletionItemsContainAll(ParamArray displayTexts As String())
WaitForAsynchronousOperations()
Public Async Function AssertCompletionItemsContainAll(ParamArray displayTexts As String()) As Task
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
If Me.CurrentCompletionPresenterSession Is Nothing Then
Assert.False(True, "No completion session active")
......@@ -223,10 +224,10 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Assert.False(True, "Didn't find '" & displayText & "' in completion.")
End If
Next
End Sub
End Function
Public Sub AssertCompletionItemsContainNone(ParamArray displayTexts As String())
WaitForAsynchronousOperations()
Public Async Function AssertCompletionItemsContainNone(ParamArray displayTexts As String()) As Task
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
If Me.CurrentCompletionPresenterSession Is Nothing Then
Assert.False(True, "No completion session active")
......@@ -237,16 +238,16 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Assert.False(True, "Found '" & displayText & "' in completion.")
End If
Next
End Sub
End Function
Public Sub AssertSelectedCompletionItem(
Public Async Function AssertSelectedCompletionItem(
Optional displayText As String = Nothing,
Optional description As String = Nothing,
Optional isSoftSelected As Boolean? = Nothing,
Optional isHardSelected As Boolean? = Nothing
)
) As Task
WaitForAsynchronousOperations()
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
If isSoftSelected.HasValue Then
Assert.Equal(isSoftSelected.Value, Me.CurrentCompletionPresenterSession.IsSoftSelected)
End If
......@@ -268,7 +269,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
If description IsNot Nothing Then
Assert.Equal(description, Me.CurrentCompletionPresenterSession.SelectedItem.GetDescriptionAsync().Result.GetFullText())
End If
End Sub
End Function
#End Region
......@@ -294,22 +295,22 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
End Sub
Public Sub SendSelectSignatureHelpItemThroughPresenterSession(item As SignatureHelpItem)
WaitForAsynchronousOperations()
AssertNoAsynchronousOperationsRunning()
CurrentSignatureHelpPresenterSession.SetSelectedItem(item)
End Sub
Public Sub AssertNoSignatureHelpSession(Optional block As Boolean = True)
Public Async Function AssertNoSignatureHelpSession(Optional block As Boolean = True) As Task
If block Then
WaitForAsynchronousOperations()
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
End If
Assert.Null(Me.CurrentSignatureHelpPresenterSession)
End Sub
End Function
Public Sub AssertSignatureHelpSession()
WaitForAsynchronousOperations()
Public Async Function AssertSignatureHelpSession() As Task
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
Assert.NotNull(Me.CurrentSignatureHelpPresenterSession)
End Sub
End Function
Private Function GetDisplayText(item As SignatureHelpItem, selectedParameter As Integer) As String
Dim suffix = If(selectedParameter < item.Parameters.Count,
......@@ -330,21 +331,21 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
End Function
Public Function SignatureHelpItemsContainsAll(displayText As String()) As Boolean
WaitForAsynchronousOperations()
AssertNoAsynchronousOperationsRunning()
Return displayText.All(Function(v) CurrentSignatureHelpPresenterSession.SignatureHelpItems.Any(
Function(i) GetDisplayText(i, CurrentSignatureHelpPresenterSession.SelectedParameter.Value) = v))
End Function
Public Function SignatureHelpItemsContainsAny(displayText As String()) As Boolean
WaitForAsynchronousOperations()
AssertNoAsynchronousOperationsRunning()
Return displayText.Any(Function(v) CurrentSignatureHelpPresenterSession.SignatureHelpItems.Any(
Function(i) GetDisplayText(i, CurrentSignatureHelpPresenterSession.SelectedParameter.Value) = v))
End Function
Public Sub AssertSelectedSignatureHelpItem(Optional displayText As String = Nothing,
Public Async Function AssertSelectedSignatureHelpItem(Optional displayText As String = Nothing,
Optional documentation As String = Nothing,
Optional selectedParameter As String = Nothing)
WaitForAsynchronousOperations()
Optional selectedParameter As String = Nothing) As Task
Await WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
If displayText IsNot Nothing Then
Assert.Equal(displayText, GetDisplayText(Me.CurrentSignatureHelpPresenterSession.SelectedItem, Me.CurrentSignatureHelpPresenterSession.SelectedParameter.Value))
......@@ -359,7 +360,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.DebuggerIntelliSense
Me.CurrentSignatureHelpPresenterSession.SelectedItem.Parameters(
Me.CurrentSignatureHelpPresenterSession.SelectedParameter.Value).DisplayParts))
End If
End Sub
End Function
#End Region
Public Function GetCurrentViewLineText() As String
......
......@@ -169,11 +169,11 @@ End Module</Document>
For xx = 0 To 10
state.SendTypeChars("z")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("z")
Await state.AssertSelectedCompletionItem("z").ConfigureAwait(True)
state.SendTab()
state.SendTypeChars(".")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionSession()
Await state.AssertCompletionSession().ConfigureAwait(True)
state.SendReturn()
Next
End Using
......@@ -197,7 +197,7 @@ End Module</Document>
Using state = TestState.CreateVisualBasicTestState(text, False)
state.SendTypeChars("new String(")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSignatureHelpSession()
Await state.AssertSignatureHelpSession().ConfigureAwait(True)
End Using
End Sub
......@@ -219,7 +219,7 @@ End Module</Document>
Using state = TestState.CreateVisualBasicTestState(text, False)
state.SendTypeChars("Main(")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSignatureHelpSession()
Await state.AssertSignatureHelpSession().ConfigureAwait(True)
End Using
End Sub
......@@ -245,7 +245,7 @@ End Module</Document>
Using state = TestState.CreateVisualBasicTestState(text, False)
state.SendTypeChars("Self(Of Integer)(")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSignatureHelpSession()
Await state.AssertSignatureHelpSession().ConfigureAwait(True)
End Using
End Sub
......@@ -271,7 +271,7 @@ End Module</Document>
Using state = TestState.CreateVisualBasicTestState(text, False)
state.SendTypeChars("new List(Of String) From { a")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionSession()
Await state.AssertCompletionSession().ConfigureAwait(True)
End Using
End Sub
......@@ -303,7 +303,7 @@ End Class
Using state = TestState.CreateVisualBasicTestState(text, False)
state.SendTypeChars("new AClass")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem("AClass")
Await state.AssertSelectedCompletionItem("AClass").ConfigureAwait(True)
End Using
End Sub
......@@ -329,7 +329,7 @@ End Module</Document>
Using state = TestState.CreateVisualBasicTestState(text, False)
state.SendTypeChars("Self(Of ")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionSession()
Await state.AssertCompletionSession().ConfigureAwait(True)
End Using
End Sub
......@@ -365,11 +365,11 @@ End Module</Document>
End If
state.SendTypeChars(item)
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertSelectedCompletionItem(item)
Await state.AssertSelectedCompletionItem(item).ConfigureAwait(True)
state.SendTab()
state.SendTypeChars(".")
Await state.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
state.AssertCompletionSession()
Await state.AssertCompletionSession().ConfigureAwait(True)
For i As Integer = 0 To item.Length
state.SendBackspace()
Next
......
......@@ -2,6 +2,7 @@
Imports System.Collections.Immutable
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor
......@@ -47,7 +48,7 @@ class 123 { }
Dim tagger = provider.CreateTagger(Of IErrorTag)(buffer)
Using disposable = TryCast(tagger, IDisposable)
Dim analyzer = miscService.CreateIncrementalAnalyzer(workspace)
analyzer.AnalyzeSyntaxAsync(workspace.CurrentSolution.Projects.First().Documents.First(), CancellationToken.None).PumpingWait()
Await analyzer.AnalyzeSyntaxAsync(workspace.CurrentSolution.Projects.First().Documents.First(), CancellationToken.None).ConfigureAwait(True)
Await listener.CreateWaitTask().ConfigureAwait(True)
......@@ -61,7 +62,7 @@ class 123 { }
End Function
<WpfFact>
Public Sub TestMiscCSharpErrorSource()
Public Async Function TestMiscCSharpErrorSource() As Tasks.Task
Dim code = <code>
class 123 { }
</code>
......@@ -78,14 +79,14 @@ class 123 { }
End Sub
Dim analyzer = miscService.CreateIncrementalAnalyzer(workspace)
analyzer.AnalyzeSyntaxAsync(workspace.CurrentSolution.Projects.First().Documents.First(), CancellationToken.None).PumpingWait()
Await analyzer.AnalyzeSyntaxAsync(workspace.CurrentSolution.Projects.First().Documents.First(), CancellationToken.None).ConfigureAwait(True)
Assert.Equal(PredefinedBuildTools.Live, buildTool)
End Using
End Sub
End Function
<WpfFact>
Public Sub TestMiscVBErrorSource()
Public Async Function TestMiscVBErrorSource() As Task
Dim code = <code>
Class 123
End Class
......@@ -103,10 +104,10 @@ End Class
End Sub
Dim analyzer = miscService.CreateIncrementalAnalyzer(workspace)
analyzer.AnalyzeSyntaxAsync(workspace.CurrentSolution.Projects.First().Documents.First(), CancellationToken.None).PumpingWait()
Await analyzer.AnalyzeSyntaxAsync(workspace.CurrentSolution.Projects.First().Documents.First(), CancellationToken.None).ConfigureAwait(True)
Assert.Equal(PredefinedBuildTools.Live, buildTool)
End Using
End Sub
End Function
End Class
End Namespace
\ No newline at end of file
......@@ -41,7 +41,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Snippets
testState.SendBackspace()
Await testState.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
testState.WaitForAsynchronousOperations()
Assert.Equal(testState.CurrentCompletionPresenterSession.SelectedItem.DisplayText, "Shortcut")
testState.SendTabToCompletion()
......@@ -63,7 +62,6 @@ End Class</File>.Value
Using testState
testState.SendTabToCompletion()
Await testState.WaitForAsynchronousOperationsAsync().ConfigureAwait(True)
testState.WaitForAsynchronousOperations()
Assert.Null(testState.CurrentCompletionPresenterSession)
End Using
End Function
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册