public void ShouldReturnOnlyLastValueOfVariablesDeclaredManyTimes([NoAutoProperties] MonoScriptEngine engine, ScriptPackSession scriptPackSession) { var session = new SessionState <Evaluator> { Session = new Evaluator(new CompilerContext(new CompilerSettings(), new ConsoleReportPrinter())) }; scriptPackSession.State[MonoScriptEngine.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> { "int x = 2" }); }
public void ShouldReturn0VariablesAfterReset([NoAutoProperties] MonoScriptEngine engine, ScriptPackSession scriptPackSession) { var session = new SessionState <Evaluator> { Session = new Evaluator(new CompilerContext(new CompilerSettings(), new ConsoleReportPrinter())) }; scriptPackSession.State[MonoScriptEngine.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[MonoScriptEngine.SessionKey] = new SessionState <Evaluator> { Session = new Evaluator(new CompilerContext(new CompilerSettings(), new ConsoleReportPrinter())) }; engine.GetLocalVariables(scriptPackSession).ShouldBeEmpty(); }