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

Commit a654692

Browse files
authored
(GH-278) Add support for column information (#330)
* (GH-278) Add column information to HtmlDiagnostic template * (GH-278) Add column information to HtmlDxDataGrid template
1 parent 43f14de commit a654692

File tree

9 files changed

+529
-20
lines changed

9 files changed

+529
-20
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void Should_Give_Correct_Result()
4141
var result = expandoObject.SerializeToJsonString();
4242

4343
// Then
44-
result.ShouldBe("{\"ProviderType\":\"providerType\",\"ProviderName\":\"providerName\",\"Run\":null,\"Priority\":null,\"PriorityName\":null,\"ProjectPath\":null,\"ProjectName\":null,\"FilePath\":null,\"FileDirectory\":null,\"FileName\":null,\"FileLink\":null,\"Line\":null,\"EndLine\":null,\"Location\":\"\",\"Rule\":null,\"RuleUrl\":null,\"MessageText\":\"message\"}");
44+
result.ShouldBe("{\"ProviderType\":\"providerType\",\"ProviderName\":\"providerName\",\"Run\":null,\"Priority\":null,\"PriorityName\":null,\"ProjectPath\":null,\"ProjectName\":null,\"FilePath\":null,\"FileDirectory\":null,\"FileName\":null,\"FileLink\":null,\"Line\":null,\"EndLine\":null,\"Column\":null,\"EndColumn\":null,\"Location\":\"\",\"Rule\":null,\"RuleUrl\":null,\"MessageText\":\"message\"}");
4545
}
4646
}
4747

@@ -81,7 +81,7 @@ public void Should_Give_Correct_Result()
8181
var result = expandoObjects.SerializeToJsonString();
8282

8383
// Then
84-
result.ShouldBe("[{\"ProviderType\":\"providerType1\",\"ProviderName\":\"providerName1\",\"Run\":null,\"Priority\":null,\"PriorityName\":null,\"ProjectPath\":null,\"ProjectName\":null,\"FilePath\":null,\"FileDirectory\":null,\"FileName\":null,\"FileLink\":null,\"Line\":null,\"EndLine\":null,\"Location\":\"\",\"Rule\":null,\"RuleUrl\":null,\"MessageText\":\"message1\"},{\"ProviderType\":\"providerType1\",\"ProviderName\":\"providerName1\",\"Run\":null,\"Priority\":null,\"PriorityName\":null,\"ProjectPath\":null,\"ProjectName\":null,\"FilePath\":null,\"FileDirectory\":null,\"FileName\":null,\"FileLink\":null,\"Line\":null,\"EndLine\":null,\"Location\":\"\",\"Rule\":null,\"RuleUrl\":null,\"MessageText\":\"message1\"}]");
84+
result.ShouldBe("[{\"ProviderType\":\"providerType1\",\"ProviderName\":\"providerName1\",\"Run\":null,\"Priority\":null,\"PriorityName\":null,\"ProjectPath\":null,\"ProjectName\":null,\"FilePath\":null,\"FileDirectory\":null,\"FileName\":null,\"FileLink\":null,\"Line\":null,\"EndLine\":null,\"Column\":null,\"EndColumn\":null,\"Location\":\"\",\"Rule\":null,\"RuleUrl\":null,\"MessageText\":\"message1\"},{\"ProviderType\":\"providerType1\",\"ProviderName\":\"providerName1\",\"Run\":null,\"Priority\":null,\"PriorityName\":null,\"ProjectPath\":null,\"ProjectName\":null,\"FilePath\":null,\"FileDirectory\":null,\"FileName\":null,\"FileLink\":null,\"Line\":null,\"EndLine\":null,\"Column\":null,\"EndColumn\":null,\"Location\":\"\",\"Rule\":null,\"RuleUrl\":null,\"MessageText\":\"message1\"}]");
8585
}
8686
}
8787
}

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,84 @@ public void Should_Not_Set_EndLine_If_Flag_Is_Not_Set()
446446
result.IsRuntimeBinderException("'System.Dynamic.ExpandoObject' does not contain a definition for 'EndLine'");
447447
}
448448

449+
[Fact]
450+
public void Should_Set_Column_If_Flag_Is_Set()
451+
{
452+
// Given
453+
var filePath = @"src\Cake.Issues.Reporting.Generic.Tests\Foo.cs";
454+
var line = 23;
455+
var endLine = 42;
456+
var column = 5;
457+
var endColumn = 10;
458+
var issue =
459+
IssueBuilder
460+
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
461+
.InFile(filePath, line, endLine, column, endColumn)
462+
.Create();
463+
464+
// When
465+
dynamic result = issue.GetExpandoObject(addColumn: true);
466+
467+
// Then
468+
Assert.Equal(result.Column, column);
469+
}
470+
471+
[Fact]
472+
public void Should_Not_Set_Column_If_Flag_Is_Not_Set()
473+
{
474+
// Given
475+
var issue =
476+
IssueBuilder
477+
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
478+
.Create();
479+
480+
// When
481+
dynamic expando = issue.GetExpandoObject(addColumn: false);
482+
var result = Record.Exception(() => expando.Column);
483+
484+
// Then
485+
result.IsRuntimeBinderException("'System.Dynamic.ExpandoObject' does not contain a definition for 'Column'");
486+
}
487+
488+
[Fact]
489+
public void Should_Set_EndColumn_If_Flag_Is_Set()
490+
{
491+
// Given
492+
var filePath = @"src\Cake.Issues.Reporting.Generic.Tests\Foo.cs";
493+
var line = 23;
494+
var endLine = 42;
495+
var column = 5;
496+
var endColumn = 10;
497+
var issue =
498+
IssueBuilder
499+
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
500+
.InFile(filePath, line, endLine, column, endColumn)
501+
.Create();
502+
503+
// When
504+
dynamic result = issue.GetExpandoObject(addEndColumn: true);
505+
506+
// Then
507+
Assert.Equal(result.EndColumn, endColumn);
508+
}
509+
510+
[Fact]
511+
public void Should_Not_Set_EndColumn_If_Flag_Is_Not_Set()
512+
{
513+
// Given
514+
var issue =
515+
IssueBuilder
516+
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo")
517+
.Create();
518+
519+
// When
520+
dynamic expando = issue.GetExpandoObject(addEndColumn: false);
521+
var result = Record.Exception(() => expando.EndColumn);
522+
523+
// Then
524+
result.IsRuntimeBinderException("'System.Dynamic.ExpandoObject' does not contain a definition for 'EndColumn'");
525+
}
526+
449527
[Fact]
450528
public void Should_Set_Location_If_Flag_Is_Set()
451529
{

0 commit comments

Comments
 (0)