コード例 #1
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 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}");
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 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.");
     }
 }
コード例 #6
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
        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);
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
        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);
        }
コード例 #10
0
        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");
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
                }
            }
        }
コード例 #13
0
        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);
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static void InvokeQuickInfo(this AbstractIntegrationTest test)
 {
     test.ExecuteCommand(WellKnownCommandNames.Edit_QuickInfo);
     test.WaitForAsyncOperations(FeatureAttribute.QuickInfo);
 }
コード例 #16
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static void InvokeSignatureHelp(this AbstractIntegrationTest test)
 {
     test.ExecuteCommand(WellKnownCommandNames.Edit_ParameterInfo);
     test.WaitForAsyncOperations(FeatureAttribute.SignatureHelp);
 }
コード例 #17
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static void InvokeCompletionList(this AbstractIntegrationTest test)
 {
     CommonExtensions.InvokeCompletionList(test);
 }
コード例 #18
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static void SendKeys(this AbstractIntegrationTest test, params object[] keys)
 => test.VisualStudio.Instance.Editor.SendKeys(keys);
コード例 #19
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 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);
コード例 #20
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static void DeleteText(this AbstractIntegrationTest test, string text)
 {
     test.SelectTextInCurrentDocument(text);
     test.SendKeys(VirtualKey.Delete);
 }
コード例 #21
0
ファイル: CommonExtensions.cs プロジェクト: m0nguss/roslyn
 public static void WaitForAsyncOperations(this AbstractIntegrationTest test, params string[] featuresToWaitFor)
 => test.VisualStudio.Instance.VisualStudioWorkspace.WaitForAsyncOperations(string.Join(";", featuresToWaitFor));
コード例 #22
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static string GetWinFormButtonPropertyValue(this AbstractIntegrationTest test, string buttonName, string propertyName)
 => test.VisualStudio.Instance.Editor.GetWinFormButtonPropertyValue(buttonName, propertyName);
コード例 #23
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static void EditWinFormsButtonEvent(this AbstractIntegrationTest test, string buttonName, string eventName, string eventHandlerName)
 => test.VisualStudio.Instance.Editor.EditWinFormButtonEvent(buttonName, eventName, eventHandlerName);
コード例 #24
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 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);
コード例 #25
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static void PressDialogButton(this AbstractIntegrationTest test, string dialogAutomationName, string buttonAutomationName)
 {
     test.VisualStudio.Instance.Editor.PressDialogButton(dialogAutomationName, buttonAutomationName);
 }
コード例 #26
0
ファイル: CommonExtensions.cs プロジェクト: m0nguss/roslyn
 public static void InvokeCompletionList(AbstractIntegrationTest test)
 {
     test.ExecuteCommand(WellKnownCommandNames.Edit_ListMembers);
     test.WaitForAsyncOperations(FeatureAttribute.CompletionSet);
 }
コード例 #27
0
ファイル: CommonExtensions.cs プロジェクト: m0nguss/roslyn
 public static void ExecuteCommand(this AbstractIntegrationTest test, string commandName, string argument = "")
 => test.VisualStudio.Instance.ExecuteCommand(commandName, argument);
コード例 #28
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 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);
 }
コード例 #29
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
        public static AutomationElement GetDialog(this AbstractIntegrationTest test, string dialogAutomationId)
        {
            var dialog = DialogHelpers.FindDialog(test.VisualStudio.Instance.Shell.GetHWnd(), dialogAutomationId, isOpen: true);

            return(dialog);
        }
コード例 #30
0
ファイル: EditorExtensions.cs プロジェクト: m0nguss/roslyn
 public static void DeleteWinFormButton(this AbstractIntegrationTest test, string buttonName)
 => test.VisualStudio.Instance.Editor.DeleteWinFormButton(buttonName);