本文整理汇总了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");
}
}
示例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"));
}
}
示例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"
);
}
}
示例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");
}
}
示例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"));
}
}
示例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);
}
}
示例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");
}
}
示例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");
}
}
示例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
);
}
}
示例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");
}
}
示例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());
}
}
示例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);
}
}
}