本文整理汇总了C#中TestUtilities.SharedProject.ProjectDefinition.ToMockVs方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectDefinition.ToMockVs方法的具体用法?C# ProjectDefinition.ToMockVs怎么用?C# ProjectDefinition.ToMockVs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestUtilities.SharedProject.ProjectDefinition
的用法示例。
在下文中一共展示了ProjectDefinition.ToMockVs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicProjectTest
public void BasicProjectTest() {
var sln = new ProjectDefinition(
"HelloWorld",
PythonProject,
Compile("server", "")
).Generate();
using (var vs = sln.ToMockVs()) {
Assert.IsNotNull(vs.WaitForItem("HelloWorld", "Python Environments"));
Assert.IsNotNull(vs.WaitForItem("HelloWorld", "References"));
Assert.IsNotNull(vs.WaitForItem("HelloWorld", "Search Paths"));
Assert.IsNotNull(vs.WaitForItem("HelloWorld", "server.py"));
var view = vs.OpenItem("HelloWorld", "server.py");
view.Invoke(() => view.Type("import "));
using (var sh = view.WaitForSession<ICompletionSession>()) {
AssertUtil.Contains(sh.Session.Completions(), "sys");
}
}
}
示例2: ShouldWarnOnRun
public void ShouldWarnOnRun() {
var sln = new ProjectDefinition(
"HelloWorld",
PythonProject,
Compile("app", "print \"hello\"")
).Generate();
using (var vs = sln.ToMockVs())
using (var analyzerChanged = new AutoResetEvent(false)) {
var project = vs.GetProject("HelloWorld").GetPythonProject();
project.ProjectAnalyzerChanged += (s, e) => analyzerChanged.Set();
var uiThread = (UIThreadBase)project.GetService(typeof(UIThreadBase));
var interpreters = ((IComponentModel)project.GetService(typeof(SComponentModel)))
.GetService<IInterpreterRegistryService>()
.Interpreters;
var v27 = interpreters.Where(x => x.Configuration.Id == "Global|PythonCore|2.7|x86").First();
var v34 = interpreters.Where(x => x.Configuration.Id == "Global|PythonCore|3.4|x86").First();
var interpOptions = (UIThreadBase)project.GetService(typeof(IComponentModel));
uiThread.Invoke(() => {
project.AddInterpreter(v27.Configuration.Id);
project.AddInterpreter(v34.Configuration.Id);
});
project.SetInterpreterFactory(v27);
Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #1");
uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
Assert.IsFalse(project.ShouldWarnOnLaunch, "Should not warn on 2.7");
project.SetInterpreterFactory(v34);
Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #2");
uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
Assert.IsTrue(project.ShouldWarnOnLaunch, "Expected warning on 3.4");
project.SetInterpreterFactory(v27);
Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #3");
uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
Assert.IsFalse(project.ShouldWarnOnLaunch, "Expected warning to go away on 2.7");
}
}
示例3: ShouldWarnOnRun
public void ShouldWarnOnRun() {
var sln = new ProjectDefinition(
"HelloWorld",
PythonProject,
Compile("app", "print \"hello\"")
).Generate();
using (var vs = sln.ToMockVs())
using (var analyzerChanged = new AutoResetEvent(false)) {
var project = vs.GetProject("HelloWorld").GetPythonProject();
project.ProjectAnalyzerChanged += (s, e) => analyzerChanged.Set();
var v27 = InterpreterFactoryCreator.CreateInterpreterFactory(new InterpreterFactoryCreationOptions {
LanguageVersion = new Version(2, 7),
PrefixPath = "C:\\Python27",
InterpreterPath = "C:\\Python27\\python.exe"
});
var v34 = InterpreterFactoryCreator.CreateInterpreterFactory(new InterpreterFactoryCreationOptions {
LanguageVersion = new Version(3, 4),
PrefixPath = "C:\\Python34",
InterpreterPath = "C:\\Python34\\python.exe"
});
var uiThread = (UIThreadBase)project.GetService(typeof(UIThreadBase));
uiThread.Invoke(() => {
project.Interpreters.AddInterpreter(v27);
project.Interpreters.AddInterpreter(v34);
});
project.SetInterpreterFactory(v27);
Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #1");
uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
Assert.IsFalse(project.ShouldWarnOnLaunch, "Should not warn on 2.7");
project.SetInterpreterFactory(v34);
Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #2");
uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
Assert.IsTrue(project.ShouldWarnOnLaunch, "Expected warning on 3.4");
project.SetInterpreterFactory(v27);
Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #3");
uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
Assert.IsFalse(project.ShouldWarnOnLaunch, "Expected warning to go away on 2.7");
}
}