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


C# PythonVisualStudioApp.ExecuteCommand方法代码示例

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


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

示例1: LaunchUnknownEnvironment

        public void LaunchUnknownEnvironment() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\Environments\Unknown.sln");

                app.ExecuteCommand("Debug.Start");
                PythonVisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "Unknown Python 2.7", "incorrectly configured");
            }
        }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:8,代码来源:VirtualEnvTests.cs

示例2: CopyFolderOnToSelf

        public void CopyFolderOnToSelf() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(@"TestData\HelloWorld2.sln", expectedProjects: 2);
                var proj = app.Dte.Solution.Projects.Cast<Project>().Single(p => p.Name == "HelloWorld2");

                var window = app.OpenSolutionExplorer();

                try {
                    // Remove the destination folder in case a previous test has
                    // created it.
                    Directory.Delete(TestData.GetPath(@"TestData\HelloWorld2\TestFolder - Copy"), true);
                } catch {
                }

                window.FindChildOfProject(proj, "TestFolder").Select();
                app.ExecuteCommand("Edit.Copy");

                window.FindChildOfProject(proj, "TestFolder").Select();
                app.ExecuteCommand("Edit.Paste");

                Assert.IsNotNull(window.WaitForChildOfProject(proj, "TestFolder - Copy"));
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:23,代码来源:UITests.cs

示例3: InstallGenerateRequirementsTxt

        public void InstallGenerateRequirementsTxt() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);

                string envName;
                var env = app.CreateVirtualEnvironment(project, out envName);
                env.Select();

                try {
                    app.ExecuteCommand("Python.InstallRequirementsTxt", "/y", timeout: 5000);
                    Assert.Fail("Command should not have executed");
                } catch (AggregateException ae) {
                    ae.Handle(ex => ex is COMException);
                } catch (COMException) {
                }

                var requirementsTxt = Path.Combine(Path.GetDirectoryName(project.FullName), "requirements.txt");
                File.WriteAllText(requirementsTxt, "azure==0.6.2");

                app.ExecuteCommand("Python.InstallRequirementsTxt", "/y");

                app.SolutionExplorerTreeView.WaitForChildOfProject(
                    project,
                    SR.GetString(SR.Environments),
                    envName,
                    "azure (0.6.2)"
                );

                File.Delete(requirementsTxt);

                app.ExecuteCommand("Python.GenerateRequirementsTxt", "/e:\"" + envName + "\"");

                app.SolutionExplorerTreeView.WaitForChildOfProject(
                    project,
                    "requirements.txt"
                );
                
                AssertUtil.ContainsAtLeast(
                    File.ReadAllLines(requirementsTxt).Select(s => s.Trim()),
                    "azure==0.6.2"
                );
            }
        }
开发者ID:KaushikCh,项目名称:PTVS,代码行数:44,代码来源:VirtualEnvTests.cs

示例4: AddNewFolderNested

        public void AddNewFolderNested() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                app.OpenSolutionExplorer().SelectProject(project);

                app.ExecuteCommand("Project.NewFolder");
                Keyboard.Type("FolderX");
                Keyboard.PressAndRelease(Key.Enter);

                var folderNode = app.OpenSolutionExplorer().WaitForChildOfProject(project, "FolderX");
                folderNode.Select();

                app.ExecuteCommand("Project.NewFolder");
                Keyboard.Type("FolderY");
                Keyboard.PressAndRelease(Key.Enter);

                var innerFolderNode = app.OpenSolutionExplorer().WaitForChildOfProject(project, "FolderX", "FolderY");
                innerFolderNode.Select();

                var newItem = project.ProjectItems.Item("FolderX").ProjectItems.Item("FolderY").ProjectItems.AddFromFile(
                    TestData.GetPath(@"TestData\DebuggerProject\BreakpointTest.py")
                );

                app.OpenSolutionExplorer().WaitForChildOfProject(project, "FolderX", "FolderY", "BreakpointTest.py");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:27,代码来源:UITests.cs

