Exemple #1
0
        public void VerifySyntaxWithMultipleSyntaxErrors()
        {
            var projects = new Mock <ILinkScriptsToProjects>();

            using (var writer = new ScriptOutputPipe())
            {
                writer.OnScriptOutput += (s, e) => { };

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

                var script = "prin 10" + Environment.NewLine + "prin 20";
                var errors = runner.VerifySyntax(script);
                Assert.AreEqual(2, errors.Count());

                var error = errors.First();
                Assert.AreEqual(1, error.Line);
                Assert.AreEqual(6, error.Column);
                Assert.AreEqual(SyntaxVerificationSeverity.Error, error.Severity);

                error = errors.Last();
                Assert.AreEqual(2, error.Line);
                Assert.AreEqual(6, error.Column);
                Assert.AreEqual(SyntaxVerificationSeverity.Error, error.Severity);
            }
        }
Exemple #2
0
        public void VerifySyntaxWithoutSyntaxErrors()
        {
            var projects = new Mock <ILinkScriptsToProjects>();

            using (var writer = new ScriptOutputPipe())
            {
                writer.OnScriptOutput += (s, e) => { };

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

                var script = "print \"Hello\"";
                var errors = runner.VerifySyntax(script);
                Assert.AreEqual(0, errors.Count());
            }
        }
        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 #4
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);
            }
        }
        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);
            }
        }
Exemple #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);
            }
        }
        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 #8
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 VerifySyntaxWithMultipleSyntaxErrors()
        {
            var projects = new Mock<ILinkScriptsToProjects>();
            using (var writer = new ScriptOutputPipe())
            {
                writer.OnScriptOutput += (s, e) => { };

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

                var script = "prin 10" + Environment.NewLine + "prin 20";
                var errors = runner.VerifySyntax(script);
                Assert.AreEqual(2, errors.Count());

                var error = errors.First();
                Assert.AreEqual(1, error.Line);
                Assert.AreEqual(6, error.Column);
                Assert.AreEqual(SyntaxVerificationSeverity.Error, error.Severity);

                error = errors.Last();
                Assert.AreEqual(2, error.Line);
                Assert.AreEqual(6, error.Column);
                Assert.AreEqual(SyntaxVerificationSeverity.Error, error.Severity);
            }
        }
        public void VerifySyntaxWithoutSyntaxErrors()
        {
            var projects = new Mock<ILinkScriptsToProjects>();
            using (var writer = new ScriptOutputPipe())
            {
                writer.OnScriptOutput += (s, e) => { };

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

                var script = "print \"Hello\"";
                var errors = runner.VerifySyntax(script);
                Assert.AreEqual(0, errors.Count());
            }
        }