public void Should_Generate_Report_From_Embedded_Template(GenericIssueReportTemplate template) { // Given var fixture = new GenericIssueReportFixture(template); var issues = new List <IIssue> { IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") .WithMessageInHtmlFormat("Message <b>Foo</b>") .WithMessageInMarkdownFormat("Message **Foo**") .InFile(@"src\Cake.Issues.Reporting.Generic.Tests\Foo.cs", 10) .OfRule("Rule Foo") .WithPriority(IssuePriority.Warning) .Create(), IssueBuilder .NewIssue("Message Bar", "ProviderType Bar", "ProviderName Bar") .InFile(@"src\Cake.Issues.Reporting.Generic.Tests\Foo.cs", 12) .OfRule("Rule Bar") .WithPriority(IssuePriority.Warning) .Create(), }; // When var result = fixture.CreateReport(issues); // Then // No additional tests. We only check if template can be compiled. }
public GenericIssueReportFixture(GenericIssueReportTemplate template) { this.Log = new FakeLog { Verbosity = Verbosity.Normal }; this.GenericIssueReportFormatSettings = GenericIssueReportFormatSettings.FromEmbeddedTemplate(template); }
public static IIssueReportFormat GenericIssueReportFormatFromEmbeddedTemplate( this ICakeContext context, GenericIssueReportTemplate template) { context.NotNull(nameof(context)); return(context.GenericIssueReportFormat(GenericIssueReportFormatSettings.FromEmbeddedTemplate(template))); }
/// <summary> /// Initializes a new instance of the <see cref="GenericIssueReportFormatSettings"/> class. /// </summary> /// <param name="template">Template to use for generating the report.</param> protected GenericIssueReportFormatSettings(GenericIssueReportTemplate template) { using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Reporting.Generic.Templates." + template.GetTemplateResourceName())) { using (var sr = new StreamReader(stream)) { this.Template = sr.ReadToEnd(); } } }
public static IIssueReportFormat GenericIssueReportFormatFromEmbeddedTemplate( this ICakeContext context, GenericIssueReportTemplate template, Action <GenericIssueReportFormatSettings> configurator) { context.NotNull(nameof(context)); configurator.NotNull(nameof(configurator)); var settings = GenericIssueReportFormatSettings.FromEmbeddedTemplate(template); configurator(settings); return(context.GenericIssueReportFormat(settings)); }
/// <summary> /// Initializes a new instance of the <see cref="GenericIssueReportFormatSettings"/> class. /// </summary> /// <param name="template">Template to use for generating the report.</param> protected GenericIssueReportFormatSettings(GenericIssueReportTemplate template) { using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Reporting.Generic.Templates." + template.GetTemplateResourceName())) { if (stream == null) { throw new ApplicationException($"Could not load resource {template}"); } using (var sr = new StreamReader(stream)) { this.Template = sr.ReadToEnd(); } } }
/// <summary> /// Returns the name of the embedded template file. /// </summary> /// <param name="template">Template for which the embedded file name should be returned.</param> /// <returns>Name of the template file.</returns> public static string GetTemplateResourceName(this GenericIssueReportTemplate template) { switch (template) { case GenericIssueReportTemplate.HtmlDiagnostic: return("Diagnostic.cshtml"); case GenericIssueReportTemplate.HtmlDataTable: return("DataTable.cshtml"); case GenericIssueReportTemplate.HtmlDxDataGrid: return("DxDataGrid.cshtml"); default: throw new ArgumentOutOfRangeException(nameof(template)); } }
/// <summary> /// Returns a new instance of the <see cref="GenericIssueReportFormatSettings"/> class from a template file on disk. /// </summary> /// <param name="template">Template to use for generating the report.</param> /// <returns>Instance of the <see cref="GenericIssueReportFormatSettings"/> class.</returns> public static GenericIssueReportFormatSettings FromEmbeddedTemplate(GenericIssueReportTemplate template) { return(new GenericIssueReportFormatSettings(template)); }