public static void WriteCSV(BatchRunResponse results, string file)
        {
            using (var writer = new StreamWriter(file))
            {

                results.records.Each(record =>
                {
                    var suite = record.specification.SuitePath();
                    var name = record.specification.name.Replace(',', ' ');
                    var id = record.specification.id;

                    record.results.Performance.Each(x =>
                    {
                        writer.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7}",
                            id,
                            suite,
                            name,
                            x.Type,
                            x.Subject,
                            x.Duration,
                            x.Start,
                            x.End
                            );

                    });
                });
            }
        }
        private void writeResponse(BatchRunResponse response)
        {
            var json = JsonSerialization.ToIndentedJson(response);

            var path = TestingContext.FindClientFolder().AppendPath("batch-run-response-data.js");

            new FileSystem().WriteStringToFile(path, "module.exports = " + json);
        }
        public static HtmlDocument BuildResults(BatchRunResponse results)
        {
            var document = new HtmlDocument
            {
                Title = "Storyteller Batch Results for {0}: {1}".ToFormat(results.system, results.suite)
            };

            WriteCSS(document);
            writeJavascript(results, document);

            return document;
        }
        private static void writeJavascript(BatchRunResponse results, HtmlDocument document)
        {
            var cleanJson = JsonSerialization.ToCleanJson(results);

            document.Body.Add("div").Hide().Id("batch-data").Text(cleanJson);
            document.Body.Add("div").Id("main");

            var js = readFile("StoryTeller.batch-bundle.js");

            document.Body.Add("script").Attr("language", "javascript").Text("\n\n" + js + "\n\n").Encoded(false);


        }
        private static void writeJavascript(BatchRunResponse results, HtmlDocument document)
        {
            var cleanJson = JsonSerialization.ToCleanJson(results);

            document.Body.Add("div").Hide().Id("batch-data").Text(cleanJson);
            document.Body.Add("div").Id("main");

            var js = readFile("StoryTeller.batch-bundle.js");

            var foot = new HtmlTag("foot");
            document.Body.Next = foot;

            foot.Add("script").Attr("language", "javascript").Text("\n\n" + js + "\n\n").Encoded(false);
            /*
            foot.Add("script")
                .Attr("language", "Javascript")
                .Attr("src", "file://Z:/code/storyteller/src/ST/batch-bundle.js");
                */
        }
        private void writeResponse(BatchRunResponse response)
        {
            var json = JsonSerialization.ToIndentedJson(response);

            var path = AppDomain.CurrentDomain.BaseDirectory
                .ParentDirectory().ParentDirectory() // project dir
                .ParentDirectory().ParentDirectory() // root
                .AppendPath("client", "batch-run-response-data.js");

            new FileSystem().WriteStringToFile(path, "module.exports = " + json);
        }
 public static void WriteJSON(BatchRunResponse results, string file)
 {
     new FileSystem().WriteStringToFile(file, JsonSerialization.ToIndentedJson(results.records));
 }