本文整理汇总了C#中TestUtilities.UI.Python.PythonVisualStudioApp.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# PythonVisualStudioApp.AddItem方法的具体用法?C# PythonVisualStudioApp.AddItem怎么用?C# PythonVisualStudioApp.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestUtilities.UI.Python.PythonVisualStudioApp
的用法示例。
在下文中一共展示了PythonVisualStudioApp.AddItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WebProjectAddSupportFiles
public void WebProjectAddSupportFiles() {
using (var app = new PythonVisualStudioApp()) {
var project = app.CreateProject(
PythonVisualStudioApp.TemplateLanguageName,
PythonVisualStudioApp.EmptyWebProjectTemplate,
TestData.GetTempPath(),
"WebProjectAddSupportFiles"
);
var proj = project.GetCommonProject();
Assert.IsNotNull(proj);
var previousItems = project.ProjectItems.Cast<ProjectItem>().Select(p => p.Name).ToSet(StringComparer.CurrentCultureIgnoreCase);
// Add the items
app.AddItem(project, PythonVisualStudioApp.TemplateLanguageName, PythonVisualStudioApp.WebRoleSupportTemplate, "bin");
var newItems = project.ProjectItems.Cast<ProjectItem>().Where(p => !previousItems.Contains(p.Name)).ToList();
AssertUtil.ContainsExactly(newItems.Select(i => i.Name), "bin");
var children = newItems[0].ProjectItems.Cast<ProjectItem>().Select(i => i.Name).ToSet(StringComparer.CurrentCultureIgnoreCase);
AssertUtil.ContainsExactly(children, "ConfigureCloudService.ps1", "ps.cmd", "Readme.mht");
}
}
示例2: WorkerProjectAddSupportFiles
public void WorkerProjectAddSupportFiles() {
using (var app = new PythonVisualStudioApp()) {
var project = app.CreateProject(
PythonVisualStudioApp.TemplateLanguageName,
PythonVisualStudioApp.PythonApplicationTemplate,
TestData.GetTempPath(),
"WorkerProjectAddSupportFiles"
);
// Ensure the bin directory already exists
Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(project.FullName), "bin"));
var previousItems = project.ProjectItems.Cast<ProjectItem>().Select(p => p.Name).ToSet(StringComparer.CurrentCultureIgnoreCase);
// Add the items
app.AddItem(project, PythonVisualStudioApp.TemplateLanguageName, PythonVisualStudioApp.WorkerRoleSupportTemplate, "bin");
var newItems = project.ProjectItems.Cast<ProjectItem>().Where(p => !previousItems.Contains(p.Name)).ToList();
AssertUtil.ContainsExactly(newItems.Select(i => i.Name), "bin");
var children = newItems[0].ProjectItems.Cast<ProjectItem>().Select(i => i.Name).ToSet(StringComparer.CurrentCultureIgnoreCase);
AssertUtil.ContainsExactly(children, "ConfigureCloudService.ps1", "LaunchWorker.ps1", "ps.cmd", "Readme.mht");
}
}
示例3: WebProjectBuildWarnings
public void WebProjectBuildWarnings() {
using (var app = new PythonVisualStudioApp())
using (app.SelectDefaultInterpreter(PythonPaths.Python33 ?? PythonPaths.Python33_x64)) {
var project = app.CreateProject(
PythonVisualStudioApp.TemplateLanguageName,
PythonVisualStudioApp.EmptyWebProjectTemplate,
TestData.GetTempPath(),
"WebProjectBuildWarnings"
);
var proj = project.GetPythonProject();
Assert.IsNotNull(proj);
Assert.AreEqual(new Version(3, 3), app.ServiceProvider.GetUIThread().Invoke(() => proj.GetLaunchConfigurationOrThrow().Interpreter.Version));
for (int iteration = 0; iteration <= 2; ++iteration) {
var warnings = app.ServiceProvider.GetUIThread().Invoke(() => {
var buildPane = app.GetOutputWindow("Build");
buildPane.Clear();
project.DTE.Solution.SolutionBuild.Clean(true);
project.DTE.Solution.SolutionBuild.Build(true);
var text = app.GetOutputWindowText("Build");
Console.WriteLine(text);
return text.Split('\r', '\n')
.Select(s => Regex.Match(s, @"warning\s*:\s*(?<msg>.+)"))
.Where(m => m.Success)
.Select(m => m.Groups["msg"].Value)
.ToList();
});
Console.WriteLine("Warnings:{0}{1}", Environment.NewLine, string.Join(Environment.NewLine, warnings));
if (iteration < 2) {
Assert.IsNotNull(
warnings.FirstOrDefault(s => Regex.IsMatch(s, @"Python( 64-bit)? 3\.3 is not natively supported.+")),
"Missing \"not natively supported\" warning"
);
} else {
// Third time through, we've fixed this warning.
Assert.IsNull(
warnings.FirstOrDefault(s => Regex.IsMatch(s, @"Python( 64-bit)? 3\.3 is not natively supported.+")),
"Still recieved \"not natively supported\" warning"
);
}
if (iteration < 1) {
Assert.IsNotNull(
warnings.FirstOrDefault(s => Regex.IsMatch(s, "Using old configuration tools.+")),
"Missing \"old configuration tools\" warning"
);
} else {
// Second time through, we've fixed this warning.
Assert.IsNull(
warnings.FirstOrDefault(s => Regex.IsMatch(s, "Using old configuration tools.+")),
"Still received \"old configuration tools\" warning"
);
}
switch (iteration) {
case 0:
app.AddItem(project, PythonVisualStudioApp.TemplateLanguageName, PythonVisualStudioApp.WebRoleSupportTemplate, "bin");
break;
case 1:
var model = app.GetService<IComponentModel>(typeof(SComponentModel));
var interpreterService = model.GetService<IInterpreterRegistryService>();
var optionsService = model.GetService<IInterpreterOptionsService>();
var newInterpreter = interpreterService.FindInterpreter("Global|PythonCore|3.4|x86")
?? interpreterService.FindInterpreter("Global|PythonCore|2.7|x86");
Assert.IsNotNull(newInterpreter);
optionsService.DefaultInterpreter = newInterpreter;
break;
}
}
}
}