From f6154dac9fa6b7a8d2f5b9178c0b9d9153c7453e Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Thu, 13 Apr 2017 18:04:04 +1000 Subject: [PATCH] bugfix - PUT should have a payload for Mark as Read (#1579) * bugfix - PUT should have a payload for Mark as Read * also fix the Observable client test * add integration tests for MarkRead methods * Fixup MarkReadForRepository methods to specify a body in the PUT request * Fix unit tests for regular and observable client * helps if the new files are included in the test project :) --- .../Clients/NotificationsClientTests.cs | 41 ++++++++++++++++++ .../Octokit.Tests.Integration.csproj | 2 + .../ObservableNotificationsClientTests.cs | 43 +++++++++++++++++++ .../Clients/NotificationsClientTests.cs | 6 +-- .../ObservableNotificationsClientTests.cs | 6 +-- Octokit/Clients/NotificationsClient.cs | 6 +-- 6 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 Octokit.Tests.Integration/Clients/NotificationsClientTests.cs create mode 100644 Octokit.Tests.Integration/Reactive/ObservableNotificationsClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/NotificationsClientTests.cs b/Octokit.Tests.Integration/Clients/NotificationsClientTests.cs new file mode 100644 index 00000000..0b85b1cb --- /dev/null +++ b/Octokit.Tests.Integration/Clients/NotificationsClientTests.cs @@ -0,0 +1,41 @@ +using System.Threading.Tasks; +using Octokit.Tests.Integration; +using Xunit; + +public class NotificationsClientTests +{ + public class TheMarkAsReadMethod + { + [IntegrationTest] + public async Task MarksNotificationsRead() + { + var github = Helper.GetAuthenticatedClient(); + + await github.Activity.Notifications.MarkAsRead(); + } + } + + public class TheMarkAsReadForRepositoryMethod + { + [IntegrationTest] + public async Task MarksNotificationsRead() + { + var owner = "octokit"; + var repo = "octokit.net"; + + var github = Helper.GetAuthenticatedClient(); + + await github.Activity.Notifications.MarkAsReadForRepository(owner, repo); + } + + [IntegrationTest] + public async Task MarksNotificationsReadForRepositoryId() + { + var repositoryId = 7528679; + + var github = Helper.GetAuthenticatedClient(); + + await github.Activity.Notifications.MarkAsReadForRepository(repositoryId); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 6aef864f..85acbc70 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -98,6 +98,7 @@ + @@ -157,6 +158,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableNotificationsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableNotificationsClientTests.cs new file mode 100644 index 00000000..e0e761fe --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableNotificationsClientTests.cs @@ -0,0 +1,43 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Octokit.Tests.Integration; +using Xunit; + +public class ObservableNotificationsClientTests +{ + public class TheMarkAsReadMethod + { + [IntegrationTest] + public async Task MarksNotificationsRead() + { + var client = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + await client.Activity.Notifications.MarkAsRead(); + } + } + + public class TheMarkAsReadForRepositoryMethod + { + [IntegrationTest] + public async Task MarksNotificationsRead() + { + var owner = "octokit"; + var repo = "octokit.net"; + + var client = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + await client.Activity.Notifications.MarkAsReadForRepository(owner, repo); + } + + [IntegrationTest] + public async Task MarksNotificationsReadForRepositoryId() + { + var repositoryId = 7528679; + + var client = new ObservableGitHubClient(Helper.GetAuthenticatedClient()); + + await client.Activity.Notifications.MarkAsReadForRepository(repositoryId); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/NotificationsClientTests.cs b/Octokit.Tests/Clients/NotificationsClientTests.cs index c7eacccf..64828b9d 100644 --- a/Octokit.Tests/Clients/NotificationsClientTests.cs +++ b/Octokit.Tests/Clients/NotificationsClientTests.cs @@ -284,7 +284,7 @@ namespace Octokit.Tests.Clients client.MarkAsRead(); - connection.Received().Put(endpoint); + connection.Received().Put(endpoint, Args.Object); } } @@ -299,7 +299,7 @@ namespace Octokit.Tests.Clients client.MarkAsReadForRepository("banana", "split"); - connection.Received().Put(endpoint); + connection.Received().Put(endpoint, Args.Object); } [Fact] @@ -311,7 +311,7 @@ namespace Octokit.Tests.Clients client.MarkAsReadForRepository(1); - connection.Received().Put(endpoint); + connection.Received().Put(endpoint, Args.Object); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableNotificationsClientTests.cs b/Octokit.Tests/Reactive/ObservableNotificationsClientTests.cs index 7e9f6480..cbcd97c6 100644 --- a/Octokit.Tests/Reactive/ObservableNotificationsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableNotificationsClientTests.cs @@ -302,7 +302,7 @@ namespace Octokit.Tests.Reactive client.MarkAsRead(); - connection.Received().Put(endpoint); + connection.Received().Put(endpoint, Args.Object); } } @@ -318,7 +318,7 @@ namespace Octokit.Tests.Reactive client.MarkAsReadForRepository("banana", "split"); - connection.Received().Put(endpoint); + connection.Received().Put(endpoint, Args.Object); } [Fact] @@ -331,7 +331,7 @@ namespace Octokit.Tests.Reactive client.MarkAsReadForRepository(1); - connection.Received().Put(endpoint); + connection.Received().Put(endpoint, Args.Object); } [Fact] diff --git a/Octokit/Clients/NotificationsClient.cs b/Octokit/Clients/NotificationsClient.cs index af77bd6a..9a2c8c06 100644 --- a/Octokit/Clients/NotificationsClient.cs +++ b/Octokit/Clients/NotificationsClient.cs @@ -187,7 +187,7 @@ namespace Octokit /// http://developer.github.com/v3/activity/notifications/#mark-as-read public Task MarkAsRead() { - return ApiConnection.Put(ApiUrls.Notifications()); + return ApiConnection.Put(ApiUrls.Notifications(), new object()); } /// @@ -213,7 +213,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.Put(ApiUrls.Notifications(owner, name)); + return ApiConnection.Put(ApiUrls.Notifications(owner, name), new object()); } /// @@ -223,7 +223,7 @@ namespace Octokit /// http://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository public Task MarkAsReadForRepository(long repositoryId) { - return ApiConnection.Put(ApiUrls.Notifications(repositoryId)); + return ApiConnection.Put(ApiUrls.Notifications(repositoryId), new object()); } ///