This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to limit posted issues for a specific provider (#158)
This pullrequest introduces a new property ProviderType to the IPullRequestDiscussionThread interface. The ProviderType is being used to restrict each providers issues by either a maximum limit across all runs or a limit for each individual run. Co-authored-by: janniksam <jannik.sam@gmail.com> Co-authored-by: Pascal Berger <bep@bbtsoftware.ch>
- Loading branch information
1 parent
098d34f
commit caa3eba
Showing
12 changed files
with
1,478 additions
and
14 deletions.
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
src/Cake.Issues.PullRequests.Tests/IIssueExtensionsTests.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,127 @@ | ||
namespace Cake.Issues.PullRequests.Tests | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Cake.Issues.Testing; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
public sealed class IIssueExtensionsTests | ||
{ | ||
public sealed class TheSortWithDefaultPriorizationMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Issues_Are_Null() | ||
{ | ||
// Given | ||
IEnumerable<IIssue> issues = null; | ||
|
||
// When | ||
var result = | ||
Record.Exception(() => | ||
issues.SortWithDefaultPriorization()); | ||
|
||
// Then | ||
result.IsArgumentNullException("issues"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Order_By_Priority() | ||
{ | ||
// Given | ||
var issue1 = | ||
IssueBuilder | ||
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") | ||
.InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 10) | ||
.OfRule("Rule Foo") | ||
.WithPriority(IssuePriority.Warning) | ||
.Create(); | ||
var issue2 = | ||
IssueBuilder | ||
.NewIssue("Message Bar", "ProviderType Bar", "ProviderName Bar") | ||
.InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 12) | ||
.OfRule("Rule Bar") | ||
.WithPriority(IssuePriority.Error) | ||
.Create(); | ||
var issues = | ||
new List<IIssue> | ||
{ | ||
issue1, | ||
issue2, | ||
}; | ||
|
||
// When | ||
var result = issues.SortWithDefaultPriorization(); | ||
|
||
// Then | ||
result.First().ShouldBe(issue2); | ||
result.Last().ShouldBe(issue1); | ||
} | ||
|
||
[Fact] | ||
public void Should_Order_By_Existance_Of_FilePath() | ||
{ | ||
// Given | ||
var issue1 = | ||
IssueBuilder | ||
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") | ||
.OfRule("Rule Foo") | ||
.WithPriority(IssuePriority.Warning) | ||
.Create(); | ||
var issue2 = | ||
IssueBuilder | ||
.NewIssue("Message Bar", "ProviderType Bar", "ProviderName Bar") | ||
.InFile(@"src\Cake.Issues.Tests\FakeIssueProvider.cs", 12) | ||
.OfRule("Rule Bar") | ||
.WithPriority(IssuePriority.Warning) | ||
.Create(); | ||
var issues = | ||
new List<IIssue> | ||
{ | ||
issue1, | ||
issue2, | ||
}; | ||
|
||
// When | ||
var result = issues.SortWithDefaultPriorization(); | ||
|
||
// Then | ||
result.First().ShouldBe(issue2); | ||
result.Last().ShouldBe(issue1); | ||
} | ||
|
||
[Fact] | ||
public void Should_Order_By_FilePath() | ||
{ | ||
// Given | ||
var issue1 = | ||
IssueBuilder | ||
.NewIssue("Message Foo", "ProviderType Foo", "ProviderName Foo") | ||
.OfRule("Rule Foo") | ||
.InFile(@"src\Cake.Issues.Tests\B.cs", 12) | ||
.WithPriority(IssuePriority.Warning) | ||
.Create(); | ||
var issue2 = | ||
IssueBuilder | ||
.NewIssue("Message Bar", "ProviderType Bar", "ProviderName Bar") | ||
.InFile(@"src\Cake.Issues.Tests\A.cs", 12) | ||
.OfRule("Rule Bar") | ||
.WithPriority(IssuePriority.Warning) | ||
.Create(); | ||
var issues = | ||
new List<IIssue> | ||
{ | ||
issue1, | ||
issue2, | ||
}; | ||
|
||
// When | ||
var result = issues.SortWithDefaultPriorization(); | ||
|
||
// Then | ||
result.First().ShouldBe(issue2); | ||
result.Last().ShouldBe(issue1); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.