This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0490acd
commit 977ddf6
Showing
11 changed files
with
297 additions
and
212 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); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.