-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1228 from TattsGroup/search-issues
Implement additional `SearchIssuesRequest` options
- Loading branch information
Showing
13 changed files
with
1,028 additions
and
54 deletions.
There are no files selected for viewing
408 changes: 398 additions & 10 deletions
408
Octokit.Tests.Integration/Clients/SearchClientTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
85 changes: 85 additions & 0 deletions
85
Octokit.Tests/Models/SearchIssuesRequestExclusionsTests.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,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Octokit; | ||
using Octokit.Tests.Helpers; | ||
using Xunit; | ||
|
||
public class SearchIssuesRequestExclusionsTests | ||
{ | ||
public class TheExclusionsMergedQualifiersMethod | ||
{ | ||
[Fact] | ||
public void HandlesStringAttributesCorrectly() | ||
{ | ||
var stringProperties = new Dictionary<string, Action<SearchIssuesRequestExclusions, string>>() | ||
{ | ||
{ "author:", (x,value) => x.Author = value }, | ||
{ "assignee:", (x,value) => x.Assignee = value }, | ||
{ "mentions:", (x,value) => x.Mentions = value }, | ||
{ "commenter:", (x,value) => x.Commenter = value }, | ||
{ "involves:", (x,value) => x.Involves = value }, | ||
{ "head:", (x,value) => x.Head = value }, | ||
{ "base:", (x,value) => x.Base = value } | ||
}; | ||
|
||
foreach (var property in stringProperties) | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
|
||
// Ensure the specified parameter does not exist when not set | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains(property.Key))); | ||
|
||
// Set the parameter | ||
property.Value(request, "blah"); | ||
|
||
// Ensure the specified parameter now exists | ||
Assert.True(request.MergedQualifiers().Count(x => x.Contains(property.Key)) == 1); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void HandlesStateAttributeCorrectly() | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains("-state:"))); | ||
|
||
request.State = ItemState.Closed; | ||
Assert.True(request.MergedQualifiers().Contains("-state:closed")); | ||
} | ||
|
||
[Fact] | ||
public void HandlesExcludeLabelsAttributeCorrectly() | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains("-label:"))); | ||
|
||
request.Labels = new[] { "label1", "label2" }; | ||
|
||
Assert.True(request.MergedQualifiers().Contains("-label:label1")); | ||
Assert.True(request.MergedQualifiers().Contains("-label:label2")); | ||
} | ||
|
||
[Fact] | ||
public void HandlesLanguageAttributeCorrectly() | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains("-language:"))); | ||
|
||
request.Language = Language.CSharp; | ||
|
||
Assert.True(request.MergedQualifiers().Contains("-language:C#")); | ||
} | ||
|
||
[Fact] | ||
public void HandlesStatusAttributeCorrectly() | ||
{ | ||
var request = new SearchIssuesRequestExclusions(); | ||
Assert.False(request.MergedQualifiers().Any(x => x.Contains("-status:"))); | ||
|
||
request.Status = CommitState.Error; | ||
|
||
Assert.True(request.MergedQualifiers().Contains("-status:error")); | ||
} | ||
} | ||
} |
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
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.