/// <summary> /// Initializes a new instance of the <see cref="ReportGenerator"/> class. /// </summary> /// <param name="testRun">Completed test results.</param> /// <param name="parameters">Test parameters.</param> /// <param name="libraryParameters">User parameters.</param> internal ReportGenerator(TestRun testRun, IReadOnlyDictionary <string, string> parameters, IDictionary <string, object> libraryParameters) { var library = new LibraryDrop(libraryParameters); var run = new TestRunDrop(testRun); _context = Hash.FromAnonymousObject(new { run, parameters, library }); }
private string GenerateReport(string template, LibraryDrop libraryDrop) { var inputProcessor = new InputProcessingService(_inputs); TestRunDrop run; try { run = inputProcessor.Process(); } catch (InvalidDataException e) { _errorConsole.WriteLine(e.Message); return(null); } string report = null; _standardConsole.WriteLine(); _standardConsole.MarkupLine("Generating report"); try { var reportGenerator = new ReportGenerator(new LibraryTestRun { Run = run, Library = libraryDrop }); report = reportGenerator.GenerateReport(template ?? Templates.MdMultiReport, out var errors); foreach (var error in errors) { _standardConsole.MarkupLine($"[orange1]{error.Message}[/]"); } _standardConsole.WriteLine(); _standardConsole.MarkupLine("Finished generating report"); } catch (SyntaxException e) { _errorConsole.WriteLine(e.Message); } catch (Exception e) { _errorConsole.WriteLine($"Unexpected error occurred while generating report {e.Message}"); } return(report); }