示例#1
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));
            }
示例#2
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");
            }
示例#3
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");
            }