From d68d00913a57a8c0ab27d766fd59e2751a3edea8 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Thu, 30 Jun 2016 04:32:53 +0700 Subject: [PATCH] added fixes in integration tests --- .../Clients/IssuesEventsClientTests.cs | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs index 1833a838..b8880491 100644 --- a/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesEventsClientTests.cs @@ -1,11 +1,10 @@ using System; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; -using Xunit; using Octokit.Tests.Integration.Helpers; +using Xunit; public class IssuesEventsClientTests : IDisposable { @@ -34,8 +33,7 @@ public class IssuesEventsClientTests : IDisposable var issueEventInfo = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.Empty(issueEventInfo); - var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }); Assert.NotNull(closed); issueEventInfo = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); @@ -52,8 +50,7 @@ public class IssuesEventsClientTests : IDisposable var issueEventInfo = await _issuesEventsClient.GetAllForIssue(_context.Repository.Id, issue.Number); Assert.Empty(issueEventInfo); - var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }); Assert.NotNull(closed); issueEventInfo = await _issuesEventsClient.GetAllForIssue(_context.Repository.Id, issue.Number); @@ -159,7 +156,7 @@ public class IssuesEventsClientTests : IDisposable }; var firstPage = await _issuesEventsClient.GetAllForIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number, startOptions); - + var skipStartOptions = new ApiOptions { PageSize = 1, @@ -188,7 +185,7 @@ public class IssuesEventsClientTests : IDisposable }; var firstPage = await _issuesEventsClient.GetAllForIssue(_context.Repository.Id, issue.Number, startOptions); - + var skipStartOptions = new ApiOptions { PageSize = 1, @@ -209,21 +206,18 @@ public class IssuesEventsClientTests : IDisposable var newIssue2 = new NewIssue("A test issue2") { Body = "A new unassigned issue" }; var issue1 = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue1); - Thread.Sleep(1000); + await Task.Delay(1000); var issue2 = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue2); - Thread.Sleep(1000); + await Task.Delay(1000); // close and open issue1 - var closed1 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed1 = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Closed }); Assert.NotNull(closed1); - var reopened1 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Open }) - .Result; + var reopened1 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Open }); Assert.NotNull(reopened1); // close issue2 - var closed2 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue2.Number, new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed2 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue2.Number, new IssueUpdate { State = ItemState.Closed }); Assert.NotNull(closed2); var issueEvents = await _issuesEventsClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); @@ -240,21 +234,18 @@ public class IssuesEventsClientTests : IDisposable var newIssue2 = new NewIssue("A test issue2") { Body = "A new unassigned issue" }; var issue1 = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue1); - Thread.Sleep(1000); + await Task.Delay(1000); var issue2 = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue2); - Thread.Sleep(1000); + await Task.Delay(1000); // close and open issue1 - var closed1 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed1 = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Closed }); Assert.NotNull(closed1); - var reopened1 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Open }) - .Result; + var reopened1 = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue1.Number, new IssueUpdate { State = ItemState.Open }); Assert.NotNull(reopened1); // close issue2 - var closed2 = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue2.Number, new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed2 = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue2.Number, new IssueUpdate { State = ItemState.Closed }); Assert.NotNull(closed2); var issueEvents = await _issuesEventsClient.GetAllForRepository(_context.Repository.Id); @@ -408,8 +399,7 @@ public class IssuesEventsClientTests : IDisposable { var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }); Assert.NotNull(closed); var issueEvents = await _issuesEventsClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName); int issueEventId = issueEvents[0].Id; @@ -425,8 +415,7 @@ public class IssuesEventsClientTests : IDisposable { var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed = await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }); Assert.NotNull(closed); var issueEvents = await _issuesEventsClient.GetAllForRepository(_context.Repository.Id); int issueEventId = issueEvents[0].Id;