示例#1
0
            public void RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions()
            {
                var endpoint     = new Uri("users/banana/starred", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

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

                var starredRequest = new StarredRequest {
                    SortDirection = SortDirection.Ascending
                };

                client.GetAllForUserWithTimestamps("banana", starredRequest, options);

                connection.Received().Get <List <RepositoryStar> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 4 && d["direction"] == "asc" && d["direction"] == "asc" && d["per_page"] == "1" && d["page"] == "1"),
                                                                   "application/vnd.github.v3.star+json");
            }
示例#2
0
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableStarredClient(Substitute.For <IGitHubClient>());

                Assert.Throws <ArgumentNullException>(() => client.GetAllForUser(null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUser(null, ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUser("banana", (ApiOptions)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUser(null, new StarredRequest()));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUser("banana", (StarredRequest)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUser(null, new StarredRequest(), ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUser("banana", null, ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUser("banana", new StarredRequest(), null));

                Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", (ApiOptions)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, new StarredRequest()));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", (StarredRequest)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps(null, new StarredRequest(), ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", null, ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForUserWithTimestamps("banana", new StarredRequest(), null));

                Assert.Throws <ArgumentException>(() => client.GetAllForUser(""));
                Assert.Throws <ArgumentException>(() => client.GetAllForUser("", ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllForUser("", new StarredRequest(), ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllForUserWithTimestamps(""));
                Assert.Throws <ArgumentException>(() => client.GetAllForUserWithTimestamps("", ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllForUserWithTimestamps("", new StarredRequest(), ApiOptions.None));
            }
示例#3
0
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableStarredClient(Substitute.For <IGitHubClient>());

                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazers(null, "club"));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazers("fight", null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazers(null, "club", ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazers("fight", null, ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazers("fight", "club", null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazersWithTimestamps(null, "club"));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazersWithTimestamps("fight", null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazersWithTimestamps(null, "club", ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazersWithTimestamps("fight", null, ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAllStargazersWithTimestamps("fight", "club", null));

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

                Assert.Throws <ArgumentException>(() => client.GetAllStargazers("", "club"));
                Assert.Throws <ArgumentException>(() => client.GetAllStargazers("fight", ""));
                Assert.Throws <ArgumentException>(() => client.GetAllStargazers("", "club", ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllStargazers("fight", "", ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllStargazersWithTimestamps("", "club"));
                Assert.Throws <ArgumentException>(() => client.GetAllStargazersWithTimestamps("fight", ""));
                Assert.Throws <ArgumentException>(() => client.GetAllStargazersWithTimestamps("", "club", ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllStargazersWithTimestamps("fight", "", ApiOptions.None));
            }
        public ObservableActivitiesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            Events = new ObservableEventsClient(client);
            Watched = new ObservableWatchedClient(client);
            Starred = new ObservableStarredClient(client);
        }
        public ObservableActivitiesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            Events   = new ObservableEventsClient(client);
            Watching = new ObservableWatchedClient(client);
            Starring = new ObservableStarredClient(client);
        }
示例#6
0
            public async Task ChecksStarredForUser()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableStarredClient(gitHubClient);

                client.CheckStarred("jugglingnutcase", "katiejamie");
                gitHubClient.Activity.Starring.Received().CheckStarred("jugglingnutcase", "katiejamie");
            }
            public async Task EnsuresArguments()
            {
                var client = new ObservableStarredClient(Substitute.For <IGitHubClient>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllStargazers(null, "name").ToTask());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllStargazers("owner", null).ToTask());
            }
示例#8
0
            public async Task EnsuresArguments()
            {
                var client = new ObservableStarredClient(Substitute.For <IGitHubClient>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.RemoveStarFromRepo(null, "james").ToTask());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.RemoveStarFromRepo("james", null).ToTask());
            }
示例#9
0
            public async Task EnsuresArguments()
            {
                var client = new ObservableStarredClient(Substitute.For <IGitHubClient>());

                await AssertEx.Throws <ArgumentException>(async() => await client.GetAllStargazers(null, "name"));

                await AssertEx.Throws <ArgumentException>(async() => await client.GetAllStargazers("owner", null));
            }
示例#10
0
            public async Task EnsuresArguments()
            {
                var client = new ObservableStarredClient(Substitute.For <IGitHubClient>());

                await AssertEx.Throws <ArgumentException>(async() => await client.CheckStarred(null, "james"));

                await AssertEx.Throws <ArgumentException>(async() => await client.CheckStarred("james", null));
            }
示例#11
0
            public void ChecksStarredForUser()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableStarredClient(gitHubClient);

                client.RemoveStarFromRepo("jugglingnutcase", "katiejamie");
                gitHubClient.Activity.Starring.Received().RemoveStarFromRepo("jugglingnutcase", "katiejamie");
            }
        public ObservableActivitiesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            Events = new ObservableEventsClient(client);
            Watching = new ObservableWatchedClient(client);
            Starring = new ObservableStarredClient(client);
            Feeds = new ObservableFeedsClient(client);
            Notifications = new ObservableNotificationsClient(client);
        }
        public ObservableActivitiesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, nameof(client));

            Events        = new ObservableEventsClient(client);
            Watching      = new ObservableWatchedClient(client);
            Starring      = new ObservableStarredClient(client);
            Feeds         = new ObservableFeedsClient(client);
            Notifications = new ObservableNotificationsClient(client);
        }
示例#14
0
            public void GetsStarsForUser()
            {
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

                client.GetAllForUser("jugglingnutcase");
                connection.Received().GetAsync <List <Repository> >(ApiUrls.StarredByUser("jugglingnutcase"), null, null);
            }
示例#15
0
            public void GetsStargazersFromClient()
            {
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

                client.GetAllStargazers("jugglingnutcase", "katiejamie");
                connection.Received().GetAsync <List <User> >(ApiUrls.Stargazers("jugglingnutcase", "katiejamie"), null, null);
            }
示例#16
0
            public void RequestsCorrectUrl()
            {
                var endpoint     = new Uri("users/banana/starred", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

                client.GetAllForUser("banana");

                connection.Received().Get <List <Repository> >(endpoint, Args.EmptyDictionary, null);
            }
示例#17
0
            public void RequestsCorrectUrlWithTimestamps()
            {
                var endpoint     = new Uri("user/starred", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

                client.GetAllForCurrentWithTimestamps();

                connection.Received().Get <List <RepositoryStar> >(endpoint, Args.EmptyDictionary, "application/vnd.github.v3.star+json");
            }
示例#18
0
            public void RequestsCorrectUrlWithTimestamps()
            {
                var endpoint     = new Uri("repos/fight/club/stargazers", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

                client.GetAllStargazersWithTimestamps("fight", "club");

                connection.Received().Get <List <UserStar> >(endpoint, Args.EmptyDictionary, "application/vnd.github.v3.star+json");
            }
示例#19
0
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var endpoint     = new Uri("repositories/1/stargazers", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

                client.GetAllStargazers(1);

                connection.Received().Get <List <User> >(endpoint, Args.EmptyDictionary, null);
            }
示例#20
0
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableStarredClient(Substitute.For <IGitHubClient>());

                Assert.Throws <ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForCurrent((StarredRequest)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps((ApiOptions)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps((StarredRequest)null));

                Assert.Throws <ArgumentNullException>(() => client.GetAllForCurrent(null, new ApiOptions()));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForCurrent(new StarredRequest(), null));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps(null, new ApiOptions()));
                Assert.Throws <ArgumentNullException>(() => client.GetAllForCurrentWithTimestamps(new StarredRequest(), null));
            }
示例#21
0
            public void RequestsCorrectUrlParametrized()
            {
                var endpoint     = new Uri("users/banana/starred", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

                var starredRequest = new StarredRequest {
                    SortDirection = SortDirection.Ascending
                };

                client.GetAllForUser("banana", starredRequest);

                connection.Received().Get <List <Repository> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["direction"] == "asc"), null);
            }
示例#22
0
            public void RequestsCorrectUrlWithTimestampsParametrized()
            {
                var endpoint     = new Uri("user/starred", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

                var request = new StarredRequest {
                    SortDirection = SortDirection.Ascending
                };

                client.GetAllForCurrentWithTimestamps(request);

                connection.Received().Get <List <RepositoryStar> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["direction"] == "asc"),
                                                                   "application/vnd.github.v3.star+json");
            }
示例#23
0
            public void RequestsCorrectUrlWithTimestampsWithApiOptions()
            {
                var endpoint     = new Uri("repos/fight/club/stargazers", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

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

                client.GetAllStargazersWithTimestamps("fight", "club", options);

                connection.Received().Get <List <UserStar> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2), "application/vnd.github.v3.star+json");
            }
示例#24
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                var endpoint     = new Uri("user/starred", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

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

                client.GetAllForCurrent(options);

                connection.Received().Get <List <Repository> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["per_page"] == "1" && d["page"] == "1"), null);
            }
示例#25
0
            public void RequestsCorrectUrlWithApiOptionsWithRepositoryId()
            {
                var endpoint     = new Uri("repositories/1/stargazers", UriKind.Relative);
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = Substitute.For <IGitHubClient>();

                gitHubClient.Connection.Returns(connection);
                var client = new ObservableStarredClient(gitHubClient);

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

                client.GetAllStargazers(1, options);

                connection.Received().Get <List <User> >(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2), null);
            }