示例5: CutPaste

        public void CutPaste() {
            using (var app = new PythonVisualStudioApp()) {
                app.OpenProject(@"TestData\HelloWorld2.sln", expectedProjects: 2);
                var proj = app.Dte.Solution.Projects.Cast<Project>().Single(p => p.Name == "HelloWorld2");

                var window = app.OpenSolutionExplorer();

                window.FindChildOfProject(proj, "TestFolder", "SubItem.py").Select();

                app.ExecuteCommand("Edit.Cut");

                window.SelectProject(proj);
                app.ExecuteCommand("Edit.Paste");

                Assert.IsNotNull(window.WaitForChildOfProject(proj, "SubItem.py"));
                Assert.IsNull(window.WaitForChildOfProjectRemoved(proj, "TestFolder", "SubItem.py"));
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:18,代码来源:UITests.cs

示例6: AddSearchPathRelativePath

        public void AddSearchPathRelativePath() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\AddSearchPaths.sln");

                app.OpenSolutionExplorer().SelectProject(project);

                using (var dialog = SelectFolderDialog.AddFolderToSearchPath(app)) {
                    dialog.FolderName = TestData.GetPath(@"TestData\Outlining");
                    dialog.SelectFolder();
                }

                app.ExecuteCommand("File.SaveAll");

                var text = File.ReadAllText(TestData.GetPath(@"TestData\AddSearchPaths\AddSearchPaths.pyproj"));
                string actual = Regex.Match(text, @"<SearchPath>.*</SearchPath>", RegexOptions.Singleline).Value;
                Assert.AreEqual("<SearchPath>..\\Outlining\\</SearchPath>", actual);
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:18,代码来源:UITests.cs

示例7: LoadSearchPath

        public void LoadSearchPath() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\LoadSearchPaths.sln");

                // Ensure we complete analysis. VS may crash if the invalid
                // path is not handled correctly.
                project.GetPythonProject().GetAnalyzer().WaitForCompleteAnalysis(_ => true);

                var tree = app.OpenSolutionExplorer();

                const string sln = "Solution 'LoadSearchPaths' (1 project)";
                const string proj = "LoadSearchPaths";
                var sp = SR.GetString(SR.SearchPaths);

                // Entered in file as ..\AddSearchPaths\
                var path1 = tree.WaitForItem(sln, proj, sp, "..\\AddSearchPaths");
                Assert.IsNotNull(path1, "Could not find ..\\AddSearchPaths");

                // Entered in file as ..\HelloWorld
                var path2 = tree.WaitForItem(sln, proj, sp, "..\\HelloWorld");
                Assert.IsNotNull(path2, "Could not find ..\\HelloWorld");

                // Entered in file as ..\LoadSearchPaths\NotHere\..\ - resolves to .\
                var path3 = tree.WaitForItem(sln, proj, sp, ".");
                Assert.IsNotNull(path3, "Could not find .");

                // Entered in file as .\NotHere\
                var path4 = tree.WaitForItem(sln, proj, sp, "NotHere");
                Assert.IsNotNull(path4, "Could not find NotHere");
                Assert.AreEqual("NotHere", path4.Current.Name);

                AutomationWrapper.Select(path4);
                app.ExecuteCommand("Edit.Delete"); // should not prompt, https://pytools.codeplex.com/workitem/1233
                Assert.IsNull(tree.WaitForItemRemoved(sln, proj, sp, "NotHere"));

                // Entered in file as Invalid*Search?Path
                var path5 = tree.WaitForItem(sln, proj, sp, "Invalid*Search?Path");
                Assert.IsNotNull(path5, "Could not find Invalid*Search?Path");
                Assert.AreEqual(path5.Current.Name, "Invalid*Search?Path");

                AutomationWrapper.Select(path5);
                app.ExecuteCommand("Edit.Delete");
                Assert.IsNull(tree.WaitForItemRemoved(sln, proj, sp, "Invalid*Search?Path"));

                // Ensure NotHere hasn't come back
                path4 = tree.WaitForItem(sln, proj, sp, "NotHere");
                Assert.IsNull(path4, "NotHere came back");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:49,代码来源:UITests.cs

示例8: AddNewFolder

        public void AddNewFolder() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                app.OpenSolutionExplorer().SelectProject(project);

                app.ExecuteCommand("Project.NewFolder");
                Keyboard.Type("MyNewFolder");
                Keyboard.PressAndRelease(Key.Enter);

                app.OpenSolutionExplorer().WaitForChildOfProject(project, "MyNewFolder");
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:13,代码来源:UITests.cs

示例9: InstallUninstallPackage

        public void InstallUninstallPackage() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);

                string envName;
                var env = app.CreateVirtualEnvironment(project, out envName);
                env.Select();

                app.ExecuteCommand("Python.InstallPackage", "/p:" + TestPackageSpec);

                var azure = app.SolutionExplorerTreeView.WaitForChildOfProject(
                    project,
                    Strings.Environments,
                    envName,
                    TestPackageDisplay
                );

                azure.Select();

                using (var confirmation = AutomationDialog.FromDte(app, "Edit.Delete")) {
                    confirmation.OK();
                }

                app.SolutionExplorerTreeView.WaitForChildOfProjectRemoved(
                    project,
                    Strings.Environments,
                    envName,
                    TestPackageDisplay
                );
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:32,代码来源:VirtualEnvTests.cs

示例10: WebProjectStaticUri

        public void WebProjectStaticUri() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.CreateProject(
                    PythonVisualStudioApp.TemplateLanguageName,
                    PythonVisualStudioApp.EmptyWebProjectTemplate,
                    TestData.GetTempPath(),
                    "WebProjectStaticUri"
                );

                var proj = project.GetCommonProject();
                Assert.IsNotNull(proj);

                app.ServiceProvider.GetUIThread().Invoke(() => {
                    proj.SetProjectProperty("PythonWsgiHandler", "NoHandler");

                    proj.SetProjectProperty("StaticUriPattern", "");
                    proj.SetProjectProperty("StaticUriRewrite", "");
                });
                app.ExecuteCommand("Build.RebuildSolution");
                app.WaitForOutputWindowText("Build", "1 succeeded");

                var webConfig = File.ReadAllText(Path.Combine(Path.GetDirectoryName(project.FullName), "web.config"));
                if (!webConfig.Contains(@"<add input=""true"" pattern=""false"" />")) {
                    Assert.Fail(string.Format("Did not find Static Files condition in:{0}{0}{1}",
                        Environment.NewLine,
                        webConfig
                    ));
                }

                app.ServiceProvider.GetUIThread().Invoke(() => {
                    proj.SetProjectProperty("StaticUriPattern", "^static/.*$");
                });
                app.ExecuteCommand("Build.RebuildSolution");
                app.WaitForOutputWindowText("Build", "1 succeeded");

                webConfig = File.ReadAllText(Path.Combine(Path.GetDirectoryName(project.FullName), "web.config"));
                if (!webConfig.Contains(@"<add input=""{REQUEST_URI}"" pattern=""^static/.*$"" ignoreCase=""true"" negate=""true"" />")) {
                    Assert.Fail(string.Format("Did not find rewrite condition in:{0}{0}{1}",
                        Environment.NewLine,
                        webConfig
                    ));
                }
                if (!webConfig.Contains(@"<add input=""true"" pattern=""false"" />")) {
                    Assert.Fail(string.Format("Did not find Static Files condition in:{0}{0}{1}",
                        Environment.NewLine,
                        webConfig
                    ));
                }

                app.ServiceProvider.GetUIThread().Invoke(() => {
                    proj.SetProjectProperty("StaticUriRewrite", "static_files/{R:1}");
                });
                app.ExecuteCommand("Build.RebuildSolution");
                app.WaitForOutputWindowText("Build", "1 succeeded");

                webConfig = File.ReadAllText(Path.Combine(Path.GetDirectoryName(project.FullName), "web.config"));
                if (webConfig.Contains(@"<add input=""{REQUEST_URI}"" pattern=""^static/.*$"" ignoreCase=""true"" negate=""true"" />")) {
                    Assert.Fail(string.Format("Found old rewrite condition in:{0}{0}{1}",
                        Environment.NewLine,
                        webConfig
                    ));
                }
                if (!webConfig.Contains(@"<action type=""Rewrite"" url=""static_files/{R:1}"" appendQueryString=""true"" />")) {
                    Assert.Fail(string.Format("Did not find rewrite action in:{0}{0}{1}",
                        Environment.NewLine,
                        webConfig
                    ));
                }
                if (webConfig.Contains(@"<add input=""true"" pattern=""false"" />")) {
                    Assert.Fail(string.Format("Should not have found Static Files condition in:{0}{0}{1}",
                        Environment.NewLine,
                        webConfig
                    ));
                }

                app.ServiceProvider.GetUIThread().Invoke(() => {
                    proj.SetProjectProperty("StaticUriPattern", "invalid[pattern");
                });
                app.ExecuteCommand("Build.RebuildSolution");
                app.WaitForOutputWindowText("Build", "1 failed");
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:82,代码来源:WebProjectTests.cs

示例11: WebProjectEnvironment

        public void WebProjectEnvironment() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\CheckEnvironment.sln");

                var proj = project.GetCommonProject() as IPythonProject;
                Assert.IsNotNull(proj);

                var outFile = Path.Combine(Path.GetDirectoryName(project.FullName), "output.txt");
                                if (File.Exists(outFile)) {
                    File.Delete(outFile);
                }

                app.ServiceProvider.GetUIThread().Invoke(() => {
                    proj.SetProperty("CommandLineArguments", '"' + outFile + '"');
                    proj.SetProperty("Environment", "FOB=123\nOAR=456\r\nBAZ=789");
                });

                app.ExecuteCommand("Debug.StartWithoutDebugging");

                for (int retries = 10; retries > 0 && !File.Exists(outFile); --retries) {
                    Thread.Sleep(300);
                }

                Assert.AreEqual("FOB=123\r\nOAR=456\r\nBAZ=789", File.ReadAllText(outFile).Trim());
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:26,代码来源:WebProjectTests.cs

示例12: MultiLineSignaturesTest

        public void MultiLineSignaturesTest() {
            using (var app = new PythonVisualStudioApp()) {
                var project = app.OpenProject(@"TestData\Signatures.sln");

                var item = project.ProjectItems.Item("multilinesigs.py");
                var window = item.Open();
                window.Activate();

                var doc = app.GetDocument(item.Document.FullName);
                doc.SetFocus();

                ((UIElement)doc.TextView).Dispatcher.Invoke((Action)(() => {
                    var point = doc.TextView.TextBuffer.CurrentSnapshot.GetLineFromLineNumber(5 - 1).Start;
                    doc.TextView.Caret.MoveTo(point);
                    ((UIElement)doc.TextView).Focus();
                }));

                app.ExecuteCommand("Edit.ParameterInfo");

                using (var sh = doc.WaitForSession<ISignatureHelpSession>()) {
                    Assert.AreEqual("b", sh.Session.SelectedSignature.CurrentParameter.Name);
                }
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:24,代码来源:EditorTests.cs


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