当前位置: 首页>>代码示例>>C#>>正文


C# PythonVisualStudioApp.WaitForErrorListItems方法代码示例

本文整理汇总了C#中TestUtilities.UI.Python.PythonVisualStudioApp.WaitForErrorListItems方法的典型用法代码示例。如果您正苦于以下问题:C# PythonVisualStudioApp.WaitForErrorListItems方法的具体用法?C# PythonVisualStudioApp.WaitForErrorListItems怎么用?C# PythonVisualStudioApp.WaitForErrorListItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestUtilities.UI.Python.PythonVisualStudioApp的用法示例。


在下文中一共展示了PythonVisualStudioApp.WaitForErrorListItems方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CustomCommandsErrorList

        public void CustomCommandsErrorList() {
            using (var app = new PythonVisualStudioApp()) {
                PythonProjectNode node;
                EnvDTE.Project proj;
                OpenProject(app, "ErrorCommand.sln", out node, out proj);

                var expectedItems = new[] {
                    new { Document = "Program.py", Line = 0, Column = 1, Category = __VSERRORCATEGORY.EC_ERROR, Message = "This is an error with a relative path." },
                    new { Document = Path.Combine(node.ProjectHome, "Program.py"), Line = 2, Column = 3, Category = __VSERRORCATEGORY.EC_WARNING, Message = "This is a warning with an absolute path." },
                    new { Document = ">>>", Line = 4, Column = -1, Category = __VSERRORCATEGORY.EC_ERROR, Message = "This is an error with an invalid path." },
                };

                Execute(node, "Produce Errors");
                var items = app.WaitForErrorListItems(3);
                Console.WriteLine("Got errors:");
                foreach (var item in items) {
                    string document, text;
                    Assert.AreEqual(0, item.Document(out document), "HRESULT getting document");
                    Assert.AreEqual(0, item.get_Text(out text), "HRESULT getting message");
                    Console.WriteLine("  {0}: {1}", document ?? "(null)", text ?? "(null)");
                }
                Assert.AreEqual(expectedItems.Length, items.Count);

                // Second invoke should replace the error items in the list, not add new ones to those already existing.
                Execute(node, "Produce Errors");
                items = app.WaitForErrorListItems(3);
                Assert.AreEqual(expectedItems.Length, items.Count);

                items.Sort(Comparer<IVsTaskItem>.Create((x, y) => {
                    int lx, ly;
                    x.Line(out lx);
                    y.Line(out ly);
                    return lx.CompareTo(ly);
                }));

                for (int i = 0; i < expectedItems.Length; ++i) {
                    var item = items[i];
                    var expectedItem = expectedItems[i];

                    string document, message;
                    item.get_Text(out message);
                    item.Document(out document);

                    int line, column;
                    item.Line(out line);
                    item.Column(out column);

                    uint category;
                    ((IVsErrorItem)item).GetCategory(out category);

                    Assert.AreEqual(expectedItem.Document, document);
                    Assert.AreEqual(expectedItem.Line, line);
                    Assert.AreEqual(expectedItem.Column, column);
                    Assert.AreEqual(expectedItem.Message, message);
                    Assert.AreEqual(expectedItem.Category, (__VSERRORCATEGORY)category);
                }

                app.ServiceProvider.GetUIThread().Invoke((Action)delegate { items[0].NavigateTo(); });

                var doc = app.Dte.ActiveDocument;
                Assert.IsNotNull(doc);
                Assert.AreEqual("Program.py", doc.Name);

                var textDoc = (EnvDTE.TextDocument)doc.Object("TextDocument");
                Assert.AreEqual(1, textDoc.Selection.ActivePoint.Line);
                Assert.AreEqual(2, textDoc.Selection.ActivePoint.DisplayColumn);
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:68,代码来源:BuildTasksUITests.cs

示例2: IndentationInconsistencyIgnore

        public void IndentationInconsistencyIgnore() {
            using (var app = new PythonVisualStudioApp()) {
                var options = app.Options;
                var severity = options.IndentationInconsistencySeverity;
                options.IndentationInconsistencySeverity = Severity.Ignore;
                app.OnDispose(() => options.IndentationInconsistencySeverity = severity);

                var project = app.OpenProject(@"TestData\InconsistentIndentation.sln");

                List<IVsTaskItem> items = app.WaitForErrorListItems(0);
                Assert.AreEqual(0, items.Count);
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:13,代码来源:EditorTests.cs

示例3: ImportPresentThenAddThenRemoveReference

        public void ImportPresentThenAddThenRemoveReference() {
            var python = PythonPaths.Versions.LastOrDefault(p => p.Version.Is3x() && !p.Isx64);
            python.AssertInstalled();

            var vcproj = TestData.GetPath(@"TestData\ProjectReference\NativeModule\NativeModule.vcxproj");
            File.WriteAllText(vcproj, File.ReadAllText(vcproj)
                .Replace("$(PYTHON_INCLUDE)", Path.Combine(python.PrefixPath, "include"))
                .Replace("$(PYTHON_LIB)", Path.Combine(python.PrefixPath, "libs"))
            );

            using (var app = new PythonVisualStudioApp())
            using (app.SelectDefaultInterpreter(python)) {
                var project = app.OpenProject(@"TestData\ProjectReference\CProjectReference.sln", projectName: "PythonApplication2", expectedProjects: 2);

                var wnd = project.ProjectItems.Item("Program.py").Open();
                wnd.Activate();
                try {
                    app.Dte.Solution.SolutionBuild.Clean(true);

                    string text;
                    var items = app.WaitForErrorListItems(1);
                    Assert.AreEqual(1, items.Count);
                    Assert.AreEqual(0, items[0].get_Text(out text));
                    Assert.IsTrue(text.Contains("native_module"), text);

                    app.Dte.Solution.SolutionBuild.Build(true);

                    items = app.WaitForErrorListItems(0);
                    Assert.AreEqual(0, items.Count);
                } finally {
                    wnd.Close();
                }
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:34,代码来源:EditorTests.cs

示例4: IndentationInconsistencyError

        public void IndentationInconsistencyError() {
            using (var app = new PythonVisualStudioApp()) {
                var options = app.Options;
                var severity = options.IndentationInconsistencySeverity;
                options.IndentationInconsistencySeverity = Severity.Error;
                app.OnDispose(() => options.IndentationInconsistencySeverity = severity);

                var project = app.OpenProject(@"TestData\InconsistentIndentation.sln");

                var items = app.WaitForErrorListItems(1);
                Assert.AreEqual(1, items.Count);

                VSTASKPRIORITY[] pri = new VSTASKPRIORITY[1];
                ErrorHandler.ThrowOnFailure(items[0].get_Priority(pri));
                Assert.AreEqual(VSTASKPRIORITY.TP_HIGH, pri[0]);
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:17,代码来源:EditorTests.cs


注:本文中的TestUtilities.UI.Python.PythonVisualStudioApp.WaitForErrorListItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。