コード例 #1
0
            public void RequestsCorrectUrl()
            {
                var endpoint = new Uri("notifications", UriKind.Relative);
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableNotificationsClient(gitHubClient);

                client.GetAllForCurrent();

                connection.Received().Get<List<Notification>>(endpoint, Args.EmptyDictionary, null);
            }
コード例 #2
0
        public ObservableGitHubClient(IGitHubClient gitHubClient)
        {
            Ensure.ArgumentNotNull(gitHubClient, "githubClient");

            _gitHubClient = gitHubClient;
            Authorization = new ObservableAuthorizationsClient(gitHubClient);
            Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous);
            Notification  = new ObservableNotificationsClient(gitHubClient);
            Organization  = new ObservableOrganizationsClient(gitHubClient);
            Repository    = new ObservableRepositoriesClient(gitHubClient);
            SshKey        = new ObservableSshKeysClient(gitHubClient);
            User          = new ObservableUsersClient(gitHubClient);
            Release       = new ObservableReleasesClient(gitHubClient);
        }
コード例 #3
0
            public void RequestsCorrectUrlNotificationRequest()
            {
                var endpoint = new Uri("notifications", UriKind.Relative);
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableNotificationsClient(gitHubClient);

                var notificationsRequest = new NotificationsRequest { All = true };

                client.GetAllForCurrent(notificationsRequest);

                connection.Received().Get<List<Notification>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2
                                                                                                                 && d["all"] == "true" && d["participating"] == "false"), null);
            }
コード例 #4
0
            public void RequestsCorrectUrlApiOptions()
            {
                var endpoint = new Uri("notifications", UriKind.Relative);
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableNotificationsClient(gitHubClient);

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

                client.GetAllForCurrent(options);

                connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(d => d.Count == 2), null);
            }
コード例 #5
0
        public ObservableGitHubClient(IGitHubClient gitHubClient)
        {
            Ensure.ArgumentNotNull(gitHubClient, "githubClient");

            _gitHubClient = gitHubClient;
            Authorization = new ObservableAuthorizationsClient(gitHubClient);
            Activity = new ObservableActivitiesClient(gitHubClient);
            Issue = new ObservableIssuesClient(gitHubClient);
            Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous);
            Notification = new ObservableNotificationsClient(gitHubClient);
            Organization = new ObservableOrganizationsClient(gitHubClient);
            Repository = new ObservableRepositoriesClient(gitHubClient);
            SshKey = new ObservableSshKeysClient(gitHubClient);
            User = new ObservableUsersClient(gitHubClient);
            Release = new ObservableReleasesClient(gitHubClient);
            GitDatabase = new ObservableGitDatabaseClient(gitHubClient);
            Gist = new ObservableGistsClient(gitHubClient);
            Search = new ObservableSearchClient(gitHubClient);
        }
コード例 #6
0
        public ObservableGitHubClient(IGitHubClient gitHubClient)
        {
            Ensure.ArgumentNotNull(gitHubClient, "githubClient");

            _gitHubClient = gitHubClient;
            Authorization = new ObservableAuthorizationsClient(gitHubClient);
            Activity      = new ObservableActivitiesClient(gitHubClient);
            Issue         = new ObservableIssuesClient(gitHubClient);
            Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous);
            Notification  = new ObservableNotificationsClient(gitHubClient);
            Organization  = new ObservableOrganizationsClient(gitHubClient);
            Repository    = new ObservableRepositoriesClient(gitHubClient);
            SshKey        = new ObservableSshKeysClient(gitHubClient);
            User          = new ObservableUsersClient(gitHubClient);
            Release       = new ObservableReleasesClient(gitHubClient);
            GitDatabase   = new ObservableGitDatabaseClient(gitHubClient);
            Gist          = new ObservableGistsClient(gitHubClient);
            Search        = new ObservableSearchClient(gitHubClient);
        }
コード例 #7
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new ObservableNotificationsClient(Substitute.For<IGitHubClient>());

                Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForCurrent((NotificationsRequest)null));
            }
