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("owner", "name", (RepositoryForksListRequest)null));
                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", null, ApiOptions.None));
                Assert.Throws <ArgumentNullException>(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null));

                Assert.Throws <ArgumentNullException>(() => client.GetAll(1, (ApiOptions)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAll(1, (RepositoryForksListRequest)null));
                Assert.Throws <ArgumentNullException>(() => client.GetAll(1, 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));
            }
Exemple #2
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");
            }
Exemple #3
0
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableRepositoryForksClient(Substitute.For <IGitHubClient>());

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

                Assert.Throws <ArgumentException>(() => client.Create("", "name", new NewRepositoryFork()));
                Assert.Throws <ArgumentException>(() => client.Create("owner", "", new NewRepositoryFork()));
            }
Exemple #4
0
            public void RequestsCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableRepositoryForksClient(gitHubClient);

                var newRepositoryFork = new NewRepositoryFork();

                client.Create("fake", "repo", newRepositoryFork);

                gitHubClient.Received().Repository.Forks.Create("fake", "repo", newRepositoryFork);
            }
Exemple #5
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);
            }
Exemple #6
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);
            }