예제 #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 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));
            }
            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());
            }
예제 #4
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);
            }
예제 #5
0
            public void RequestsCorrectUrl()
            {
                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.GetAllStargazers("fight", "club");

                connection.Received().Get <List <User> >(endpoint, Args.EmptyDictionary, null);
            }
예제 #6
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                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.GetAllStargazers("fight", "club", options);

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