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