public override string ToString() { return(_template.Get()); }
public string FeatureToHtml(SquashFeature feature) { var template = new Template(Templates.Feature); template.Replace("name", feature.Name); template.Replace("description", feature.Description); var scenarios = ""; foreach (var scenario in feature.Scenarios) { var t = new Template(Templates.Scenario); t.Replace("name", scenario.Name); t.Replace("tags", string.Join(" ", scenario.Tags.Select(tag => "<span class='tag'>" + tag + "</span>"))); var steps = ""; foreach (var stepDef in scenario.StepDefinitions) { var t1 = new Template(Templates.StepDefinition); t1.Replace("action", stepDef.Action.ToString()); t1.Replace("statement", stepDef.Statement); if (stepDef.Table != null && stepDef.Table.Count > 0) { var header = $"<tr><th>{string.Join("</th><th>", stepDef.Table[0].Cells)}</th></tr>"; var table = stepDef.Table.Skip(1).Select(r => $"<tr><td>{string.Join("</td><td>", r.Cells)}</td></tr>"); t1.Replace("table", "<table>" + header + string.Join("", table) + "</table>"); } else { t1.Replace("table", ""); } steps += t1.Get(); } var outline = scenario as SquashScenarioOutline; var scens = ""; if (outline != null) { foreach (var scenar in outline.Scenarios) { scens += $"<div class='so-scenarios'>{scenar.Name}</div>"; scens += "<table>"; foreach (var scen in scenar.Rows) { scens += "<tr><td>" + string.Join("</td><td>", scen) + "</td></tr>"; //$"<div>{scen}</div>"; } scens += "</table>"; } } t.Replace("scenarios", scens); t.Replace("stepDefinitions", steps); scenarios += t.Get(); } template.Replace("scenarios", scenarios); return(template.Get()); }