예제 #1
0
 protected static void AssertSucceeded(ConsoleOutput output)
 {
     Assert.True(0 == output.ExitCode,
                 $"Exit code: {output.ExitCode}\n{output.Stdout}");
 }
        /// <summary>Runs StorageSample.exe with the provided arguments</summary>
        /// <returns>The console output of this program</returns>
        public ConsoleOutput Run(params string[] arguments)
        {
            Console.Write($"{Command} ");
            Console.WriteLine(string.Join(" ", arguments));

            TextWriter consoleOut = Console.Out;
            StringWriter stringOut = new StringWriter();
            Console.SetOut(stringOut);
            try
            {
                int exitCode = 0;
                if (null == VoidMain)
                    exitCode = Main(arguments);
                else
                    VoidMain(arguments);
                var consoleOutput = new ConsoleOutput()
                {
                    ExitCode = exitCode,
                    Stdout = stringOut.ToString()
                };
                Console.Write(consoleOutput.Stdout);
                return consoleOutput;
            }
            finally
            {
                Console.SetOut(consoleOut);
            }
        }