Beispiel #1
0
        private void RunSingleTest(MethodInfo methodInfo, string inputFile, string outputFile)
        {
            Console.SetIn(File.OpenText(inputFile));
            var actualOutput        = new StringWriter();
            var expectedOutputLines = FileWithoutLock.ReadAllLines(outputFile).Select(l => l.Replace("\r\n", string.Empty)).ToArray();

            Console.SetOut(actualOutput);
            methodInfo.Invoke(null, null);
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput())
            {
                AutoFlush = true
            });

            var actualOutputLines = new StringReader(actualOutput.ToString()).ReadAllLines()
                                    .Select(l => l.Replace("\r\n", string.Empty)).ToArray();
            var success     = CompareOutput(actualOutputLines, expectedOutputLines);
            var sucessLabel = success ? "OK" : "KO";

            Console.WriteLineStyled($"[{Path.GetFileName(_sourceCodeFile)}] Running test : {Path.GetFileName(inputFile)} {sucessLabel}", _styleSheet);

            if (!success)
            {
                PrintDiff(expectedOutputLines, actualOutputLines);
            }
        }