/// <summary>
        /// Outputs the results to an appropriate file or stdout.
        /// </summary>
        /// <param name="results">The test results.</param>
        /// <param name="cla">The command line arguments.</param>
        /// <exception cref="Exception">Output format must be specified.</exception>
        public void OutputResults(ParsedData results, CommandLineArguments cla)
        {
            using (Stream s = cla.OutputFilename == null ? Console.OpenStandardOutput() : new FileStream(cla.OutputFilename, FileMode.Create))
            {
                ITestResultWriter writer = null;
                switch (cla.OutputFormat)
                {
                    case OutputFormat.CSV:
                        writer = new CSVTestResultWriter();
                        break;
                    case OutputFormat.Json:
                        writer = new JSONTestResultWriter();
                        break;
                    case OutputFormat.KVP:
                        writer = new KVPTestResultWriter();
                        break;
                    case OutputFormat.Xlsx:
                        writer = new XLSXWriter(cla.YellowBand, cla.GreenBand);
                        break;
                    default:
                        throw new Exception("Unsupported output format: " + cla.OutputFormat);
                }

                writer.WriteResults(s, results);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Outputs the results to an appropriate file or stdout.
        /// </summary>
        /// <param name="results">The test results.</param>
        /// <param name="cla">The command line arguments.</param>
        /// <exception cref="Exception">Output format must be specified.</exception>
        public void OutputResults(ParsedData results, CommandLineArguments cla)
        {
            using (Stream s = cla.OutputFilename == null ? Console.OpenStandardOutput() : new FileStream(cla.OutputFilename, FileMode.Create))
            {
                ITestResultWriter writer = null;
                switch (cla.OutputFormat)
                {
                case OutputFormat.CSV:
                    writer = new CSVTestResultWriter();
                    break;

                case OutputFormat.Json:
                    writer = new JSONTestResultWriter();
                    break;

                case OutputFormat.KVP:
                    writer = new KVPTestResultWriter();
                    break;

                case OutputFormat.Xlsx:
                    writer = new XLSXWriter(cla.YellowBand, cla.GreenBand);
                    break;

                default:
                    throw new Exception("Unsupported output format: " + cla.OutputFormat);
                }

                writer.WriteResults(s, results);
            }
        }