Пример #1
0
        public void ExecuteWithExecutionFailure()
        {
            var projects = new Mock<ILinkScriptsToProjects>();
            using (var writer = new ScriptOutputPipe())
            {
                bool hasOutput = false;
                writer.OnScriptOutput += (s, e) => hasOutput = true;

                var engine = Python.CreateEngine();
                var runner = new RemoteScriptRunner(projects.Object, writer, engine);

                var script = "foobar()";
                Assert.Throws<ScriptExecutionFailureException>(() => runner.Execute(script, new CancelScriptToken()));
                Assert.IsFalse(hasOutput);
            }
        }
Пример #2
0
        public void ExecuteWithExecutionFailure()
        {
            var projects = new Mock <ILinkScriptsToProjects>();

            using (var writer = new ScriptOutputPipe())
            {
                bool hasOutput = false;
                writer.OnScriptOutput += (s, e) => hasOutput = true;

                var engine = Python.CreateEngine();
                var runner = new RemoteScriptRunner(projects.Object, writer, engine);

                var script = "foobar()";
                Assert.Throws <ScriptExecutionFailureException>(() => runner.Execute(script, new CancelScriptToken()));
                Assert.IsFalse(hasOutput);
            }
        }
Пример #3
0
        public void ExecuteWithOutput()
        {
            var projects = new Mock <ILinkScriptsToProjects>();

            using (var writer = new ScriptOutputPipe())
            {
                var output = string.Empty;
                writer.OnScriptOutput += (s, e) => output += e.Text;

                var engine = Python.CreateEngine();
                var runner = new RemoteScriptRunner(projects.Object, writer, engine);

                var script = "print \"Hello\"";
                runner.Execute(script, new CancelScriptToken());

                Assert.AreEqual("Hello" + Environment.NewLine, output);
            }
        }
Пример #4
0
        public void ExecuteWithoutOutput()
        {
            var projects = new Mock<ILinkScriptsToProjects>();
            {
                projects.Setup(p => p.NewProject())
                    .Verifiable();
            }

            using (var writer = new ScriptOutputPipe())
            {
                bool hasOutput = false;
                writer.OnScriptOutput += (s, e) => hasOutput = true;

                var engine = Python.CreateEngine();
                var runner = new RemoteScriptRunner(projects.Object, writer, engine);

                var script = "projects.NewProject()";
                runner.Execute(script, new CancelScriptToken());

                Assert.IsFalse(hasOutput);
                projects.Verify(p => p.NewProject(), Times.Once());
            }
        }
Пример #5
0
        public void ExecuteWithoutOutput()
        {
            var projects = new Mock <ILinkScriptsToProjects>();

            {
                projects.Setup(p => p.NewProject())
                .Verifiable();
            }

            using (var writer = new ScriptOutputPipe())
            {
                bool hasOutput = false;
                writer.OnScriptOutput += (s, e) => hasOutput = true;

                var engine = Python.CreateEngine();
                var runner = new RemoteScriptRunner(projects.Object, writer, engine);

                var script = "projects.NewProject()";
                runner.Execute(script, new CancelScriptToken());

                Assert.IsFalse(hasOutput);
                projects.Verify(p => p.NewProject(), Times.Once());
            }
        }
Пример #6
0
        public void ExecuteWithOutput()
        {
            var projects = new Mock<ILinkScriptsToProjects>();
            using (var writer = new ScriptOutputPipe())
            {
                var output = string.Empty;
                writer.OnScriptOutput += (s, e) => output += e.Text;

                var engine = Python.CreateEngine();
                var runner = new RemoteScriptRunner(projects.Object, writer, engine);

                var script = "print \"Hello\"";
                runner.Execute(script, new CancelScriptToken());

                Assert.AreEqual("Hello" + Environment.NewLine, output);
            }
        }