當前位置: 首頁>>代碼示例>>C#>>正文


C# Mocks.MockReplWindow類代碼示例

本文整理匯總了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>();
 }
開發者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


注:本文中的TestUtilities.Mocks.MockReplWindow類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。