public ObservableRepositoriesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Repository;
            _connection = client.Connection;
            Status = new ObservableCommitStatusClient(client);
            Hooks = new ObservableRepositoryHooksClient(client);
            Forks = new ObservableRepositoryForksClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            RepoCollaborators = new ObservableRepoCollaboratorsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Collaborator = new ObservableRepoCollaboratorsClient(client);
            Deployment = new ObservableDeploymentsClient(client);
            Statistics = new ObservableStatisticsClient(client);
            PullRequest = new ObservablePullRequestsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            RepositoryComments = new ObservableRepositoryCommentsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Comment = new ObservableRepositoryCommentsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            Commits = new ObservableRepositoryCommitsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Commit = new ObservableRepositoryCommitsClient(client);
            Release = new ObservableReleasesClient(client);
            DeployKeys = new ObservableRepositoryDeployKeysClient(client);
            Content = new ObservableRepositoryContentsClient(client);
            Merging = new ObservableMergingClient(client);
            Page = new ObservableRepositoryPagesClient(client);
        }
        public ObservableRepositoriesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client     = client.Repository;
            _connection = client.Connection;
            Status      = new ObservableCommitStatusClient(client);
            Hooks       = new ObservableRepositoryHooksClient(client);
            Forks       = new ObservableRepositoryForksClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            RepoCollaborators = new ObservableRepoCollaboratorsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Collaborator = new ObservableRepoCollaboratorsClient(client);
            Deployment   = new ObservableDeploymentsClient(client);
            Statistics   = new ObservableStatisticsClient(client);
            PullRequest  = new ObservablePullRequestsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            RepositoryComments = new ObservableRepositoryCommentsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Comment = new ObservableRepositoryCommentsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            Commits = new ObservableRepositoryCommitsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Commit     = new ObservableRepositoryCommitsClient(client);
            Release    = new ObservableReleasesClient(client);
            DeployKeys = new ObservableRepositoryDeployKeysClient(client);
            Content    = new ObservableRepositoryContentsClient(client);
            Merging    = new ObservableMergingClient(client);
            Page       = new ObservableRepositoryPagesClient(client);
        }
            public async Task ReturnsDistinctResultsBasedOnStartPage()
            {
                var github = Helper.GetAuthenticatedClient();

                var client = new ObservableRepositoryHooksClient(github);

                var startOptions = new ApiOptions
                {
                    PageSize = 2,
                    PageCount = 1
                };

                var firstPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, startOptions).ToList();

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

                var secondPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, skipStartOptions).ToList();

                Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
                Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
            }
Пример #4
0
        public ObservableRepositoriesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, nameof(client));

            _client      = client.Repository;
            _connection  = client.Connection;
            Status       = new ObservableCommitStatusClient(client);
            Hooks        = new ObservableRepositoryHooksClient(client);
            Forks        = new ObservableRepositoryForksClient(client);
            Collaborator = new ObservableRepoCollaboratorsClient(client);
            Deployment   = new ObservableDeploymentsClient(client);
            Statistics   = new ObservableStatisticsClient(client);
            PullRequest  = new ObservablePullRequestsClient(client);
            Branch       = new ObservableRepositoryBranchesClient(client);
            Comment      = new ObservableRepositoryCommentsClient(client);
            Commit       = new ObservableRepositoryCommitsClient(client);
            Release      = new ObservableReleasesClient(client);
            DeployKeys   = new ObservableRepositoryDeployKeysClient(client);
            Content      = new ObservableRepositoryContentsClient(client);
            Merging      = new ObservableMergingClient(client);
            Page         = new ObservableRepositoryPagesClient(client);
            Invitation   = new ObservableRepositoryInvitationsClient(client);
            Traffic      = new ObservableRepositoryTrafficClient(client);
            Project      = new ObservableProjectsClient(client);
        }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryHooksClient(gitHubClient);

                client.GetAll(1);

                gitHubClient.Received().Repository.Hooks.GetAll(1);
            }
 public ObservableRepositoriesClient(IGitHubClient client)
 {
     Ensure.ArgumentNotNull(client, "client");
     
     _client = client.Repository;
     _connection = client.Connection;
     CommitStatus = new ObservableCommitStatusClient(client);
     Hooks = new ObservableRepositoryHooksClient(client);
     RepoCollaborators = new ObservableRepoCollaboratorsClient(client);
 }
                public void GetsCorrectUrl()
                {
                    var client = Substitute.For<IGitHubClient>();
                    var authEndpoint = new ObservableRepositoryHooksClient(client);
                    var expectedUrl = string.Format("repos/{0}/{1}/hooks", owner, repositoryName);

                    authEndpoint.GetAll(owner, repositoryName);

                    client.Connection.Received(1).Get<List<RepositoryHook>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                        Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null);
                }
            public async Task ReturnsAllHooksFromRepository()
            {
                var github = Helper.GetAuthenticatedClient();

                var client = new ObservableRepositoryHooksClient(github);

                var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName).ToList();

                Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count);

                var actualHook = hooks[0];
                AssertHook(_fixture.ExpectedHook, actualHook);
            }
            public void RequestsCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryHooksClient(gitHubClient);

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

                client.GetAll(1, options);

                gitHubClient.Received(1).Repository.Hooks.GetAll(1, options);
            }
            public async Task ReturnsCorrectCountOfHooksWithoutStart()
            {
                var github = Helper.GetAuthenticatedClient();

                var client = new ObservableRepositoryHooksClient(github);

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

                var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options).ToList();

                Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count);
            }
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableRepositoryHooksClient(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", null));

                Assert.Throws<ArgumentNullException>(() => client.GetAll(1, 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));
            }
                public void GetsCorrectUrlWithApiOption()
                {
                    var gitHubClient = Substitute.For<IGitHubClient>();
                    var hooksClient = new ObservableRepositoryHooksClient(gitHubClient);
                    var expectedUrl = string.Format("repos/{0}/{1}/hooks", owner, repositoryName);

                    // all properties are setted => only 2 options (StartPage, PageSize) in dictionary
                    var options = new ApiOptions
                    {
                        StartPage = 1,
                        PageCount = 1,
                        PageSize = 1
                    };

                    hooksClient.GetAll(owner, repositoryName, options);
                    gitHubClient.Connection.Received(1)
                        .Get<List<RepositoryHook>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                            Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 2),
                            null);

                    // StartPage is setted => only 1 option (StartPage) in dictionary
                    options = new ApiOptions
                    {
                        StartPage = 1
                    };

                    hooksClient.GetAll(owner, repositoryName, options);
                    gitHubClient.Connection.Received(1)
                        .Get<List<RepositoryHook>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                            Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 1),
                            null);

                    // PageCount is setted => none of options in dictionary
                    options = new ApiOptions
                    {
                        PageCount = 1
                    };

                    hooksClient.GetAll(owner, repositoryName, options);
                    gitHubClient.Connection.Received(1)
                        .Get<List<RepositoryHook>>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
                            Arg.Is<IDictionary<string, string>>(dictionary => dictionary.Count == 0),
                            null);
                }
        public ObservableRepositoriesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client            = client.Repository;
            _connection        = client.Connection;
            CommitStatus       = new ObservableCommitStatusClient(client);
            Hooks              = new ObservableRepositoryHooksClient(client);
            Forks              = new ObservableRepositoryForksClient(client);
            RepoCollaborators  = new ObservableRepoCollaboratorsClient(client);
            Deployment         = new ObservableDeploymentsClient(client);
            Statistics         = new ObservableStatisticsClient(client);
            PullRequest        = new ObservablePullRequestsClient(client);
            RepositoryComments = new ObservableRepositoryCommentsClient(client);
            Commits            = new ObservableRepositoryCommitsClient(client);
            DeployKeys         = new ObservableRepositoryDeployKeysClient(client);
            Content            = new ObservableRepositoryContentsClient(client);
            Merging            = new ObservableMergingClient(client);
        }
