public void ShouldAddNewReferencesIfTheyAreProvided(
                [Frozen] Mock <IScriptHostFactory> scriptHostFactory,
                [NoAutoProperties] MonoTestScriptEngine engine,
                ScriptPackSession scriptPackSession)
            {
                // Arrange
                const string Code = "var a = 0;";

                scriptHostFactory.Setup(f => f.CreateScriptHost(It.IsAny <IScriptPackManager>(), It.IsAny <string[]>()))
                .Returns <IScriptPackManager, string[]>((p, q) => new ScriptHost(p, new ScriptEnvironment(q)));

                var session = new SessionState <Evaluator> {
                    Session = new Evaluator(new CompilerContext(new CompilerSettings(), new ConsoleReportPrinter()))
                };

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

                refs.PathReferences.Add("System");

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

                // Assert
                ((SessionState <Evaluator>)scriptPackSession.State[MonoScriptEngine.SessionKey]).References.PathReferences.Count().ShouldEqual(1);
            }
            public void ShouldCreateNewSessionIfNotProvided(
                [Frozen] Mock <IScriptHostFactory> scriptHostFactory,
                [NoAutoProperties] MonoTestScriptEngine engine,
                ScriptPackSession scriptPackSession)
            {
                // Arrange
                const string Code = "var a = 0;";

                scriptHostFactory.Setup(f => f.CreateScriptHost(It.IsAny <IScriptPackManager>(), It.IsAny <string[]>()))
                .Returns <IScriptPackManager, string[]>((p, q) => new ScriptHost(p, new ScriptEnvironment(q, _console, _printers)));

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

                // Assert
                engine.Session.ShouldNotBeNull();
            }
            public void ShouldReuseExistingSessionIfProvided(
                [Frozen] Mock <IScriptHostFactory> scriptHostFactory,
                [NoAutoProperties] MonoTestScriptEngine engine,
                ScriptPackSession scriptPackSession)
            {
                // Arrange
                const string Code = "var a = 0;";

                scriptHostFactory.Setup(f => f.CreateScriptHost(It.IsAny <IScriptPackManager>(), It.IsAny <string[]>()))
                .Returns <IScriptPackManager, string[]>((p, q) => new ScriptHost(p, new ScriptEnvironment(q, _console, _printers)));

                var session = new SessionState <Evaluator> {
                    Session = new Evaluator(new CompilerContext(new CompilerSettings(), new ConsoleReportPrinter()))
                };

                scriptPackSession.State[MonoScriptEngine.SessionKey] = session;

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

                // Assert
                engine.Session.ShouldEqual(session.Session);
            }