<commit_before>﻿using System;
using System.Threading.Tasks;
using Octokit.Tests.Integration.Helpers;
using Xunit;

namespace Octokit.Tests.Integration.Clients
{
    public class IssueTimelineClientTests : IDisposable
    {
        private readonly IIssueTimelineClient _issueTimelineClient;
        private readonly IIssuesClient _issuesClient;
        private readonly RepositoryContext _context;

        public IssueTimelineClientTests()
        {
            var github = Helper.GetAuthenticatedClient();

            _issueTimelineClient = github.Issue.Timeline;
            _issuesClient = github.Issue;

            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _context = github.CreateRepositoryContext(new NewRepository(repoName)).Result;
        }

        [IntegrationTest]
        public async Task CanRetrieveTimelineForIssue()
        {
            var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503);
            Assert.NotEmpty(timelineEventInfos);
            Assert.NotEqual(0, timelineEventInfos.Count);
        }

        [IntegrationTest]
        public async Task CanRetrieveTimelineForIssueWithApiOptions()
        {
            var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503);
            Assert.NotEmpty(timelineEventInfos);
            Assert.NotEqual(1, timelineEventInfos.Count);

            var pageOptions = new ApiOptions
            {
                PageSize = 1,
                PageCount = 1,
                StartPage = 1
            };

            timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503, pageOptions);
            Assert.NotEmpty(timelineEventInfos);
            Assert.Equal(1, timelineEventInfos.Count);
        }

        [IntegrationTest]
        public async Task CanDeserializeRenameEvent()
        {
            var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" };
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

            var renamed = await _issuesClient.Update(_context.Repository.Id, issue.Number, new IssueUpdate { Title = "A test issue" });
            Assert.NotNull(renamed);<commit_msg>Write a timeline test that processes the most recent 20 closed PRs and 20 open Issues in octokit.net in attempt to more likely encounter a new EventType enum value added by github api changes<commit_after>﻿using System;
using System.Threading.Tasks;
using Octokit.Tests.Integration.Helpers;
using Xunit;

namespace Octokit.Tests.Integration.Clients
{
    public class IssueTimelineClientTests : IDisposable
    {
        private readonly IIssueTimelineClient _issueTimelineClient;
        private readonly IIssuesClient _issuesClient;
        private readonly RepositoryContext _context;

        public IssueTimelineClientTests()
        {
            var github = Helper.GetAuthenticatedClient();

            _issueTimelineClient = github.Issue.Timeline;
            _issuesClient = github.Issue;

            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _context = github.CreateRepositoryContext(new NewRepository(repoName)).Result;
        }

        [IntegrationTest]
        public async Task CanRetrieveTimelineForIssue()
        {
            var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503);
            Assert.NotEmpty(timelineEventInfos);
            Assert.NotEqual(0, timelineEventInfos.Count);
        }

        [IntegrationTest]
        public async Task CanRetrieveTimelineForIssueWithApiOptions()
        {
            var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503);
            Assert.NotEmpty(timelineEventInfos);
            Assert.NotEqual(1, timelineEventInfos.Count);

            var pageOptions = new ApiOptions
            {
                PageSize = 1,
                PageCount = 1,
                StartPage = 1
            };

            timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", 1503, pageOptions);
            Assert.NotEmpty(timelineEventInfos);
            Assert.Equal(1, timelineEventInfos.Count);
        }

        [IntegrationTest]
        public async Task CanRetrieveTimelineForRecentIssues()
        {
            // Make sure we can deserialize the event timeline for the 20 most recent closed PRs and 20 most recent open Issues from octokit.net

            // Search request
            var github = Helper.GetAuthenticatedClient();
            var search = new SearchIssuesRequest
            {
                PerPage = 20,
                Page = 1
            };
            search.Repos.Add("octokit", "octokit.net");

            // 20 most recent closed PRs
            search.Type = IssueTypeQualifier.PullRequest;
            search.State = ItemState.Closed;
            var pullRequestResults = await github.Search.SearchIssues(search);
            foreach (var pullRequest in pullRequestResults.Items)
            {
                var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", pullRequest.Number);
                Assert.NotEmpty(timelineEventInfos);
            }

            // 20 most recent open Issues
            search.Type = IssueTypeQualifier.Issue;
            search.State = ItemState.Open;
            var issueResults = await github.Search.SearchIssues(search);
            foreach (var issue in issueResults.Items)
            {
                var timelineEventInfos = await _issueTimelineClient.GetAllForIssue("octokit", "octokit.net", issue.Number);

                Assert.NotNull(timelineEventInfos);
            }
        }

        [IntegrationTest]
        public async Task CanDeserializeRenameEvent()
        {
            var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" };
            var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue);

            var renamed = await _issuesClient.Update(_context.Repository.Id, issue.Number, new IssueUpdate { Title = "A test issue" });
            Assert.NotNull(renamed);
{'fraction_non_alphanumeric': 0.07647245091830272, 'fraction_numerical': 0.008074730842305257, 'mean_word_length': 2.3816916488222697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7248140', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1603, 'n_words': 369}