本文整理汇总了C#中TestUtilities.Mocks.MockReplWindow类的典型用法代码示例。如果您正苦于以下问题:C# MockReplWindow类的具体用法?C# MockReplWindow怎么用?C# MockReplWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockReplWindow类属于TestUtilities.Mocks命名空间,在下文中一共展示了MockReplWindow类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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>();
}
开发者ID:sadapple,项目名称:PTVS,代码行数:8,代码来源:DebugReplEvaluatorTests.cs
示例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");
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:9,代码来源:ReplWindowTests.cs
示例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);
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:9,代码来源:ReplWindowTests.cs
示例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();
}
开发者ID:wenh123,项目名称:PTVS,代码行数:11,代码来源:ReplEvaluatorTests.cs
示例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();
}
}
开发者ID:jsschultz,项目名称:PTVS,代码行数:12,代码来源:ReplEvaluatorTests.cs
示例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);
}
开发者ID:wenh123,项目名称:PTVS,代码行数:16,代码来源:ReplEvaluatorTests.cs
示例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);
}
}
开发者ID:jsschultz,项目名称:PTVS,代码行数:17,代码来源:ReplEvaluatorTests.cs
示例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);
}
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:18,代码来源:ReplWindowTests.cs
示例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);
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:17,代码来源:ReplWindowTests.cs
示例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: "));
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:16,代码来源:ReplWindowTests.cs
示例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:"));
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:24,代码来源:ReplWindowTests.cs
示例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>"));
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:16,代码来源:ReplWindowTests.cs
示例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);
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:25,代码来源:ReplWindowTests.cs
示例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) {
}
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:31,代码来源:ReplWindowTests.cs
示例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);
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:14,代码来源:ReplWindowTests.cs
示例16: TestConsoleDir
public void TestConsoleDir() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("console.dir({'abc': {'foo': [1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40]}})");
var expected = @"{ abc:
{ foo:
[ 1,
2,
3,
4,
5,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40 ] } }
undefined";
Assert.IsTrue(res.Wait(10000));
var received = window.Output;
AreEqual(expected, received);
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:52,代码来源:ReplWindowTests.cs
示例17: TestObjectLiteral
public void TestObjectLiteral() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("{x:42}");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("{ x: 42 }", window.Output);
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:9,代码来源:ReplWindowTests.cs
示例18: TestNpmReplRedirector
public void TestNpmReplRedirector() {
using (var eval = ProjectlessEvaluator()) {
var mockWindow = new MockReplWindow(eval) {
ShowAnsiCodes = true
};
mockWindow.ClearScreen();
var redirector = new NpmReplCommand.NpmReplRedirector(mockWindow);
redirector.WriteLine("npm The sky is at a stable equilibrium");
var expectedInfoLine =
NpmReplCommand.NpmReplRedirector.NormalAnsiColor + "npm The sky is at a stable equilibrium" +
Environment.NewLine;
Assert.AreEqual(expectedInfoLine, mockWindow.Output);
Assert.IsFalse(redirector.HasErrors);
mockWindow.ClearScreen();
redirector.WriteLine("npm WARN The sky is at an unstable equilibrium!");
var expectedWarnLine =
NpmReplCommand.NpmReplRedirector.WarnAnsiColor + "npm WARN" +
NpmReplCommand.NpmReplRedirector.NormalAnsiColor + " The sky is at an unstable equilibrium!" +
Environment.NewLine;
Assert.AreEqual(expectedWarnLine, mockWindow.Output);
Assert.IsFalse(redirector.HasErrors);
mockWindow.ClearScreen();
redirector.WriteLine("npm ERR! The sky is falling!");
var expectedErrorLine =
NpmReplCommand.NpmReplRedirector.ErrorAnsiColor + "npm ERR!" +
NpmReplCommand.NpmReplRedirector.NormalAnsiColor + " The sky is falling!" +
Environment.NewLine;
Assert.AreEqual(expectedErrorLine, mockWindow.Output);
Assert.IsTrue(redirector.HasErrors);
mockWindow.ClearScreen();
var decodedInfoLine = "├── [email protected]";
string encodedText = Console.OutputEncoding.GetString(Encoding.UTF8.GetBytes(decodedInfoLine));
redirector.WriteLine(encodedText);
var expectedDecodedInfoLine = NpmReplCommand.NpmReplRedirector.NormalAnsiColor + decodedInfoLine
+ Environment.NewLine;
Assert.AreEqual(expectedDecodedInfoLine, mockWindow.Output);
Assert.IsTrue(redirector.HasErrors, "Errors should remain until end");
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:46,代码来源:ReplWindowTests.cs
示例19: TestNpmReplCommandProcessExitSucceeds
public async Task TestNpmReplCommandProcessExitSucceeds() {
var npmPath = Nodejs.GetPathToNodeExecutable("npm.cmd");
using (var eval = ProjectlessEvaluator()) {
var mockWindow = new MockReplWindow(eval) {
ShowAnsiCodes = true
};
mockWindow.ClearScreen();
var redirector = new NpmReplCommand.NpmReplRedirector(mockWindow);
for (int j = 0; j < 200; j++) {
await NpmReplCommand.ExecuteNpmCommandAsync(
redirector,
npmPath,
null,
new[] {"config", "get", "registry"},
null);
}
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:19,代码来源:ReplWindowTests.cs
示例20: TestProcessExit
public void TestProcessExit() {
using (var eval = ProjectlessEvaluator()) {
var window = new MockReplWindow(eval);
window.ClearScreen();
var res = eval.ExecuteText("process.exit(0);");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("The process has exited" + Environment.NewLine, window.Error);
window.ClearScreen();
res = eval.ExecuteText("42");
Assert.IsTrue(res.Wait(10000));
Assert.AreEqual("Current interactive window is disconnected - please reset the process.\r\n", window.Error);
}
}
开发者ID:mauricionr,项目名称:nodejstools,代码行数:16,代码来源:ReplWindowTests.cs
注:本文中的TestUtilities.Mocks.MockReplWindow类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论