Skip to content
This repository was archived by the owner on Apr 6, 2024. It is now read-only.

Commit fbf2fad

Browse files
committed
Merge branch 'release/0.4.2'
2 parents 3949aab + 2efa68c commit fbf2fad

13 files changed

+1479
-35
lines changed

nuspec/nuget/Cake.Issues.Reporting.Generic.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
2121
<requireLicenseAcceptance>false</requireLicenseAcceptance>
2222
<copyright>Copyright © Pascal Berger</copyright>
2323
<tags>Cake Script Cake-Issues Cake-ReportFormat Issues Reporting Html Markdown</tags>
24-
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.Reporting.Generic/releases/tag/0.4.1</releaseNotes>
24+
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.Reporting.Generic/releases/tag/0.4.2</releaseNotes>
2525
</metadata>
2626
<files>
2727
<file src="Cake.Issues.Reporting.Generic.dll" target="lib\net46" />

src/Cake.Issues.Reporting.Generic.Tests/Cake.Issues.Reporting.Generic.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
<ItemGroup>
8686
<Compile Include="ColumnSortOrderExtensionsTests.cs" />
8787
<Compile Include="DevExtremeThemeExtensionsTests.cs" />
88+
<Compile Include="ExceptionAssertExtensions.cs" />
89+
<Compile Include="HtmlDxDataGridColumnDescriptionTests.cs" />
8890
<Compile Include="IIssueExtensionTests.cs" />
8991
<Compile Include="UriExtensionsTests.cs" />
9092
<Compile Include="FileLinkSettingsTests.cs" />
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Cake.Issues.Reporting.Generic.Tests
2+
{
3+
using System;
4+
using Microsoft.CSharp.RuntimeBinder;
5+
using Xunit;
6+
7+
/// <summary>
8+
/// Extensions for asserting exceptions.
9+
/// </summary>
10+
internal static class ExceptionAssertExtensions
11+
{
12+
/// <summary>
13+
/// Checks if an execption is of type <see cref="T:Microsoft.CSharp.RuntimeBinder.RuntimeBinderException" />.
14+
/// </summary>
15+
/// <param name="exception">Exception to check.</param>
16+
/// <param name="message">Expected exception message.</param>
17+
public static void IsRuntimeBinderException(this Exception exception, string message)
18+
{
19+
Assert.IsType<RuntimeBinderException>(exception);
20+
Assert.Equal(message, exception.Message);
21+
}
22+
}
23+
}

src/Cake.Issues.Reporting.Generic.Tests/GenericIssueReportFixture.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
namespace Cake.Issues.Reporting.Generic.Tests
22
{
3+
using System;
34
using System.Collections.Generic;
45
using System.IO;
56
using Cake.Testing;
67
using Core.Diagnostics;
8+
using Shouldly;
79

810
internal class GenericIssueReportFixture
911
{
@@ -62,5 +64,28 @@ public string CreateReport(IEnumerable<IIssue> issues)
6264
}
6365
}
6466
}
67+
68+
public void TestReportCreation(Action<GenericIssueReportFormatSettings> settings)
69+
{
70+
// Given
71+
settings(this.GenericIssueReportFormatSettings);
72+
73+
// When
74+
var result =
75+
this.CreateReport(
76+
new List<IIssue>
77+
{
78+
IssueBuilder
79+
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
80+
.InFile(@"src\Cake.Issues.Reporting.Generic.Tests\Foo.cs", 10)
81+
.OfRule("Rule Foo")
82+
.WithPriority(IssuePriority.Warning)
83+
.Create(),
84+
});
85+
86+
// Then
87+
// Currently only checks if genertions failed or not without checking actual output.
88+
result.ShouldNotBeNull();
89+
}
6590
}
6691
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
namespace Cake.Issues.Reporting.Generic.Tests
2+
{
3+
using System;
4+
using Cake.Issues.Testing;
5+
using Shouldly;
6+
using Xunit;
7+
8+
public sealed class HtmlDxDataGridColumnDescriptionTests
9+
{
10+
public sealed class TheCtor
11+
{
12+
[Fact]
13+
public void Should_Throw_If_Id_Is_Null()
14+
{
15+
// Given
16+
string id = null;
17+
object valueRetriever(IIssue issue)
18+
{
19+
return true;
20+
}
21+
22+
// When
23+
var result = Record.Exception(() => new HtmlDxDataGridColumnDescription(id, valueRetriever));
24+
25+
// Then
26+
result.IsArgumentNullException("id");
27+
}
28+
29+
[Fact]
30+
public void Should_Throw_If_Id_Is_Empty()
31+
{
32+
// Given
33+
var id = string.Empty;
34+
object valueRetriever(IIssue issue)
35+
{
36+
return true;
37+
}
38+
39+
// When
40+
var result = Record.Exception(() => new HtmlDxDataGridColumnDescription(id, valueRetriever));
41+
42+
// Then
43+
result.IsArgumentOutOfRangeException("id");
44+
}
45+
46+
[Fact]
47+
public void Should_Throw_If_Id_Is_Whitespace()
48+
{
49+
// Given
50+
var id = " ";
51+
object valueRetriever(IIssue issue)
52+
{
53+
return true;
54+
}
55+
56+
// When
57+
var result = Record.Exception(() => new HtmlDxDataGridColumnDescription(id, valueRetriever));
58+
59+
// Then
60+
result.IsArgumentOutOfRangeException("id");
61+
}
62+
63+
[Fact]
64+
public void Should_Throw_If_ValueRetriever_Is_Null()
65+
{
66+
// Given
67+
var id = "foo";
68+
Func<IIssue, object> valueRetriever = null;
69+
70+
// When
71+
var result = Record.Exception(() => new HtmlDxDataGridColumnDescription(id, valueRetriever));
72+
73+
// Then
74+
result.IsArgumentNullException("valueRetriever");
75+
}
76+
77+
[Fact]
78+
public void Should_Assign_Id()
79+
{
80+
// Given
81+
var id = "foo";
82+
object valueRetriever(IIssue issue)
83+
{
84+
return true;
85+
}
86+
87+
// When
88+
var result = new HtmlDxDataGridColumnDescription(id, valueRetriever);
89+
90+
// Then
91+
result.Id.ShouldBe(id);
92+
}
93+
94+
[Fact]
95+
public void Should_Assign_ValueRetriever()
96+
{
97+
// Given
98+
var id = "foo";
99+
object valueRetriever(IIssue issue)
100+
{
101+
return true;
102+
}
103+
104+
// When
105+
var result = new HtmlDxDataGridColumnDescription(id, valueRetriever);
106+
107+
// Then
108+
result.ValueRetriever.ShouldBe(valueRetriever);
109+
}
110+
}
111+
}
112+
}

0 commit comments

Comments
 (0)