Esempio n. 1
0
            public void ShouldReturnOnlyLastValueOfVariablesDeclaredManyTimes([NoAutoProperties] RoslynReplEngine engine, ScriptPackSession scriptPackSession)
            {
                var session = new SessionState <Session> {
                    Session = new ScriptEngine().CreateSession()
                };

                scriptPackSession.State[RoslynScriptEngine.SessionKey] = session;

                engine.Execute("int x = 1;", new string[0], new AssemblyReferences(), Enumerable.Empty <string>(), scriptPackSession);
                engine.Execute("int x = 2;", new string[0], new AssemblyReferences(), Enumerable.Empty <string>(), scriptPackSession);

                engine.GetLocalVariables(scriptPackSession).ShouldEqual(new Collection <string> {
                    "System.Int32 x = 2"
                });
            }
Esempio n. 2
0
            public void ShouldReturn0VariablesAfterReset([NoAutoProperties] RoslynReplEngine engine, ScriptPackSession scriptPackSession)
            {
                var session = new SessionState <Session> {
                    Session = new ScriptEngine().CreateSession()
                };

                scriptPackSession.State[RoslynScriptEngine.SessionKey] = session;

                engine.Execute("int x = 1;", new string[0], new AssemblyReferences(), Enumerable.Empty <string>(),
                               scriptPackSession);
                engine.Execute(@"var y = ""www"";", new string[0], new AssemblyReferences(), Enumerable.Empty <string>(),
                               scriptPackSession);

                scriptPackSession.State[RoslynScriptEngine.SessionKey] = new SessionState <Session> {
                    Session = new ScriptEngine().CreateSession()
                };

                engine.GetLocalVariables(scriptPackSession).ShouldBeEmpty();
            }
Esempio n. 3
0
            public void ShouldSetIsCompleteSubmissionToFalseIfCodeIsMissingParenthesis(
                [NoAutoProperties] RoslynReplEngine engine,
                ScriptPackSession scriptPackSession)
            {
                // Arrange
                const string Code = "System.Diagnostics.Debug.WriteLine(\"a\"";

                var session = new SessionState <Session> {
                    Session = new ScriptEngine().CreateSession()
                };

                scriptPackSession.State[RoslynScriptEngine.SessionKey] = session;
                var refs = new AssemblyReferences(new[] { "System" });

                // Act
                var result = engine.Execute(Code, new string[0], refs, Enumerable.Empty <string>(), scriptPackSession);

                // Assert
                result.IsCompleteSubmission.ShouldBeFalse();
            }
            public void ShouldSetIsCompleteSubmissionToFalseIfCodeIsMissingCurlyBracket(
                [NoAutoProperties] RoslynReplEngine engine, ScriptPackSession scriptPackSession)
            {
                // Arrange
                const string Code = "class test {";

                var session = new SessionState <Session> {
                    Session = new ScriptEngine().CreateSession()
                };

                scriptPackSession.State[RoslynScriptEngine.SessionKey] = session;
                var refs = new AssemblyReferences();

                refs.PathReferences.Add("System");

                // Act
                var result = engine.Execute(
                    Code, new string[0], refs, Enumerable.Empty <string>(), scriptPackSession);

                // Assert
                result.IsCompleteSubmission.ShouldBeFalse();
            }