本文整理汇总了C#中TestUtilities.Mocks.MockReplWindow类的典型用法代码示例。如果您正苦于以下问题:C# MockReplWindow类的具体用法?C# MockReplWindow怎么用?C# MockReplWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockReplWindow类属于TestUtilities.Mocks命名空间,在下文中一共展示了MockReplWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestInit
public void TestInit() {
Version.AssertInstalled();
var serviceProvider = PythonToolsTestUtilities.CreateMockServiceProvider();
_evaluator = new PythonDebugReplEvaluator(serviceProvider);
_window = new MockReplWindow(_evaluator);
_evaluator._Initialize(_window);
_processes = new List<PythonProcess>();
}
示例2: TestNumber
public void TestNumber() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("42");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual(window.Output, "42");
}
}
示例3: TestRequire
public void TestRequire() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("require('http').constructor");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("[Function: Object]", window.Output);
}
}
示例4: IronPythonModuleName
public void IronPythonModuleName() {
var replEval = new PythonReplEvaluator(IronPythonInterpreter, PythonToolsTestUtilities.CreateMockServiceProvider(), new ReplTestReplOptions());
var replWindow = new MockReplWindow(replEval);
replEval._Initialize(replWindow).Wait();
replWindow.ClearScreen();
var execute = replEval.ExecuteText("__name__");
execute.Wait();
Assert.IsTrue(execute.Result.IsSuccessful);
Assert.AreEqual(replWindow.Output, "'__main__'\r\n");
replWindow.ClearScreen();
}
示例5: IronPythonModuleName
public void IronPythonModuleName() {
using (var replEval = Evaluator) {
var replWindow = new MockReplWindow(replEval);
replEval._Initialize(replWindow).Wait();
replWindow.ClearScreen();
var execute = replEval.ExecuteText("__name__");
execute.Wait();
Assert.IsTrue(execute.Result.IsSuccessful);
Assert.AreEqual(replWindow.Output, "'__main__'\n");
replWindow.ClearScreen();
}
}
示例6: IronPythonSignatures
public void IronPythonSignatures() {
var replEval = new PythonReplEvaluator(IronPythonInterpreter, PythonToolsTestUtilities.CreateMockServiceProvider(), new ReplTestReplOptions());
var replWindow = new MockReplWindow(replEval);
replEval._Initialize(replWindow).Wait();
var execute = replEval.ExecuteText("from System import Array");
execute.Wait();
Assert.IsTrue(execute.Result.IsSuccessful);
OverloadDoc[] sigs = null;
for (int retries = 0; retries < 5 && sigs == null; retries += 1) {
sigs = replEval.GetSignatureDocumentation("Array[int]");
}
Assert.IsNotNull(sigs, "GetSignatureDocumentation timed out");
Assert.AreEqual(sigs.Length, 1);
Assert.AreEqual("Array[int](: int)\r\n", sigs[0].Documentation);
}
示例7: IronPythonSignatures
public void IronPythonSignatures() {
using (var replEval = Evaluator) {
var replWindow = new MockReplWindow(replEval);
replEval._Initialize(replWindow).Wait();
var execute = replEval.ExecuteText("from System import Array");
execute.Wait();
Assert.IsTrue(execute.Result.IsSuccessful);
OverloadDoc[] sigs = null;
for (int retries = 0; retries < 5 && sigs == null; retries += 1) {
sigs = replEval.GetSignatureDocumentation("Array[int]");
}
Assert.IsNotNull(sigs, "GetSignatureDocumentation timed out");
Assert.AreEqual(sigs.Length, 1);
Assert.AreEqual("Array[int](: int)\r\n", sigs[0].Documentation);
}
}
示例8: TestFunctionDefinition
public void TestFunctionDefinition() {
var whitespaces = new[] { "", "\r\n", " ", "\r\n " };
using (var eval = ProjectlessEvaluator()) {
foreach (var whitespace in whitespaces) {
Console.WriteLine("Whitespace: {0}", whitespace);
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText(whitespace + "function f() { }");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("undefined", window.Output);
window.ClearScreen();
res = eval.ExecuteText("f");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("[Function: f]", window.Output);
}
}
}
示例9: TestVarI
public void TestVarI() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("i");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("ReferenceError: i is not defined", window.Error);
Assert.AreEqual("", window.Output);
res = eval.ExecuteText("var i = 987654;");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("undefined", window.Output);
res = eval.ExecuteText("i");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("undefined987654", window.Output);
}
}
示例10: TestBadSave
public void TestBadSave() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("function f() { }");
Assert.IsTrue(res.Wait(10000));
res = eval.ExecuteText("function g() { }");
Assert.IsTrue(res.Wait(10000));
new SaveReplCommand().Execute(window, "C:\\Some\\Directory\\That\\Does\\Not\\Exist\\foo.js").Wait(10000);
Assert.IsTrue(window.Error.Contains("Failed to save: "));
}
}
示例11: TestSave
public void TestSave() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval, NodejsConstants.JavaScript);
window.ClearScreen();
var res = window.Execute("function f() { }");
Assert.IsTrue(res.Wait(10000));
res = window.Execute("function g() { }");
Assert.IsTrue(res.Wait(10000));
var path = Path.GetTempFileName();
File.Delete(path);
new SaveReplCommand().Execute(window, path).Wait(10000);
Assert.IsTrue(File.Exists(path));
var saved = File.ReadAllText(path);
Assert.IsTrue(saved.IndexOf("function f") != -1);
Assert.IsTrue(saved.IndexOf("function g") != -1);
Assert.IsTrue(window.Output.Contains("Session saved to:"));
}
}
示例12: TestSaveBadFile
public void TestSaveBadFile() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("function f() { }");
Assert.IsTrue(res.Wait(10000));
res = eval.ExecuteText("function g() { }");
Assert.IsTrue(res.Wait(10000));
new SaveReplCommand().Execute(window, "<foo>").Wait(10000);
Assert.IsTrue(window.Error.Contains("Invalid filename: <foo>"));
}
}
示例13: TestReset
public void TestReset() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("1");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("1", window.Output);
res = window.Reset();
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("The process has exited" + Environment.NewLine, window.Error);
window.ClearScreen();
Assert.AreEqual("", window.Output);
Assert.AreEqual("", window.Error);
//Check to ensure the REPL continues to work after Reset
res = eval.ExecuteText("var a = 1");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("undefined", window.Output);
res = eval.ExecuteText("a");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("undefined1", window.Output);
}
}
示例14: TestRequireInProject
public void TestRequireInProject() {
string testDir;
do {
testDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
} while (Directory.Exists(testDir));
Directory.CreateDirectory(testDir);
var moduleDir = Path.Combine(testDir, "node_modules");
Directory.CreateDirectory(moduleDir);
File.WriteAllText(Path.Combine(moduleDir, "foo.js"), "exports.foo = function(a, b, c) { }");
File.WriteAllText(Path.Combine(testDir, "bar.js"), "exports.bar = function(a, b, c) { }");
try {
using (var eval = new NodejsReplEvaluator(new TestNodejsReplSite(null, testDir))) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("require('foo.js');");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual(window.Output, "{ foo: [Function] }");
window.ClearScreen();
res = eval.ExecuteText("require('./bar.js');");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual(window.Output, "{ bar: [Function] }");
}
} finally {
try {
Directory.Delete(testDir, true);
} catch (IOException) {
}
}
}
示例15: LargeOutput
public void LargeOutput() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("var x = 'abc'; for(i = 0; i<12; i++) { x += x; }; x");
string expected = "abc";
for (int i = 0; i < 12; i++) {
expected += expected;
}
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("'" + expected + "'", window.Output);
}
}