public void HandlesStringAttributesCorrectly() { var stringProperties = new Dictionary <string, Action <SearchIssuesRequest, 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 }, { "team:", (x, value) => x.Team = value }, { "head:", (x, value) => x.Head = value }, { "base:", (x, value) => x.Base = value }, { "user:"******"query"); // 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); } }
public void HandlesMilestoneAttributeWithoutQuotes() { var request = new SearchIssuesRequest("text"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("milestone:"))); request.Milestone = "testMilestone"; Assert.True(request.MergedQualifiers().Contains("milestone:\"testMilestone\"")); }
public void HandlesLanguageAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("language:")); request.Language = Language.CSharp; Assert.Contains("language:\"CSharp\"", request.MergedQualifiers()); }
public void HandlesNoMetadataAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("no:")); request.No = IssueNoMetadataQualifier.Milestone; Assert.Contains("no:milestone", request.MergedQualifiers()); }
public void DoesntWrapMilestoneWithDoubleQuotesForQuotedMilestone() { var request = new SearchIssuesRequest("text"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("milestone:"))); request.Milestone = "\"testMilestone\""; Assert.Contains <string>("milestone:\"\\\"testMilestone\\\"\"", request.MergedQualifiers()); }
public void HandlesStateAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("state:"))); request.State = ItemState.Closed; Assert.True(request.MergedQualifiers().Contains("state:closed")); }
public void HandlesStatusAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("status:"))); request.Status = CommitState.Error; Assert.True(request.MergedQualifiers().Contains("status:error")); }
public void HandlesCommentsAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("comments:"))); request.Comments = Range.GreaterThan(5); Assert.True(request.MergedQualifiers().Contains("comments:>5")); }
public void HandlesLanguageAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("language:"))); request.Language = Language.CSharp; Assert.True(request.MergedQualifiers().Contains("language:C#")); }
public void HandlesMilestoneAttributeWithoutQuotes() { var request = new SearchIssuesRequest("text"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("milestone:")); request.Milestone = "testMilestone"; Assert.Contains("milestone:\"testMilestone\"", request.MergedQualifiers()); }
public void HandlesNoMetadataAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("no:"))); request.No = IssueNoMetadataQualifier.Milestone; Assert.True(request.MergedQualifiers().Contains("no:milestone")); }
public void HandlesStateAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("state:")); request.State = ItemState.Closed; Assert.Contains("state:closed", request.MergedQualifiers()); }
public void HandlesCommentsAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("comments:")); request.Comments = Range.GreaterThan(5); Assert.Contains("comments:>5", request.MergedQualifiers()); }
public void HandlesStatusAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("status:")); request.Status = CommitState.Error; Assert.Contains("status:error", request.MergedQualifiers()); }
public void HandlesLabelsAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("label:")); request.Labels = new[] { "label1", "label 2" }; Assert.Contains("label:\"label1\"", request.MergedQualifiers()); Assert.Contains("label:\"label 2\"", request.MergedQualifiers()); }
public void HandlesLabelsAttributeCorrectly() { var request = new SearchIssuesRequest("test"); 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")); }
public void HandlesRepoAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("repo:"))); request.Repos.Add("myorg", "repo1"); request.Repos.Add("myorg", "repo2"); Assert.True(request.MergedQualifiers().Contains("repo:myorg/repo1")); Assert.True(request.MergedQualifiers().Contains("repo:myorg/repo2")); }
public void HandlesInAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("in:"))); request.In = new List <IssueInQualifier> { IssueInQualifier.Body, IssueInQualifier.Comment }; Assert.True(request.MergedQualifiers().Contains("in:body,comment")); }
public void HandlesRepoAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("repo:")); request.Repos.Add("myorg", "repo1"); request.Repos.Add("myorg", "repo2"); Assert.Contains("repo:myorg/repo1", request.MergedQualifiers()); Assert.Contains("repo:myorg/repo2", request.MergedQualifiers()); }
public void HandlesIsAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.False(request.MergedQualifiers().Any(x => x.Contains("is:"))); request.Is = new List <IssueIsQualifier> { IssueIsQualifier.Merged, IssueIsQualifier.PullRequest }; Assert.True(request.MergedQualifiers().Contains("is:merged")); Assert.True(request.MergedQualifiers().Contains("is:pr")); }
public void HandlesIsAttributeCorrectly() { var request = new SearchIssuesRequest("test"); Assert.DoesNotContain(request.MergedQualifiers(), x => x.Contains("is:")); request.Is = new List <IssueIsQualifier> { IssueIsQualifier.Merged, IssueIsQualifier.PullRequest }; Assert.Contains("is:merged", request.MergedQualifiers()); Assert.Contains("is:pr", request.MergedQualifiers()); }
public static async Task <IReadOnlyList <Issue> > SearchIssuesLogged(this GitHubClient github, SearchIssuesRequest query, ILogger logger) { var queryText = string.Join(" ", query.MergedQualifiers()); logger.LogInformation("Executing GitHub query: {Query}", queryText); var issues = new List <Issue>(); while (true) { var results = await github.Search.SearchIssues(query); if (results.Items.Count == 0) { break; } if (results.IncompleteResults) { logger.LogWarning("Results are incomplete!"); } issues.AddRange(results.Items); query.Page += 1; } // Get all the issues var apiInfo = github.GetLastApiInfo(); logger.LogInformation("Received {Count} results. Rate Limit Remaining {Remaining} (Resets At: {ResetAt})", issues.Count, apiInfo.RateLimit.Remaining, apiInfo.RateLimit.Reset.LocalDateTime); return(issues); }
public void ReturnsAReadOnlyDictionary() { var request = new SearchIssuesRequest("test"); var result = request.MergedQualifiers(); // If I can cast this to a writeable collection, then that defeats the purpose of a read only. AssertEx.IsReadOnlyCollection <string>(result); }
public void HandlesDateRangeAttributesCorrectly() { var dateProperties = new Dictionary <string, Action <SearchIssuesRequest, DateRange> > { { "created:", (x, value) => x.Created = value }, { "updated:", (x, value) => x.Updated = value }, { "merged:", (x, value) => x.Merged = value }, { "closed:", (x, value) => x.Closed = value } }; foreach (var property in dateProperties) { var request = new SearchIssuesRequest("query"); // 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, DateRange.GreaterThan(DateTime.Today.AddDays(-7))); // Ensure the specified parameter now exists Assert.True(request.MergedQualifiers().Count(x => x.Contains(property.Key)) == 1); } }