diff --git a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs index 61f9c919..1a74eda7 100644 --- a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs @@ -42,6 +42,76 @@ public class IssuesEventsClientTests : IDisposable Assert.Equal(EventInfoState.Closed, issueEventInfo[0].Event); } + [IntegrationTest] + public async Task ReturnsCorrectCountOfEventInfosWithoutStart() + { + var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var eventInfos = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, options); + + Assert.Equal(3, eventInfos.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfEventInfosWithStart() + { + var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var eventInfos = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, options); + + Assert.Equal(1, eventInfos.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var newIssue = new NewIssue("issue 1") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstPage = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, skipStartOptions); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + } + [IntegrationTest] public async Task CanListIssueEventsForARepository() {