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);
            }
        }
Exemple #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);
            }
        }
Exemple #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);
            }
        }
        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());
            }
        }
Exemple #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());
            }
        }
        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);
            }
        }