コード例 #8
0
            public void RequestsCorrectUrl()
            {
                var endpoint = new Uri("notifications/threads/1/subscription", UriKind.Relative);
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableNotificationsClient(gitHubClient);

                client.DeleteThreadSubscription(1);

                connection.Received().Delete(endpoint);
            }
コード例 #9
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new ObservableNotificationsClient(Substitute.For<IGitHubClient>());

                Assert.Throws<ArgumentNullException>(() => client.SetThreadSubscription(1, null));
            }
コード例 #10
0
            public void RequestsCorrectUrl()
            {
                var endpoint = new Uri("notifications/threads/1", UriKind.Relative);
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableNotificationsClient(gitHubClient);

                client.MarkAsRead(1);

                connection.Received().Patch(endpoint);
            }
コード例 #11
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new ObservableNotificationsClient(Substitute.For<IGitHubClient>());

                Assert.Throws<ArgumentNullException>(() => client.MarkAsReadForRepository(null, "name"));
                Assert.Throws<ArgumentNullException>(() => client.MarkAsReadForRepository("owner", null));
                Assert.Throws<ArgumentNullException>(() => client.MarkAsReadForRepository(null, "name", new MarkAsReadRequest()));
                Assert.Throws<ArgumentNullException>(() => client.MarkAsReadForRepository("owner", null, new MarkAsReadRequest()));
                Assert.Throws<ArgumentNullException>(() => client.MarkAsReadForRepository("owner", "name", null));

                Assert.Throws<ArgumentNullException>(() => client.MarkAsReadForRepository(1, null));

                Assert.Throws<ArgumentException>(() => client.MarkAsReadForRepository("", "name"));
                Assert.Throws<ArgumentException>(() => client.MarkAsReadForRepository("owner", ""));
                Assert.Throws<ArgumentException>(() => client.MarkAsReadForRepository("", "name", new MarkAsReadRequest()));
                Assert.Throws<ArgumentException>(() => client.MarkAsReadForRepository("owner", "", new MarkAsReadRequest()));
            }
コード例 #12
0
            public void RequestsCorrectUrlParameterizedWithRepositoryId()
            {
                var endpoint = new Uri("repositories/1/notifications", UriKind.Relative);
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableNotificationsClient(gitHubClient);

                var markAsReadRequest = new MarkAsReadRequest();

                client.MarkAsReadForRepository(1, markAsReadRequest);

                connection.Received().Put<object>(endpoint, markAsReadRequest);
            }
コード例 #13
0
            public void RequestsCorrectUrl()
            {
                var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative);
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableNotificationsClient(gitHubClient);

                client.MarkAsReadForRepository("banana", "split");

                connection.Received().Put(endpoint);
            }
コード例 #14
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new ObservableNotificationsClient(Substitute.For<IGitHubClient>());

                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new NotificationsRequest()));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new NotificationsRequest()));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (NotificationsRequest)null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new NotificationsRequest(), ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new NotificationsRequest(), ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new NotificationsRequest(), null));

                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (NotificationsRequest)null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, new NotificationsRequest(), null));

                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name"));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", ""));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest()));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest()));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest(), ApiOptions.None));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest(), ApiOptions.None));
            }
コード例 #15
0
            public void RequestsCorrectUrlNotificationRequestWithApiOptionsWithRepositoryId()
            {
                var endpoint = new Uri("repositories/1/notifications", UriKind.Relative);
                var connection = Substitute.For<IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client = new ObservableNotificationsClient(gitHubClient);

                var notificationsRequest = new NotificationsRequest { All = true };

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

                client.GetAllForRepository(1, notificationsRequest, options);

                connection.Received().Get<List<Notification>>(endpoint, Arg.Is<Dictionary<string, string>>(
                    d => d.Count == 4 && d["all"] == "true" && d["participating"] == "false"
                         && d["page"] == "1" && d["per_page"] == "1"),
                    null);
            }