Exemplo n.º 1
0
        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\""));
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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());
        }
Exemplo n.º 6
0
        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"));
        }
Exemplo n.º 7
0
        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"));
        }
Exemplo n.º 8
0
        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"));
        }
Exemplo n.º 9
0
        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#"));
        }
Exemplo n.º 10
0
        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());
        }
Exemplo n.º 11
0
        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"));
        }
Exemplo n.º 12
0
        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());
        }
Exemplo n.º 13
0
        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());
        }
Exemplo n.º 14
0
        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());
        }
Exemplo n.º 15
0
        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());
        }
Exemplo n.º 16
0
        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"));
        }
Exemplo n.º 17
0
        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"));
        }
Exemplo n.º 18
0
        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"));
        }
Exemplo n.º 19
0
        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());
        }
Exemplo n.º 20
0
        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"));
        }
Exemplo n.º 21
0
        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());
        }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 24
0
        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);
            }
        }