From 8fc43e2cd922703add4a91142fd2d3f3629d6b51 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Mon, 22 Jul 2024 07:47:15 +0200
Subject: [PATCH 1/6] Update dependency Verify.Xunit to v26 (#688)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
.../Cake.Issues.PullRequests.Tests.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj
index 5f0dd18e4..6b1938109 100644
--- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj
+++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj
@@ -5,7 +5,7 @@
-
+
From 2148529faf9770445f5b167ef73d31a894a20b90 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Tue, 23 Jul 2024 22:42:38 +0200
Subject: [PATCH 2/6] Update dependency Verify.Xunit to v26.0.1 (#691)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
.../Cake.Issues.PullRequests.Tests.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj
index 6b1938109..3c0e330ca 100644
--- a/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj
+++ b/src/Cake.Issues.PullRequests.Tests/Cake.Issues.PullRequests.Tests.csproj
@@ -5,7 +5,7 @@
-
+
From 8b6592fb3f9ac6d1197f4377249748a054c8573d Mon Sep 17 00:00:00 2001
From: Pascal Berger
Date: Wed, 24 Jul 2024 20:09:34 +0200
Subject: [PATCH 3/6] Fix repo root directory when not running on Windows
(#689)
---
src/Cake.Issues.Terraform/TerraformIssuesAliases.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Cake.Issues.Terraform/TerraformIssuesAliases.cs b/src/Cake.Issues.Terraform/TerraformIssuesAliases.cs
index 99a36ec06..a485565c1 100644
--- a/src/Cake.Issues.Terraform/TerraformIssuesAliases.cs
+++ b/src/Cake.Issues.Terraform/TerraformIssuesAliases.cs
@@ -53,7 +53,7 @@ public static IIssueProvider TerraformIssuesFromFilePath(
context.NotNull();
validateOutputFilePath.NotNull();
- return context.TerraformIssuesFromFilePath(validateOutputFilePath, "/");
+ return context.TerraformIssuesFromFilePath(validateOutputFilePath, "./");
}
///
@@ -118,7 +118,7 @@ public static IIssueProvider TerraformIssuesFromContent(
context.NotNull();
validateOutput.NotNullOrWhiteSpace();
- return context.TerraformIssues(new TerraformIssuesSettings(validateOutput.ToByteArray(), "/"));
+ return context.TerraformIssues(new TerraformIssuesSettings(validateOutput.ToByteArray(), "./"));
}
///
From 2514ce16b657c71c124ab6cf669e6f83ef29a33e Mon Sep 17 00:00:00 2001
From: Pascal Berger
Date: Thu, 25 Jul 2024 09:37:46 +0200
Subject: [PATCH 4/6] Add possibility to ignore arbitrary properties in
IssueComparer (#693)
---
src/Cake.Issues.Tests/IIssueComparerTests.cs | 1725 ++++++++++++++++++
src/Cake.Issues/IIssueComparer.cs | 272 ++-
src/Cake.Issues/IIssueProperty.cs | 120 ++
3 files changed, 2024 insertions(+), 93 deletions(-)
create mode 100644 src/Cake.Issues/IIssueProperty.cs
diff --git a/src/Cake.Issues.Tests/IIssueComparerTests.cs b/src/Cake.Issues.Tests/IIssueComparerTests.cs
index b289ee391..aba9c61c0 100644
--- a/src/Cake.Issues.Tests/IIssueComparerTests.cs
+++ b/src/Cake.Issues.Tests/IIssueComparerTests.cs
@@ -1802,4 +1802,1729 @@ private static void CompareIssues(IIssue issue1, IIssue issue2, bool expectedToB
}
}
}
+
+ public sealed class TheCtorWithIgnoredProperties
+ {
+ [Fact]
+ public void Should_Throw_If_First_Issue_Is_Null()
+ {
+ // Given
+ const IIssue issue1 = null;
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+
+ // When
+ var result = Record.Exception(() =>
+ CompareIssues(IIssueProperty.None, issue1, issue2, false));
+
+ // Then
+ result.IsArgumentNullException("obj");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Second_Issue_Is_Null()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+ const IIssue issue2 = null;
+
+ // When
+ var result = Record.Exception(() =>
+ CompareIssues(IIssueProperty.None, issue1, issue2, false));
+
+ // Then
+ result.IsArgumentNullException("obj");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Both_Are_Null()
+ {
+ // Given
+ const IIssue issue1 = null;
+ const IIssue issue2 = null;
+
+ // When
+ var result = Record.Exception(() =>
+ CompareIssues(IIssueProperty.None, issue1, issue2, true));
+
+ // Then
+ result.IsArgumentNullException("obj");
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_False_If_ProjectFileRelativePath_Is_Different_And_Property_Is_Not_Ignored(string path1, string path2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectFile(path1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectFile(path2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_True_If_ProjectFileRelativePath_Is_Different_And_Property_Is_Ignored(string path1, string path2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectFile(path1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectFile(path2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.ProjectFileRelativePath, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_False_If_ProjectName_Is_Different_And_Property_Is_Not_Ignored(string projectName1, string projectName2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectOfName(projectName1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectOfName(projectName2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_True_If_ProjectName_Is_Different_And_Property_Is_Ignored(string projectName1, string projectName2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectOfName(projectName1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectOfName(projectName2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.ProjectName, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_False_If_AffectedFileRelativePath_Is_Different_And_Property_Is_Not_Ignored(string path1, string path2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile(path1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile(path2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_True_If_AffectedFileRelativePath_Is_Different_And_Property_Is_Ignored(string path1, string path2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile(path1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile(path2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.AffectedFileRelativePath, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 2)]
+ [InlineData(1, null)]
+ [InlineData(null, 1)]
+ [InlineData(int.MaxValue, 1)]
+ [InlineData(1, int.MaxValue)]
+ public void Should_Return_False_If_Line_Is_Different_And_Property_Is_Not_Ignored(int? line1, int? line2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", line1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", line2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData(1, 2)]
+ [InlineData(1, null)]
+ [InlineData(null, 1)]
+ [InlineData(int.MaxValue, 1)]
+ [InlineData(1, int.MaxValue)]
+ public void Should_Return_True_If_Line_Is_Different_And_Property_Is_Ignored(int? line1, int? line2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", line1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", line2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Line, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 2)]
+ [InlineData(1, null)]
+ [InlineData(null, 1)]
+ [InlineData(int.MaxValue, 1)]
+ [InlineData(1, int.MaxValue)]
+ public void Should_Return_False_If_Column_Is_Different_And_Property_Is_Not_Ignored(int? column1, int? column2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", 42, column1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", 42, column2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData(1, 2)]
+ [InlineData(1, null)]
+ [InlineData(null, 1)]
+ [InlineData(int.MaxValue, 1)]
+ [InlineData(1, int.MaxValue)]
+ public void Should_Return_True_If_Column_Is_Different_And_Property_Is_Ignored(int? column1, int? column2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", 42, column1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", 42, column2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Column, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("http://foo", "http://bar")]
+ [InlineData("http://foo", null)]
+ [InlineData(null, "http://foo")]
+ public void Should_Return_False_If_FileLink_Is_Different_And_Property_Is_Not_Ignored(string fileLink1, string fileLink2)
+ {
+ // Given
+ var issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(fileLink1))
+ {
+ issueBuilder =
+ issueBuilder
+ .WithFileLink(new Uri(fileLink1));
+ }
+
+ var issue1 = issueBuilder.Create();
+
+ issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(fileLink2))
+ {
+ issueBuilder =
+ issueBuilder
+ .WithFileLink(new Uri(fileLink2));
+ }
+
+ var issue2 = issueBuilder.Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("http://foo", "http://bar")]
+ [InlineData("http://foo", null)]
+ [InlineData(null, "http://foo")]
+ public void Should_Return_True_If_FileLink_Is_Different_And_Property_Is_Ignored(string fileLink1, string fileLink2)
+ {
+ // Given
+ var issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(fileLink1))
+ {
+ issueBuilder =
+ issueBuilder
+ .WithFileLink(new Uri(fileLink1));
+ }
+
+ var issue1 = issueBuilder.Create();
+
+ issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(fileLink2))
+ {
+ issueBuilder =
+ issueBuilder
+ .WithFileLink(new Uri(fileLink2));
+ }
+
+ var issue2 = issueBuilder.Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.FileLink, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_False_If_MessageText_Is_Different_And_Property_Is_Not_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message1", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message2", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_MessageText_Is_Different_And_Property_Is_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message1", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message2", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Identifier | IIssueProperty.MessageText, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_False_If_MessageHtml_Is_Different_And_Property_Is_Not_Ignored(string message1, string message2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInHtmlFormat(message1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInHtmlFormat(message2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_True_If_MessageHtml_Is_Different_And_Property_Is_Ignored(string message1, string message2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInHtmlFormat(message1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInHtmlFormat(message2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.MessageHtml, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_False_If_MessageMarkdown_Is_Different_And_Property_Is_Not_Ignored(string message1, string message2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInMarkdownFormat(message1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInMarkdownFormat(message2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_True_If_MessageMarkdown_Is_Different_And_Property_Is_Ignored(string message1, string message2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInMarkdownFormat(message1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInMarkdownFormat(message2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.MessageMarkdown, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 2)]
+ [InlineData(1, null)]
+ [InlineData(null, 1)]
+ [InlineData(int.MinValue, 0)]
+ [InlineData(int.MaxValue, 0)]
+ public void Should_Return_False_If_Priority_Is_Different_And_Property_Is_Not_Ignored(int? priority1, int? priority2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(priority1, "Foo")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(priority2, "Foo")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData(1, 2)]
+ [InlineData(1, null)]
+ [InlineData(null, 1)]
+ [InlineData(int.MinValue, 0)]
+ [InlineData(int.MaxValue, 0)]
+ public void Should_Return_True_If_Priority_Is_Different_And_Property_Is_Ignored(int? priority1, int? priority2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(priority1, "Foo")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(priority2, "Foo")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Priority, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_False_If_PriorityName_Is_Different_And_Property_Is_Not_Ignored(string priorityName1, string priorityName2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(42, priorityName1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(42, priorityName2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_True_If_PriorityName_Is_Different_And_Property_Is_Ignored(string priorityName1, string priorityName2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(42, priorityName1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(42, priorityName2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.PriorityName, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_False_If_Rule_Is_Different_And_Property_Is_Not_Ignored(string rule1, string rule2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .OfRule(rule1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .OfRule(rule2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("foo", "bar")]
+ [InlineData("foo", "Foo")]
+ [InlineData("foo", null)]
+ [InlineData(null, "foo")]
+ public void Should_Return_True_If_Rule_Is_Different_And_Property_Is_Ignored(string rule1, string rule2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .OfRule(rule1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .OfRule(rule2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.RuleId, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("http://foo", "http://bar")]
+ [InlineData("http://foo", null)]
+ [InlineData(null, "http://foo")]
+ public void Should_Return_False_If_RuleUrl_Is_Different_And_Property_Is_Not_Ignored(string ruleUrl1, string ruleUrl2)
+ {
+ // Given
+ var issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(ruleUrl1))
+ {
+ issueBuilder =
+ issueBuilder
+ .OfRule("foo", new Uri(ruleUrl1));
+ }
+
+ var issue1 = issueBuilder.Create();
+
+ issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(ruleUrl2))
+ {
+ issueBuilder =
+ issueBuilder
+ .OfRule("foo", new Uri(ruleUrl2));
+ }
+
+ var issue2 = issueBuilder.Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Theory]
+ [InlineData("http://foo", "http://bar")]
+ [InlineData("http://foo", null)]
+ [InlineData(null, "http://foo")]
+ public void Should_Return_True_If_RuleUrl_Is_Different_And_Property_Is_Ignored(string ruleUrl1, string ruleUrl2)
+ {
+ // Given
+ var issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ Uri ruleUri1 = null;
+ if (!string.IsNullOrEmpty(ruleUrl1))
+ {
+ ruleUri1 = new Uri(ruleUrl1);
+ }
+ issueBuilder =
+ issueBuilder
+ .OfRule("foo", ruleUri1);
+
+ var issue1 = issueBuilder.Create();
+
+ issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ Uri ruleUri2 = null;
+ if (!string.IsNullOrEmpty(ruleUrl2))
+ {
+ ruleUri2 = new Uri(ruleUrl2);
+ }
+ issueBuilder =
+ issueBuilder
+ .OfRule("foo", ruleUri2);
+
+ var issue2 = issueBuilder.Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.RuleUrl, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_False_If_ProviderType_Is_Different_And_Property_Is_Not_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType1", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType2", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_ProviderType_Is_Different_And_Property_Is_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType1", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType2", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.ProviderType, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_False_If_ProviderName_Is_Different_And_Property_Is_Not_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName1")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName2")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_ProviderName_Is_Different_And_Property_Is_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName1")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName2")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.ProviderName, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_False_If_Run_Is_Different_And_Property_Is_Not_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .ForRun("run1")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .ForRun("run2")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_Run_Is_Different_And_Property_Is_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .ForRun("run1")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .ForRun("run2")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Run, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_Same_Reference()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+ var issue2 = issue1;
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_Properties_Are_The_Same()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("foo", "foo/")]
+ [InlineData("foo/", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_ProjectFileRelativePath_Is_Same_And_Property_Is_Not_Ignored(string path1, string path2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectFile(path1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectFile(path2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("foo", "foo/")]
+ [InlineData("foo/", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_ProjectFileRelativePath_Is_Same_And_Property_Is_Ignored(string path1, string path2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectFile(path1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectFile(path2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.ProjectFileRelativePath, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_ProjectName_Is_Same_And_Property_Is_Not_Ignored(string projectName1, string projectName2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectOfName(projectName1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectOfName(projectName2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_ProjectName_Is_Same_And_Property_Is_Ignored(string projectName1, string projectName2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectOfName(projectName1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InProjectOfName(projectName2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.ProjectName, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("foo", "foo/")]
+ [InlineData("foo/", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_AffectedFileRelativePath_Is_Same_And_Property_Is_Not_Ignored(string path1, string path2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile(path1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile(path2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("foo", "foo/")]
+ [InlineData("foo/", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_AffectedFileRelativePath_Is_Same_And_Property_Is_Ignored(string path1, string path2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile(path1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile(path2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.AffectedFileRelativePath, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 1)]
+ [InlineData(null, null)]
+ [InlineData(int.MaxValue, int.MaxValue)]
+ public void Should_Return_True_If_Line_Is_Same_And_Property_Is_Not_Ignored(int? line1, int? line2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", line1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", line2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 1)]
+ [InlineData(null, null)]
+ [InlineData(int.MaxValue, int.MaxValue)]
+ public void Should_Return_True_If_Line_Is_Same_And_Property_Is_Ignored(int? line1, int? line2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", line1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", line2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Line, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 1)]
+ [InlineData(null, null)]
+ [InlineData(int.MaxValue, int.MaxValue)]
+ public void Should_Return_True_If_Column_Is_Same_And_Property_Is_Not_Ignored(int? column1, int? column2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", 42, column1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", 42, column2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 1)]
+ [InlineData(null, null)]
+ [InlineData(int.MaxValue, int.MaxValue)]
+ public void Should_Return_True_If_Column_Is_Same_And_Property_Is_Ignored(int? column1, int? column2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", 42, column1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .InFile("foo", 42, column2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Column, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("http://foo", "http://foo")]
+ [InlineData("http://foo", "http://Foo")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_FileLink_Is_Same_And_Property_Is_Not_Ignored(string fileLink1, string fileLink2)
+ {
+ // Given
+ var issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(fileLink1))
+ {
+ issueBuilder =
+ issueBuilder
+ .WithFileLink(new Uri(fileLink1));
+ }
+
+ var issue1 = issueBuilder.Create();
+
+ issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(fileLink2))
+ {
+ issueBuilder =
+ issueBuilder
+ .WithFileLink(new Uri(fileLink2));
+ }
+
+ var issue2 = issueBuilder.Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("http://foo", "http://foo")]
+ [InlineData("http://foo", "http://Foo")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_FileLink_Is_Same_And_Property_Is_Ignored(string fileLink1, string fileLink2)
+ {
+ // Given
+ var issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(fileLink1))
+ {
+ issueBuilder =
+ issueBuilder
+ .WithFileLink(new Uri(fileLink1));
+ }
+
+ var issue1 = issueBuilder.Create();
+
+ issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(fileLink2))
+ {
+ issueBuilder =
+ issueBuilder
+ .WithFileLink(new Uri(fileLink2));
+ }
+
+ var issue2 = issueBuilder.Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.FileLink, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_MessageText_Is_Same_And_Property_Is_Not_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("messageText", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("messageText", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_MessageText_Is_Same_And_Property_Is_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("messageText", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("messageText", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.MessageText, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_MessageHtml_Is_Same_And_Property_Is_Not_Ignored(string message1, string message2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInHtmlFormat(message1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInHtmlFormat(message2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_MessageHtml_Is_Same_And_Property_Is_Ignored(string message1, string message2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInHtmlFormat(message1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInHtmlFormat(message2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.MessageHtml, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_MessageMarkdown_Is_Same_And_Property_Is_Not_Ignored(string message1, string message2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInMarkdownFormat(message1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInMarkdownFormat(message2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_MessageMarkdown_Is_Same_And_Property_Is_Ignored(string message1, string message2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInMarkdownFormat(message1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithMessageInMarkdownFormat(message2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.MessageMarkdown, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 1)]
+ [InlineData(null, null)]
+ [InlineData(0, 0)]
+ [InlineData(int.MinValue, int.MinValue)]
+ [InlineData(int.MaxValue, int.MaxValue)]
+ public void Should_Return_True_If_Priority_Is_Same_And_Property_Is_Not_Ignored(int? priority1, int? priority2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(priority1, "Foo")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(priority2, "Foo")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData(1, 1)]
+ [InlineData(null, null)]
+ [InlineData(0, 0)]
+ [InlineData(int.MinValue, int.MinValue)]
+ [InlineData(int.MaxValue, int.MaxValue)]
+ public void Should_Return_True_If_Priority_Is_Same_And_Property_Is_Ignored(int? priority1, int? priority2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(priority1, "Foo")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(priority2, "Foo")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Priority, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_PriorityName_Is_Same_And_Property_Is_Not_Ignored(string priorityName1, string priorityName2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(42, priorityName1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(42, priorityName2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_PriorityName_Is_Same_And_Property_Is_Ignored(string priorityName1, string priorityName2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(42, priorityName1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithPriority(42, priorityName2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.PriorityName, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_Rule_Is_Same_And_Property_Is_Not_Ignored(string rule1, string rule2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .OfRule(rule1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .OfRule(rule2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("foo", "foo")]
+ [InlineData("", "")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_Rule_Is_Same_And_Property_Is_Ignored(string rule1, string rule2)
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .OfRule(rule1)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .OfRule(rule2)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.RuleId, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("http://foo", "http://foo")]
+ [InlineData("http://foo", "http://Foo")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_RuleUrl_Is_Same_And_Property_Is_Not_Ignored(string ruleUrl1, string ruleUrl2)
+ {
+ // Given
+ var issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(ruleUrl1))
+ {
+ issueBuilder =
+ issueBuilder
+ .OfRule("foo", new Uri(ruleUrl1));
+ }
+
+ var issue1 = issueBuilder.Create();
+
+ issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(ruleUrl2))
+ {
+ issueBuilder =
+ issueBuilder
+ .OfRule("foo", new Uri(ruleUrl2));
+ }
+
+ var issue2 = issueBuilder.Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Theory]
+ [InlineData("http://foo", "http://foo")]
+ [InlineData("http://foo", "http://Foo")]
+ [InlineData(null, null)]
+ public void Should_Return_True_If_RuleUrl_Is_Same_And_Property_Is_Ignored(string ruleUrl1, string ruleUrl2)
+ {
+ // Given
+ var issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(ruleUrl1))
+ {
+ issueBuilder =
+ issueBuilder
+ .OfRule("foo", new Uri(ruleUrl1));
+ }
+
+ var issue1 = issueBuilder.Create();
+
+ issueBuilder =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName");
+ if (!string.IsNullOrEmpty(ruleUrl2))
+ {
+ issueBuilder =
+ issueBuilder
+ .OfRule("foo", new Uri(ruleUrl2));
+ }
+
+ var issue2 = issueBuilder.Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.RuleUrl, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_ProviderType_Is_Same_And_Property_Is_Not_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_ProviderType_Is_Same_And_Property_Is_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.ProviderType, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_AdditionalInformation_Is_Same_And_Property_Is_Not_Ignored()
+ {
+ const string id = "123";
+ const string lastname = "Kelso";
+ const string firstName = "Haley";
+
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithAdditionalInformation("Id", id)
+ .WithAdditionalInformation("Lastname", lastname)
+ .WithAdditionalInformation("Firstname", firstName)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithAdditionalInformation("Id", id)
+ .WithAdditionalInformation("Lastname", lastname)
+ .WithAdditionalInformation("Firstname", firstName)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_AdditionalInformation_Is_Same_And_Property_Is_Ignored()
+ {
+ const string id = "123";
+ const string lastname = "Kelso";
+ const string firstName = "Haley";
+
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithAdditionalInformation("Id", id)
+ .WithAdditionalInformation("Lastname", lastname)
+ .WithAdditionalInformation("Firstname", firstName)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithAdditionalInformation("Id", id)
+ .WithAdditionalInformation("Lastname", lastname)
+ .WithAdditionalInformation("Firstname", firstName)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.AdditionalInformation, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_False_If_AdditionalInformation_Is_Not_Same_And_Property_Is_Not_Ignored()
+ {
+ const string id = "123";
+ const string lastname = "Kelso";
+ const string correctFirstName = "Haley";
+ const string wrongFirstName = "Michael";
+
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithAdditionalInformation("Id", id)
+ .WithAdditionalInformation("Lastname", lastname)
+ .WithAdditionalInformation("Firstname", correctFirstName)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithAdditionalInformation("Id", id)
+ .WithAdditionalInformation("Lastname", lastname)
+ .WithAdditionalInformation("Firstname", wrongFirstName)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, false);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_AdditionalInformation_Is_Not_Same_And_Property_Is_Ignored()
+ {
+ const string id = "123";
+ const string lastname = "Kelso";
+ const string correctFirstName = "Haley";
+ const string wrongFirstName = "Michael";
+
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithAdditionalInformation("Id", id)
+ .WithAdditionalInformation("Lastname", lastname)
+ .WithAdditionalInformation("Firstname", correctFirstName)
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .WithAdditionalInformation("Id", id)
+ .WithAdditionalInformation("Lastname", lastname)
+ .WithAdditionalInformation("Firstname", wrongFirstName)
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.AdditionalInformation, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_ProviderName_Is_Same_And_Property_Is_Not_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_ProviderName_Is_Same_And_Property_Is_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.ProviderName, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_Run_Is_Same_And_Property_Is_Not_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .ForRun("run")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .ForRun("run")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.None, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Return_True_If_Run_Is_Same_And_Property_Is_Ignored()
+ {
+ // Given
+ var issue1 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .ForRun("run")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message", "providerType", "providerName")
+ .ForRun("run")
+ .Create();
+
+ // When / Then
+ CompareIssues(IIssueProperty.Run, issue1, issue2, true);
+ }
+
+ [Fact]
+ public void Should_Remove_Identical_Issues_From_List_Of_Issues()
+ {
+ // Given
+ var issue1_1 =
+ IssueBuilder
+ .NewIssue("message1", "providerType1", "providerName1")
+ .Create();
+ var issue1_2 =
+ IssueBuilder
+ .NewIssue("message1", "providerType1", "providerName1")
+ .Create();
+ var issue2 =
+ IssueBuilder
+ .NewIssue("message2", "providerType2", "providerName2")
+ .Create();
+ var issue3 =
+ IssueBuilder
+ .NewIssue("message3", "providerType3", "providerName3")
+ .Create();
+ var issues1 = new List { issue1_1, issue2 };
+ var issues2 = new List { issue1_2, issue3 };
+ var comparer = new IIssueComparer();
+
+ // When
+ var result = issues1.Except(issues2, comparer).ToList();
+
+ // Then
+ result.Count.ShouldBe(1);
+ result.ShouldContain(issue2);
+ }
+
+ private static void CompareIssues(IIssueProperty ignoredProperties, IIssue issue1, IIssue issue2, bool expectedToBeEqual)
+ {
+ var comparer = new IIssueComparer(ignoredProperties);
+
+ comparer.Equals(issue1, issue2).ShouldBe(expectedToBeEqual);
+
+ if (expectedToBeEqual)
+ {
+ comparer.GetHashCode(issue1).ShouldBe(comparer.GetHashCode(issue2));
+ }
+ else
+ {
+ comparer.GetHashCode(issue1).ShouldNotBe(comparer.GetHashCode(issue2));
+ }
+ }
+ }
}
diff --git a/src/Cake.Issues/IIssueComparer.cs b/src/Cake.Issues/IIssueComparer.cs
index e3219171b..a44abc2eb 100644
--- a/src/Cake.Issues/IIssueComparer.cs
+++ b/src/Cake.Issues/IIssueComparer.cs
@@ -6,38 +6,7 @@
///
/// Comparer to compare if two issues are identical.
///
-/// Flag indicating whether properties which
-/// are affected by changes in files should be considered while comparing issues.
-/// If set to true, the comparer can be used to compare issues from different
-/// build runs, where files might have been changed or renamed.
-///
-/// If is set to true the following
-/// properties will be ignored while comparing the issue:
-///
-/// -
-///
-///
-/// -
-///
-///
-/// -
-///
-///
-/// -
-///
-///
-/// -
-///
-///
-/// -
-///
-///
-/// -
-///
-///
-///
-///
-public class IIssueComparer(bool compareOnlyPersistentProperties) : IEqualityComparer
+public class IIssueComparer(IIssueProperty ignoredProperties) : IEqualityComparer
{
///
/// Initializes a new instance of the class.
@@ -48,79 +17,196 @@ public IIssueComparer()
{
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Flag indicating whether properties which
+ /// are affected by changes in files should be considered while comparing issues.
+ /// If set to true, the comparer can be used to compare issues from different
+ /// build runs, where files might have been changed or renamed.
+ ///
+ /// If is set to true the following
+ /// properties will be ignored while comparing the issue:
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ /// -
+ ///
+ ///
+ ///
+ ///
+ public IIssueComparer(bool compareOnlyPersistentProperties)
+ : this(compareOnlyPersistentProperties
+ ? IIssueProperty.ProjectFileRelativePath |
+ IIssueProperty.AffectedFileRelativePath |
+ IIssueProperty.Line |
+ IIssueProperty.EndLine |
+ IIssueProperty.Column |
+ IIssueProperty.EndColumn |
+ IIssueProperty.FileLink
+ : IIssueProperty.None)
+ {
+ }
+
///
public bool Equals(IIssue x, IIssue y) =>
ReferenceEquals(x, y) ||
(
x is not null &&
y is not null &&
- (x.Identifier == y.Identifier) &&
- (compareOnlyPersistentProperties || x.ProjectFileRelativePath?.FullPath == y.ProjectFileRelativePath?.FullPath) &&
- (x.ProjectName == y.ProjectName) &&
- (compareOnlyPersistentProperties || x.AffectedFileRelativePath?.FullPath == y.AffectedFileRelativePath?.FullPath) &&
- (compareOnlyPersistentProperties || x.Line == y.Line) &&
- (compareOnlyPersistentProperties || x.EndLine == y.EndLine) &&
- (compareOnlyPersistentProperties || x.Column == y.Column) &&
- (compareOnlyPersistentProperties || x.EndColumn == y.EndColumn) &&
- (compareOnlyPersistentProperties || x.FileLink == y.FileLink) &&
- (x.MessageText == y.MessageText) &&
- (x.MessageHtml == y.MessageHtml) &&
- (x.MessageMarkdown == y.MessageMarkdown) &&
- (x.Priority == y.Priority) &&
- (x.PriorityName == y.PriorityName) &&
- (x.RuleId == y.RuleId) &&
- (x.RuleName == y.RuleName) &&
- (x.RuleUrl?.ToString() == y.RuleUrl?.ToString()) &&
- (x.Run == y.Run) &&
- (x.ProviderType == y.ProviderType) &&
- (x.ProviderName == y.ProviderName) &&
- DictionaryContentEquals(x.AdditionalInformation, y.AdditionalInformation));
+ (ignoredProperties.HasFlag(IIssueProperty.Identifier) || x.Identifier == y.Identifier) &&
+ (ignoredProperties.HasFlag(IIssueProperty.ProjectFileRelativePath) || x.ProjectFileRelativePath?.FullPath == y.ProjectFileRelativePath?.FullPath) &&
+ (ignoredProperties.HasFlag(IIssueProperty.ProjectName) || x.ProjectName == y.ProjectName) &&
+ (ignoredProperties.HasFlag(IIssueProperty.AffectedFileRelativePath) || x.AffectedFileRelativePath?.FullPath == y.AffectedFileRelativePath?.FullPath) &&
+ (ignoredProperties.HasFlag(IIssueProperty.Line) || x.Line == y.Line) &&
+ (ignoredProperties.HasFlag(IIssueProperty.EndLine) || x.EndLine == y.EndLine) &&
+ (ignoredProperties.HasFlag(IIssueProperty.Column) || x.Column == y.Column) &&
+ (ignoredProperties.HasFlag(IIssueProperty.EndColumn) || x.EndColumn == y.EndColumn) &&
+ (ignoredProperties.HasFlag(IIssueProperty.FileLink) || x.FileLink == y.FileLink) &&
+ (ignoredProperties.HasFlag(IIssueProperty.MessageText) || x.MessageText == y.MessageText) &&
+ (ignoredProperties.HasFlag(IIssueProperty.MessageHtml) || x.MessageHtml == y.MessageHtml) &&
+ (ignoredProperties.HasFlag(IIssueProperty.MessageMarkdown) || x.MessageMarkdown == y.MessageMarkdown) &&
+ (ignoredProperties.HasFlag(IIssueProperty.Priority) || x.Priority == y.Priority) &&
+ (ignoredProperties.HasFlag(IIssueProperty.PriorityName) || x.PriorityName == y.PriorityName) &&
+ (ignoredProperties.HasFlag(IIssueProperty.RuleId) || x.RuleId == y.RuleId) &&
+ (ignoredProperties.HasFlag(IIssueProperty.RuleName) || x.RuleName == y.RuleName) &&
+ (ignoredProperties.HasFlag(IIssueProperty.RuleUrl) || x.RuleUrl?.ToString() == y.RuleUrl?.ToString()) &&
+ (ignoredProperties.HasFlag(IIssueProperty.Run) || x.Run == y.Run) &&
+ (ignoredProperties.HasFlag(IIssueProperty.ProviderType) || x.ProviderType == y.ProviderType) &&
+ (ignoredProperties.HasFlag(IIssueProperty.ProviderName) || x.ProviderName == y.ProviderName) &&
+ (ignoredProperties.HasFlag(IIssueProperty.AdditionalInformation) || DictionaryContentEquals(x.AdditionalInformation, y.AdditionalInformation)));
///
public int GetHashCode(IIssue obj)
{
obj.NotNull(nameof(obj));
- return compareOnlyPersistentProperties
- ? GetHashCode(
- obj.Identifier,
- obj.ProjectName,
- obj.MessageText,
- obj.MessageHtml,
- obj.MessageMarkdown,
- obj.Priority,
- obj.PriorityName,
- obj.RuleId,
- obj.RuleName,
- obj.RuleUrl,
- obj.Run,
- obj.ProviderType,
- obj.ProviderName) +
- GetDictionaryHashCode(
- obj.AdditionalInformation)
- : GetHashCode(
- obj.Identifier,
- obj.ProjectFileRelativePath?.ToString(),
- obj.ProjectName,
- obj.AffectedFileRelativePath?.ToString(),
- obj.Line,
- obj.EndLine,
- obj.Column,
- obj.EndColumn,
- obj.FileLink,
- obj.MessageText,
- obj.MessageHtml,
- obj.MessageMarkdown,
- obj.Priority,
- obj.PriorityName,
- obj.RuleId,
- obj.RuleName,
- obj.RuleUrl,
- obj.Run,
- obj.ProviderType,
- obj.ProviderName) +
- GetDictionaryHashCode(
- obj.AdditionalInformation);
+ var valuesToHash = new List