mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 20:13:40 +00:00
Merge pull request #842 from khellang/refine-search-api
Changed repos to a specialized collection
This commit is contained in:
@@ -47,9 +47,9 @@ public class SearchClientTests
|
||||
public async Task SearchForWordInCode()
|
||||
{
|
||||
var request = new SearchIssuesRequest("windows");
|
||||
request.Repos = new Collection<string> {
|
||||
"aspnet/dnx",
|
||||
"aspnet/dnvm"
|
||||
request.Repos = new RepositoryCollection {
|
||||
{ "aspnet", "dnx" },
|
||||
{ "aspnet", "dnvm" }
|
||||
};
|
||||
|
||||
request.SortField = IssueSearchSort.Created;
|
||||
@@ -64,7 +64,7 @@ public class SearchClientTests
|
||||
public async Task SearchForOpenIssues()
|
||||
{
|
||||
var request = new SearchIssuesRequest("phone");
|
||||
request.Repos.Add("caliburn-micro/caliburn.micro");
|
||||
request.Repos.Add("caliburn-micro", "caliburn.micro");
|
||||
request.State = ItemState.Open;
|
||||
|
||||
var issues = await _gitHubClient.Search.SearchIssues(request);
|
||||
@@ -91,7 +91,7 @@ public class SearchClientTests
|
||||
public async Task SearchForAllIssuesUsingTerm()
|
||||
{
|
||||
var request = new SearchIssuesRequest("phone");
|
||||
request.Repos.Add("caliburn-micro/caliburn.micro");
|
||||
request.Repos.Add("caliburn-micro", "caliburn.micro");
|
||||
|
||||
var issues = await _gitHubClient.Search.SearchIssues(request);
|
||||
|
||||
|
||||
@@ -1151,7 +1151,7 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchIssuesRequest("something");
|
||||
request.Repos.Add("octokit/octokit.net");
|
||||
request.Repos.Add("octokit", "octokit.net");
|
||||
|
||||
client.SearchIssues(request);
|
||||
|
||||
@@ -1167,8 +1167,8 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
|
||||
var request = new SearchIssuesRequest("windows");
|
||||
request.Repos = new Collection<string> {
|
||||
"haha-business"
|
||||
request.Repos = new RepositoryCollection {
|
||||
{ "haha-business", "some&name" }
|
||||
};
|
||||
|
||||
request.SortField = IssueSearchSort.Created;
|
||||
@@ -1512,7 +1512,7 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(connection);
|
||||
|
||||
var request = new SearchCodeRequest("windows");
|
||||
request.Repos = new Collection<string> {
|
||||
request.Repos = new RepositoryCollection {
|
||||
"haha-business"
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Octokit
|
||||
{
|
||||
public SearchCodeRequest(string term) : base(term)
|
||||
{
|
||||
Repos = new Collection<string>();
|
||||
Repos = new RepositoryCollection();
|
||||
}
|
||||
|
||||
public SearchCodeRequest(string term, string owner, string name)
|
||||
@@ -27,9 +27,7 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var repo = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, name);
|
||||
|
||||
Repos.Add(repo);
|
||||
Repos.Add(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -123,7 +121,7 @@ namespace Octokit
|
||||
/// https://help.github.com/articles/searching-code#users-organizations-and-repositories
|
||||
/// </remarks>
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public Collection<string> Repos { get; set; }
|
||||
public RepositoryCollection Repos { get; set; }
|
||||
|
||||
[SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.String.ToLower")]
|
||||
public override IReadOnlyList<string> MergedQualifiers()
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Octokit
|
||||
/// </summary>
|
||||
public SearchIssuesRequest()
|
||||
{
|
||||
Repos = new Collection<string>();
|
||||
Repos = new RepositoryCollection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -29,7 +29,7 @@ namespace Octokit
|
||||
/// <param name="term">The term to filter on</param>
|
||||
public SearchIssuesRequest(string term) : base(term)
|
||||
{
|
||||
Repos = new Collection<string>();
|
||||
Repos = new RepositoryCollection();
|
||||
}
|
||||
|
||||
[Obsolete("this will be deprecated in a future version")]
|
||||
@@ -39,9 +39,7 @@ namespace Octokit
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var repo = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, name);
|
||||
|
||||
Repos.Add(repo);
|
||||
Repos.Add(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -196,7 +194,7 @@ namespace Octokit
|
||||
public string User { get; set; }
|
||||
|
||||
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
|
||||
public Collection<string> Repos { get; set; }
|
||||
public RepositoryCollection Repos { get; set; }
|
||||
|
||||
public override IReadOnlyList<string> MergedQualifiers()
|
||||
{
|
||||
@@ -337,4 +335,30 @@ namespace Octokit
|
||||
[Parameter(Value = "issue")]
|
||||
Issue
|
||||
}
|
||||
|
||||
public class RepositoryCollection : Collection<string>
|
||||
{
|
||||
public void Add(string owner, string name)
|
||||
{
|
||||
Add(GetRepositoryName(owner, name));
|
||||
}
|
||||
|
||||
public bool Contains(string owner, string name)
|
||||
{
|
||||
return Contains(GetRepositoryName(owner, name));
|
||||
}
|
||||
|
||||
public bool Remove(string owner, string name)
|
||||
{
|
||||
return Remove(GetRepositoryName(owner, name));
|
||||
}
|
||||
|
||||
private static string GetRepositoryName(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user