public void ConsoleApplicationMultipleExecutionAndRecycling_ShouldProvide_SameResult()
        {
            var expectedOutput = "Hi";
            var codeSnipet     = $@"Console.Write(""{expectedOutput}"");";
            var code           = string.Format(ConsoleAppTemplate, codeSnipet);

            List <string> executionResults = new List <string>();

            using (var compiler = new ConsoleApplicationEmulator())
            {
                for (int i = 0; i < 50; i++)
                {
                    compiler.Compile(code);
                    var result = compiler.RunAsync().Result;
                    Assert.IsTrue(result.Success);
                    executionResults.Add(result.ConsoleOutput);
                    result = compiler.RunAsync().Result;
                    compiler.Recycle();
                    Assert.IsTrue(result.Success);
                    executionResults.Add(result.ConsoleOutput);
                }
            }

            Assert.IsTrue(executionResults.All(actual => actual == expectedOutput));
        }
        private static ConsoleExecutionResult CompileAndRun(string code, long maxExecutionTimeMs = long.MaxValue)
        {
            ConsoleExecutionResult executionResult;

            using (var compiler = new ConsoleApplicationEmulator(maxExecutionTimeMs))
            {
                compiler.Compile(code);
                executionResult = compiler.RunAsync().Result;
            }

            return(executionResult);
        }