Exemplo n.º 1
0
            public void RequestsCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryForksClient(gitHubClient);

                client.GetAll("fake", "repo");

                gitHubClient.Received().Repository.Forks.GetAll("fake", "repo");
            }
Exemplo n.º 2
0
            public void RequestsCorrectUrlWithRequestParameters()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryForksClient(gitHubClient);

                var repositoryForksListRequest = new RepositoryForksListRequest {
                    Sort = Sort.Stargazers
                };

                client.GetAll("fake", "repo", repositoryForksListRequest);

                gitHubClient.Received().Repository.Forks.GetAll(
                    "fake", "repo", repositoryForksListRequest);
            }
Exemplo n.º 3
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryForksClient(gitHubClient);

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

                client.GetAll("fake", "repo", options);

                gitHubClient.Received().Repository.Forks.GetAll("fake", "repo", options);
            }
            public void RequestsCorrectUrlWithRepositoryIdWithRequestParametersWithApiOptions()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryForksClient(gitHubClient);

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

                var repositoryForksListRequest = new RepositoryForksListRequest {
                    Sort = Sort.Stargazers
                };

                client.GetAll(1, repositoryForksListRequest, options);

                gitHubClient.Received().Repository.Forks.GetAll(1, repositoryForksListRequest, options);
            }
Exemplo n.º 5
0
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableRepositoryForksClient(Substitute.For <IGitHubClient>());

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

                Assert.Throws <ArgumentException>(() => client.GetAll("", "name"));
                Assert.Throws <ArgumentException>(() => client.GetAll("owner", ""));
                Assert.Throws <ArgumentException>(() => client.GetAll("", "name", ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAll("", "name", new RepositoryForksListRequest()));
                Assert.Throws <ArgumentException>(() => client.GetAll("owner", "", new RepositoryForksListRequest()));
                Assert.Throws <ArgumentException>(() => client.GetAll("", "name", new RepositoryForksListRequest(), ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAll("owner", "", new RepositoryForksListRequest(), ApiOptions.None));
            }