Ejemplo n.º 1
0
        public CompletionList WaitForCompletionItems(IVisualStudioTextEditorTestExtension editor, int timeout = 1000)
        {
            CompletionList items = null;

            WaitFor.TryIsTrue(() =>
            {
                try
                {
                    IVisualStudioCompletionListTestExtension completionList = editor.Intellisense.GetActiveCompletionList();

                    // Make another call if completion list is not available or is still loading.
                    if (completionList == null || completionList.Items.Count == 1 && completionList.Items[0].Text.Equals(Vsix.Resources.Text.Loading))
                    {
                        return(false);
                    }

                    items = completionList.Items;

                    return(true);
                }
                catch (EditorException)
                {
                    return(false);
                }
            }, TimeSpan.FromMilliseconds(timeout), TimeSpan.FromMilliseconds(500));

            return(items);
        }
Ejemplo n.º 2
0
        private static string WaitForCompletionEntriesHelper(IVisualStudioTextEditorTestExtension editor, IEnumerable <string> expectedCompletionEntries, bool caseInsensitive, int timeout)
        {
            string errorMessage = null;

            WaitFor.TryIsTrue(() =>
            {
                try
                {
                    IVisualStudioCompletionListTestExtension completionList = editor.Intellisense.GetActiveCompletionList();

                    if (completionList == null)
                    {
                        errorMessage = "Completion list not present.";
                        return(false);
                    }

                    HashSet <string> comparisonSet = caseInsensitive ? new HashSet <string>(StringComparer.OrdinalIgnoreCase) : new HashSet <string>();
                    foreach (CompletionItem item in completionList.Items)
                    {
                        comparisonSet.Add(item.Text);
                    }

                    // Make another call if it's still loading.
                    if (comparisonSet.Count == 1 && comparisonSet.Contains(Vsix.Resources.Text.Loading))
                    {
                        errorMessage = "Completion list not present.";
                        return(false);
                    }

                    errorMessage = null;
                    if (expectedCompletionEntries != null)
                    {
                        foreach (string curEntry in expectedCompletionEntries)
                        {
                            if (!comparisonSet.Contains(curEntry))
                            {
                                errorMessage = String.Concat(errorMessage, "\r\nTimed out waiting for completion entry: ", curEntry, ".");
                            }
                        }

                        // Do not force another call if we already got the whole completion list.
                        return(true);
                    }
                }
                catch (EditorException exc)
                {
                    errorMessage = exc.ToString();
                }

                return(errorMessage == null);
            }, TimeSpan.FromMilliseconds(timeout), TimeSpan.FromMilliseconds(500));

            return(errorMessage);
        }