public void Should_Generate_Report_From_Custom_Template() { // Given var fixture = new GenericIssueReportFixture("<ul>@foreach(var issue in Model){<li>@issue.MessageText</li>}</ul>"); var issues = new List <IIssue> { IssueBuilder .NewIssue("Message Foo", "ProviderType Foo", "ProviderName 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(), }; var expectedResult = @"<ul><li>Message Foo</li><li>Message Bar</li></ul>"; // When var result = fixture.CreateReport(issues); // Then result.ShouldBe(expectedResult); }
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 void Should_Pass_Options_To_ViewBag() { // Given var expectedResult = "Foo"; var fixture = new GenericIssueReportFixture("@ViewBag.Title"); fixture.GenericIssueReportFormatSettings.WithOption("Title", expectedResult); // When var result = fixture.CreateReport(new List <IIssue>()); // Then result.ShouldBe(expectedResult); }
public void Should_Show_Header_If_True() { // Given var fixture = new GenericIssueReportFixture(GenericIssueReportTemplate.HtmlDxDataGrid); fixture.GenericIssueReportFormatSettings .WithOption(HtmlDxDataGridOption.ShowHeader, true); // When var result = fixture.CreateReport(new List <IIssue>()); // Then var doc = new HtmlDocument(); doc.LoadHtml(result); var headingElements = doc.DocumentNode.Descendants("h1"); headingElements.ShouldHaveSingleItem(); }
public void Should_Set_Theme(DevExtremeTheme theme) { // Given var fixture = new GenericIssueReportFixture(GenericIssueReportTemplate.HtmlDxDataGrid); fixture.GenericIssueReportFormatSettings .WithOption(HtmlDxDataGridOption.Theme, theme); // When var result = fixture.CreateReport(new List <IIssue>()); // Then var doc = new HtmlDocument(); doc.LoadHtml(result); var stylesheetElements = doc.DocumentNode.SelectNodes("//link[@rel='stylesheet']"); stylesheetElements.Count.ShouldBe(2); stylesheetElements.ShouldContain(x => x.Attributes["href"].Value.EndsWith(theme.GetCssFileName())); }
public void Should_Set_Heading() { // Given var title = "Foo"; var fixture = new GenericIssueReportFixture(GenericIssueReportTemplate.HtmlDxDataGrid); fixture.GenericIssueReportFormatSettings .WithOption(HtmlDxDataGridOption.Title, title); // When var result = fixture.CreateReport(new List <IIssue>()); // Then var doc = new HtmlDocument(); doc.LoadHtml(result); var headingElements = doc.DocumentNode.Descendants("h1").ToList(); headingElements.ShouldHaveSingleItem(); headingElements.Single().InnerText.ShouldBe(title); }