public static void InvokeNavigateToAndPressEnter(this AbstractIntegrationTest test, string text) { test.ExecuteCommand(WellKnownCommandNames.Edit_GoToAll); test.VisualStudio.Instance.Editor.NavigateToSendKeys(text); test.WaitForAsyncOperations(FeatureAttribute.NavigateTo); test.VisualStudio.Instance.Editor.NavigateToSendKeys("{ENTER}"); }
private static void VerifyTextContainsAndAssertCaretPosition(AbstractIntegrationTest test, string expectedText) { var caretStartIndex = expectedText.IndexOf("$$"); if (caretStartIndex < 0) { throw new ArgumentException("Expected caret position to be specified with $$", nameof(expectedText)); } var caretEndIndex = caretStartIndex + "$$".Length; var expectedTextBeforeCaret = expectedText.Substring(0, caretStartIndex); var expectedTextAfterCaret = expectedText.Substring(caretEndIndex); var expectedTextWithoutCaret = expectedTextBeforeCaret + expectedTextAfterCaret; var editorText = test.VisualStudio.Instance.Editor.GetText(); Assert.Contains(expectedTextWithoutCaret, editorText); var index = editorText.IndexOf(expectedTextWithoutCaret); var caretPosition = test.VisualStudio.Instance.Editor.GetCaretPosition(); Assert.Equal(caretStartIndex + index, caretPosition); }
public static void VerifyAssemblyReferencePresent(this AbstractIntegrationTest test, ProjectUtils.Project project, string assemblyName, string assemblyVersion, string assemblyPublicKeyToken) { var assemblyReferences = test.VisualStudio.Instance.SolutionExplorer.GetAssemblyReferences(project.Name); var expectedAssemblyReference = assemblyName + "," + assemblyVersion + "," + assemblyPublicKeyToken.ToUpper(); Assert.Contains(expectedAssemblyReference, assemblyReferences); }
public static void VerifyCurrentParameter(this AbstractIntegrationTest test, string name, string documentation) { var currentParameter = test.VisualStudio.Instance.Editor.GetCurrentSignature().CurrentParameter; Assert.Equal(name, currentParameter.Name); Assert.Equal(documentation, currentParameter.Documentation); }
public static void VerifyCodeActionsNotShowing(this AbstractIntegrationTest test) { if (test.VisualStudio.Instance.Editor.IsLightBulbSessionExpanded()) { throw new InvalidOperationException("Expected no light bulb session, but one was found."); } }
public static void InvokeCodeActionList(this AbstractIntegrationTest test) { test.WaitForAsyncOperations(FeatureAttribute.SolutionCrawler); test.WaitForAsyncOperations(FeatureAttribute.DiagnosticService); test.VisualStudio.Instance.Editor.ShowLightBulb(); test.VisualStudio.Instance.Editor.WaitForLightBulbSession(); test.WaitForAsyncOperations(FeatureAttribute.LightBulb); }
public static void VerifyCompletionItemDoesNotExist(this AbstractIntegrationTest test, params string[] expectedItems) { var completionItems = test.VisualStudio.Instance.Editor.GetCompletionItems(); foreach (var expectedItem in expectedItems) { Assert.DoesNotContain(expectedItem, completionItems); } }
public static void VerifyTextContains(this AbstractIntegrationTest test, string expectedText, bool assertCaretPosition = false) { if (assertCaretPosition) { VerifyTextContainsAndAssertCaretPosition(test, expectedText); } else { var editorText = test.VisualStudio.Instance.Editor.GetText(); Assert.Contains(expectedText, editorText); } }
public static void VerifyCurrentTokenType(AbstractIntegrationTest test, string tokenType, TextViewWindow_OutOfProc window) { test.WaitForAsyncOperations( FeatureAttribute.SolutionCrawler, FeatureAttribute.DiagnosticService, FeatureAttribute.Classification); var actualTokenTypes = window.GetCurrentClassifications(); Assert.Equal(actualTokenTypes.Length, 1); Assert.Contains(tokenType, actualTokenTypes[0]); Assert.NotEqual("text", tokenType); }
public static void SetFullSolutionAnalysis(this AbstractIntegrationTest test, bool value) { test.VisualStudio.Instance.VisualStudioWorkspace.SetPerLanguageOption( optionName: "Closed File Diagnostic", feature: "ServiceFeaturesOnOff", language: LanguageNames.CSharp, value: value ? "true" : "false"); test.VisualStudio.Instance.VisualStudioWorkspace.SetPerLanguageOption( optionName: "Closed File Diagnostic", feature: "ServiceFeaturesOnOff", language: LanguageNames.VisualBasic, value: value ? "true" : "false"); }
public static void VerifyCodeAction( this AbstractIntegrationTest test, string expectedItem, bool applyFix = false, bool verifyNotShowing = false, bool ensureExpectedItemsAreOrdered = false, FixAllScope?fixAllScope = null, bool blockUntilComplete = true) { var expectedItems = new[] { expectedItem }; test.VerifyCodeActions( expectedItems, applyFix ? expectedItem : null, verifyNotShowing, ensureExpectedItemsAreOrdered, fixAllScope, blockUntilComplete); }
public static void VerifyCodeActions( this AbstractIntegrationTest test, IEnumerable <string> expectedItems, string applyFix = null, bool verifyNotShowing = false, bool ensureExpectedItemsAreOrdered = false, FixAllScope?fixAllScope = null, bool blockUntilComplete = true) { test.VisualStudio.Instance.Editor.ShowLightBulb(); test.VisualStudio.Instance.Editor.WaitForLightBulbSession(); if (verifyNotShowing) { test.VerifyCodeActionsNotShowing(); return; } var actions = test.VisualStudio.Instance.Editor.GetLightBulbActions(); if (expectedItems != null && expectedItems.Any()) { if (ensureExpectedItemsAreOrdered) { TestUtilities.ThrowIfExpectedItemNotFoundInOrder( actions, expectedItems); } else { TestUtilities.ThrowIfExpectedItemNotFound( actions, expectedItems); } } if (!string.IsNullOrEmpty(applyFix) || fixAllScope.HasValue) { test.VisualStudio.Instance.Editor.ApplyLightBulbAction(applyFix, fixAllScope, blockUntilComplete); if (blockUntilComplete) { // wait for action to complete test.WaitForAsyncOperations(FeatureAttribute.LightBulb); } } }
public static void VerifyCurrentLineText(this AbstractIntegrationTest test, string expectedText, bool assertCaretPosition = false, bool trimWhitespace = true) { if (assertCaretPosition) { VerifyCurrentLineTextAndAssertCaretPosition(test, expectedText, trimWhitespace); } else { var lineText = test.VisualStudio.Instance.Editor.GetCurrentLineText(); if (trimWhitespace) { lineText = lineText.Trim(); } Assert.Equal(expectedText, lineText); } }
private static void VerifyCurrentLineTextAndAssertCaretPosition(AbstractIntegrationTest test, string expectedText, bool trimWhitespace) { var caretStartIndex = expectedText.IndexOf("$$"); if (caretStartIndex < 0) { throw new ArgumentException("Expected caret position to be specified with $$", nameof(expectedText)); } var caretEndIndex = caretStartIndex + "$$".Length; var expectedTextBeforeCaret = expectedText.Substring(0, caretStartIndex); var expectedTextAfterCaret = expectedText.Substring(caretEndIndex); var lineText = test.VisualStudio.Instance.Editor.GetCurrentLineText(); if (trimWhitespace) { if (caretStartIndex == 0) { lineText = lineText.TrimEnd(); } else if (caretEndIndex == expectedText.Length) { lineText = lineText.TrimStart(); } else { lineText = lineText.Trim(); } } var lineTextBeforeCaret = caretStartIndex < lineText.Length ? lineText.Substring(0, caretStartIndex) : lineText; var lineTextAfterCaret = caretStartIndex < lineText.Length ? lineText.Substring(caretStartIndex) : string.Empty; Assert.Equal(expectedTextBeforeCaret, lineTextBeforeCaret); Assert.Equal(expectedTextAfterCaret, lineTextAfterCaret); Assert.Equal(expectedTextBeforeCaret.Length + expectedTextAfterCaret.Length, lineText.Length); }
public static void InvokeQuickInfo(this AbstractIntegrationTest test) { test.ExecuteCommand(WellKnownCommandNames.Edit_QuickInfo); test.WaitForAsyncOperations(FeatureAttribute.QuickInfo); }
public static void InvokeSignatureHelp(this AbstractIntegrationTest test) { test.ExecuteCommand(WellKnownCommandNames.Edit_ParameterInfo); test.WaitForAsyncOperations(FeatureAttribute.SignatureHelp); }
public static void InvokeCompletionList(this AbstractIntegrationTest test) { CommonExtensions.InvokeCompletionList(test); }
public static void SendKeys(this AbstractIntegrationTest test, params object[] keys) => test.VisualStudio.Instance.Editor.SendKeys(keys);
public static void PlaceCaret(this AbstractIntegrationTest test, string text, int charsOffset = 0) => test.VisualStudio.Instance.Editor.PlaceCaret(text, charsOffset: charsOffset, occurrence: 0, extendSelection: false, selectBlock: false);
public static void DeleteText(this AbstractIntegrationTest test, string text) { test.SelectTextInCurrentDocument(text); test.SendKeys(VirtualKey.Delete); }
public static void WaitForAsyncOperations(this AbstractIntegrationTest test, params string[] featuresToWaitFor) => test.VisualStudio.Instance.VisualStudioWorkspace.WaitForAsyncOperations(string.Join(";", featuresToWaitFor));
public static string GetWinFormButtonPropertyValue(this AbstractIntegrationTest test, string buttonName, string propertyName) => test.VisualStudio.Instance.Editor.GetWinFormButtonPropertyValue(buttonName, propertyName);
public static void EditWinFormsButtonEvent(this AbstractIntegrationTest test, string buttonName, string eventName, string eventHandlerName) => test.VisualStudio.Instance.Editor.EditWinFormButtonEvent(buttonName, eventName, eventHandlerName);
public static void EditWinFormButtonProperty(this AbstractIntegrationTest test, string buttonName, string propertyName, string propertyValue, string propertyTypeName = null) => test.VisualStudio.Instance.Editor.EditWinFormButtonProperty(buttonName, propertyName, propertyValue, propertyTypeName);
public static void PressDialogButton(this AbstractIntegrationTest test, string dialogAutomationName, string buttonAutomationName) { test.VisualStudio.Instance.Editor.PressDialogButton(dialogAutomationName, buttonAutomationName); }
public static void InvokeCompletionList(AbstractIntegrationTest test) { test.ExecuteCommand(WellKnownCommandNames.Edit_ListMembers); test.WaitForAsyncOperations(FeatureAttribute.CompletionSet); }
public static void ExecuteCommand(this AbstractIntegrationTest test, string commandName, string argument = "") => test.VisualStudio.Instance.ExecuteCommand(commandName, argument);
public static void SelectTextInCurrentDocument(this AbstractIntegrationTest test, string text) { test.VisualStudio.Instance.Editor.PlaceCaret(text, charsOffset: -1, occurrence: 0, extendSelection: false, selectBlock: false); test.VisualStudio.Instance.Editor.PlaceCaret(text, charsOffset: 0, occurrence: 0, extendSelection: true, selectBlock: false); }
public static AutomationElement GetDialog(this AbstractIntegrationTest test, string dialogAutomationId) { var dialog = DialogHelpers.FindDialog(test.VisualStudio.Instance.Shell.GetHWnd(), dialogAutomationId, isOpen: true); return(dialog); }
public static void DeleteWinFormButton(this AbstractIntegrationTest test, string buttonName) => test.VisualStudio.Instance.Editor.DeleteWinFormButton(buttonName);