Пример #14
0
        public ObservableRepositoriesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Repository;
            _connection = client.Connection;
            CommitStatus = new ObservableCommitStatusClient(client);
            Hooks = new ObservableRepositoryHooksClient(client);
            Forks = new ObservableRepositoryForksClient(client);
            RepoCollaborators = new ObservableRepoCollaboratorsClient(client);
            Deployment = new ObservableDeploymentsClient(client);
            Statistics = new ObservableStatisticsClient(client);
            PullRequest = new ObservablePullRequestsClient(client);
            RepositoryComments = new ObservableRepositoryCommentsClient(client);
            Commits = new ObservableRepositoryCommitsClient(client);
            DeployKeys = new ObservableRepositoryDeployKeysClient(client);
            Content = new ObservableRepositoryContentsClient(client);
            Merging = new ObservableMergingClient(client);
        }
        public ObservableRepositoriesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Repository;
            _connection = client.Connection;
            Status = new ObservableCommitStatusClient(client);
            Hooks = new ObservableRepositoryHooksClient(client);
            Forks = new ObservableRepositoryForksClient(client);
            Collaborator = new ObservableRepoCollaboratorsClient(client);
            Deployment = new ObservableDeploymentsClient(client);
            Statistics = new ObservableStatisticsClient(client);
            PullRequest = new ObservablePullRequestsClient(client);
            Branch = new ObservableRepositoryBranchesClient(client);
            Comment = new ObservableRepositoryCommentsClient(client);
            Commit = new ObservableRepositoryCommitsClient(client);
            Release = new ObservableReleasesClient(client);
            DeployKeys = new ObservableRepositoryDeployKeysClient(client);
            Content = new ObservableRepositoryContentsClient(client);
            Merging = new ObservableMergingClient(client);
            Page = new ObservableRepositoryPagesClient(client);
            Invitation = new ObservableRepositoryInvitationsClient(client);
            Traffic = new ObservableRepositoryTrafficClient(client);
        }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryHooksClient(gitHubClient);

                var hook = new EditRepositoryHook();

                client.Edit(1, 12345678, hook);

                gitHubClient.Received().Repository.Hooks.Edit(1, 12345678, hook);
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryHooksClient(gitHubClient);

                var hook = new NewRepositoryHook("name", new Dictionary<string, string> { { "config", "" } });

                client.Create(1, hook);

                gitHubClient.Received().Repository.Hooks.Create(1, hook);
            }
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableRepositoryHooksClient(Substitute.For<IGitHubClient>());

                var config = new Dictionary<string, string> { { "config", "" } };

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

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

                Assert.Throws<ArgumentException>(() => client.Create("", "name", new NewRepositoryHook("name", config)));
                Assert.Throws<ArgumentException>(() => client.Create("owner", "", new NewRepositoryHook("name", config)));
            }
            public void RequestsCorrectUrl()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableRepositoryHooksClient(gitHubClient);

                client.Delete("fake", "repo", 12345678);

                gitHubClient.Received().Repository.Hooks.Delete("fake", "repo", 12345678);
            }
            public void EnsuresNonNullArguments()
            {
                var client = new ObservableRepositoryHooksClient(Substitute.For<IGitHubClient>());

                Assert.Throws<ArgumentNullException>(() => client.Delete(null, "name", 12345678));
                Assert.Throws<ArgumentNullException>(() => client.Delete("owner", null, 12345678));

                Assert.Throws<ArgumentException>(() => client.Delete("", "name", 12345678));
                Assert.Throws<ArgumentException>(() => client.Delete("owner", "", 12345678));
            }