forked from cake-contrib/Cake.Issues
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cake-contrib#42 from cake-contrib/feature/cake-con…
…tribgh-41 (cake-contribGH-41) Add options for DxDataGrid template
- Loading branch information
Showing
19 changed files
with
988 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Cake.Issues.Reporting.Generic.Tests/ColumnSortOrderExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Cake.Issues.Reporting.Generic.Tests | ||
{ | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class ColumnSortOrderExtensionsTests | ||
{ | ||
public sealed class TheToShortStringMethod | ||
{ | ||
[Theory] | ||
[InlineData(ColumnSortOrder.Ascending)] | ||
[InlineData(ColumnSortOrder.Descending)] | ||
public void Should_Return_Identifier(ColumnSortOrder sortOrder) | ||
{ | ||
// Given | ||
|
||
// When | ||
var result = sortOrder.ToShortString(); | ||
|
||
// Then | ||
result.ShouldNotBeNullOrWhiteSpace(); | ||
} | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Cake.Issues.Reporting.Generic.Tests/DevExtremeThemeExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace Cake.Issues.Reporting.Generic.Tests | ||
{ | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class DevExtremeThemeExtensionsTests | ||
{ | ||
public sealed class TheGetCssFileNameMethod | ||
{ | ||
[Theory] | ||
[InlineData(DevExtremeTheme.Light)] | ||
[InlineData(DevExtremeTheme.Dark)] | ||
[InlineData(DevExtremeTheme.Contrast)] | ||
[InlineData(DevExtremeTheme.Carmine)] | ||
[InlineData(DevExtremeTheme.DarkMoon)] | ||
[InlineData(DevExtremeTheme.SoftBlue)] | ||
[InlineData(DevExtremeTheme.DarkViolet)] | ||
[InlineData(DevExtremeTheme.GreenMist)] | ||
[InlineData(DevExtremeTheme.LightCompact)] | ||
[InlineData(DevExtremeTheme.DarkCompact)] | ||
[InlineData(DevExtremeTheme.ContrastCompact)] | ||
[InlineData(DevExtremeTheme.MaterialBlueLight)] | ||
[InlineData(DevExtremeTheme.MaterialLimeLight)] | ||
[InlineData(DevExtremeTheme.MaterialOrangeLight)] | ||
[InlineData(DevExtremeTheme.MaterialPurpleLight)] | ||
[InlineData(DevExtremeTheme.MaterialTealLight)] | ||
public void Should_Return_FileName(DevExtremeTheme theme) | ||
{ | ||
// Given | ||
|
||
// When | ||
var result = theme.GetCssFileName(); | ||
|
||
// Then | ||
result.ShouldNotBeNullOrWhiteSpace(); | ||
} | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/Cake.Issues.Reporting.Generic.Tests/GenericIssueReportFormatSettingsExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
namespace Cake.Issues.Reporting.Generic.Tests | ||
{ | ||
using Cake.Issues.Testing; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class GenericIssueReportFormatSettingsExtensionsTests | ||
{ | ||
public sealed class TheWithOptionWithStringKeyMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
GenericIssueReportFormatSettings settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => | ||
settings.WithOption("Foo", "Bar")); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Option() | ||
{ | ||
// Given | ||
var key = "Foo"; | ||
var value = "Bar"; | ||
var settings = GenericIssueReportFormatSettings.FromContent("Foo"); | ||
|
||
// When | ||
var result = settings.WithOption(key, value); | ||
|
||
// Then | ||
result.Options.Count.ShouldBe(1); | ||
result.Options.ShouldContainKeyAndValue(key, value); | ||
} | ||
} | ||
|
||
public sealed class TheWithOptionWithEnumgKeyMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
GenericIssueReportFormatSettings settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => | ||
settings.WithOption(HtmlDxDataGridOption.Theme, "Bar")); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Option() | ||
{ | ||
// Given | ||
var key = HtmlDxDataGridOption.Title; | ||
var value = "Bar"; | ||
var settings = GenericIssueReportFormatSettings.FromContent("Foo"); | ||
|
||
// When | ||
var result = settings.WithOption(key, value); | ||
|
||
// Then | ||
result.Options.Count.ShouldBe(1); | ||
result.Options.ShouldContainKeyAndValue(key.ToString(), value); | ||
} | ||
} | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
src/Cake.Issues.Reporting.Generic.Tests/HtmlDxDataGridTemplateTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
namespace Cake.Issues.Reporting.Generic.Tests | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using HtmlAgilityPack; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class HtmlDxDataGridTemplateTests | ||
{ | ||
public sealed class TheTitleOption | ||
{ | ||
[Fact] | ||
public void Should_Set_Title() | ||
{ | ||
// 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 titleElements = doc.DocumentNode.Descendants("title"); | ||
titleElements.ShouldHaveSingleItem(); | ||
titleElements.Single().InnerText.ShouldBe(title); | ||
} | ||
|
||
[Fact] | ||
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"); | ||
headingElements.ShouldHaveSingleItem(); | ||
headingElements.Single().InnerText.ShouldBe(title); | ||
} | ||
} | ||
|
||
public sealed class TheThemeOption | ||
{ | ||
[Theory] | ||
[InlineData(DevExtremeTheme.Light)] | ||
[InlineData(DevExtremeTheme.Dark)] | ||
[InlineData(DevExtremeTheme.Contrast)] | ||
[InlineData(DevExtremeTheme.Carmine)] | ||
[InlineData(DevExtremeTheme.DarkMoon)] | ||
[InlineData(DevExtremeTheme.SoftBlue)] | ||
[InlineData(DevExtremeTheme.DarkViolet)] | ||
[InlineData(DevExtremeTheme.GreenMist)] | ||
[InlineData(DevExtremeTheme.LightCompact)] | ||
[InlineData(DevExtremeTheme.DarkCompact)] | ||
[InlineData(DevExtremeTheme.ContrastCompact)] | ||
[InlineData(DevExtremeTheme.MaterialBlueLight)] | ||
[InlineData(DevExtremeTheme.MaterialLimeLight)] | ||
[InlineData(DevExtremeTheme.MaterialOrangeLight)] | ||
[InlineData(DevExtremeTheme.MaterialPurpleLight)] | ||
[InlineData(DevExtremeTheme.MaterialTealLight)] | ||
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(DevExtremeThemeExtensions.GetCssFileName(theme))); | ||
} | ||
} | ||
|
||
public sealed class TheShowHeaderOption | ||
{ | ||
[Fact] | ||
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(); | ||
} | ||
|
||
[Fact] | ||
public void Should_Not_Show_Header_If_False() | ||
{ | ||
// Given | ||
var fixture = new GenericIssueReportFixture(GenericIssueReportTemplate.HtmlDxDataGrid); | ||
fixture.GenericIssueReportFormatSettings | ||
.WithOption(HtmlDxDataGridOption.ShowHeader, false); | ||
|
||
// When | ||
var result = fixture.CreateReport(new List<IIssue>()); | ||
|
||
// Then | ||
var doc = new HtmlDocument(); | ||
doc.LoadHtml(result); | ||
var headingElements = doc.DocumentNode.Descendants("h1"); | ||
headingElements.ShouldBeEmpty(); | ||
} | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Cake.Issues.Reporting.Generic.Tests/ViewBagHelperTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
namespace Cake.Issues.Reporting.Generic.Tests | ||
{ | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class ViewBagHelperTests | ||
{ | ||
public sealed class TheValueOrDefaultMethod | ||
{ | ||
[Fact] | ||
public void Should_Return_Value_If_Not_Null() | ||
{ | ||
// Given | ||
var value = "foo"; | ||
var defaultValue = "bar"; | ||
|
||
// When | ||
var result = ViewBagHelper.ValueOrDefault(value, defaultValue); | ||
|
||
// Then | ||
result.ShouldBe(value); | ||
} | ||
|
||
[Fact] | ||
public void Should_Return_Default_If_Value_Is_Null() | ||
{ | ||
// Given | ||
string value = null; | ||
var defaultValue = "bar"; | ||
|
||
// When | ||
var result = ViewBagHelper.ValueOrDefault(value, defaultValue); | ||
|
||
// Then | ||
result.ShouldBe(defaultValue); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace Cake.Issues.Reporting.Generic | ||
{ | ||
/// <summary> | ||
/// Possible sort orders for columns. | ||
/// </summary> | ||
public enum ColumnSortOrder | ||
{ | ||
/// <summary> | ||
/// Ascending sorting. | ||
/// </summary> | ||
Ascending, | ||
|
||
/// <summary> | ||
/// Descending sorting. | ||
/// </summary> | ||
Descending | ||
} | ||
} |
Oops, something went wrong.