public static IMarkdown ToMarkdown(this ITest test) { return(Markdown.Create(() => test.Name.ToMarkdown() .Add(test.Name != string.Empty ? ": " : string.Empty) .Add(test.Code.ToMarkdown().InlineCode()) .NewLine() .Add(string.Format("{0:0} ms", test.ExecutionTime).ToMarkdown().Bold()))); }
public static IMarkdown Code(this IMarkdown markdown) { return(Markdown.Create(() => string.Join( Environment.NewLine, markdown .Render() .Split(new[] { Environment.NewLine }, StringSplitOptions.None) .Select(x => "\t" + x)))); }
public static IMarkdown ToMarkdown(this ITestCase testCase, CultureInfo culture) { Func <IMarkdown> renderGain = () => { var testExecutionTime = testCase.Test.ExecutionTime; var benchmarkExecutionTime = testCase.Benchmark.ExecutionTime; if (testExecutionTime < 1.0 || benchmarkExecutionTime < 1.0) { return(Markdown.Empty); } var gain = (testExecutionTime / benchmarkExecutionTime) - 1.0; gain *= 100.0; if (Math.Abs(gain) < 5.0) { return(Markdown.Empty); } return (Markdown.Empty .Add(" ") .Add( Markdown.Create(() => string.Format(culture, "{0:+0.0;-0.0;0.0}%", gain)) .InlineCode())); }; return(Markdown.Create(() => { var result = testCase.Name.ToMarkdown(); if (testCase.Benchmark != null) { result = result.Add(renderGain()); } result = result.H3().NewLine().NewLine(); IEnumerable <ITest> tests = new[] { testCase.Test }; if (testCase.Benchmark != null) { tests = tests.Concat(new[] { testCase.Benchmark }); } return result.Add(tests.Select(t => t.ToMarkdown().NewLine()).AsLines()); })); }
public static IMarkdown Concat(this IEnumerable <IMarkdown> markdowns) { return(Markdown.Create(() => string.Join("", markdowns.Select(m => m.Render())))); }
public static IMarkdown AsOrderedList(this IEnumerable <IMarkdown> markdowns) { return(Markdown.Create(() => markdowns.Select((m, i) => Markdown.Create((i + 1).ToString() + ". " + m.Render())).AsLines())); }
public static IMarkdown ToMarkdown(this string source) { return(Markdown.Create(source)); }
public static IMarkdown AsUnorderedList(this IEnumerable <IMarkdown> markdowns) { return(Markdown.Create(() => markdowns.Select(m => Markdown.Create("- " + m.Render())).AsLines())); }
public static IMarkdown AsLines(this IEnumerable <IMarkdown> markdowns) { return(Markdown.Create(() => string.Join(Environment.NewLine, markdowns.Select(m => m.Render() + " ")))); }
public static IMarkdown InlineCode(this IMarkdown markdown) { return(Markdown.Create(markdown, "`{0}`")); }
public static IMarkdown Italic(this IMarkdown markdown) { return(Markdown.Create(markdown, "*{0}*")); }
public static IMarkdown Bold(this IMarkdown markdown) { return(Markdown.Create(markdown, "**{0}**")); }
public static IMarkdown H3(this IMarkdown markdown) { return(Markdown.Create(markdown, "###{0}")); }
public static IMarkdown NewLine(this IMarkdown markdown) { return(Markdown.Create(() => markdown.Render() + " " + Environment.NewLine)); }
public static IMarkdown Add(this IMarkdown markdown, IMarkdown toAdd) { return(Markdown.Create(() => markdown.Render() + toAdd.Render())); }
public static IMarkdown Add(this IMarkdown markdown, CultureInfo culture, string toAdd, params object[] arguments) { return(Markdown.Create(() => markdown.Render() + string.Format(culture, toAdd, arguments))); }