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 void CallsIntoClient()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(githubClient);

                deployKeysClient.Get("user", "repo", 42);

                githubClient.Repository.DeployKeys.Received(1).Get("user", "repo", 42);
            }
            public void EnsuresNonNullArguments()
            {
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(Substitute.For<IGitHubClient>());

                Assert.Throws<ArgumentNullException>(() => deployKeysClient.GetAll(null, "repo"));
                Assert.Throws<ArgumentException>(() => deployKeysClient.GetAll("", "repo"));
                Assert.Throws<ArgumentNullException>(() => deployKeysClient.GetAll("user", null));
                Assert.Throws<ArgumentException>(() => deployKeysClient.GetAll("user", ""));
            }
            public void RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(gitHubClient);

                deployKeysClient.Get(1, 42);

                gitHubClient.Repository.DeployKeys.Received(1).Get(1, 42);
            }
            public void RequestsCorrectUrl()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(gitHubClient);

                deployKeysClient.GetAll("user", "repo");

                gitHubClient.Connection.Received(1).Get<List<DeployKey>>(
                    new Uri("repos/user/repo/keys", UriKind.Relative), Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 0), null);
            }
    public ObservableRespositoryDeployKeysClientTests()
    {
        var github = Helper.GetAuthenticatedClient();

        _client = new ObservableRepositoryDeployKeysClient(github);
        var repoName = Helper.MakeNameWithTimestamp("public-repo");
        var result = github.Repository.Create(new NewRepository(repoName) { AutoInit = true }).Result;
        _repository = result;
        _owner = _repository.Owner.Login;
    }
            public void CallsIntoClient()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(githubClient);
                var data = new NewDeployKey { Key = "ABC123", Title = "user@repo" };

                deployKeysClient.Create("user", "repo", data);

                githubClient.Repository.DeployKeys.Received(1).Create("user", "repo", data);
            }
            public void CallsIntoClient()
            {
                var githubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(githubClient);

                deployKeysClient.GetAll("user", "repo");

                githubClient.Connection.Received(1).Get<List<DeployKey>>(
                    new Uri("repos/user/repo/keys", UriKind.Relative), null, null);
            }
    public ObservableRespositoryDeployKeysClientTests()
    {
        var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
        {
            Credentials = Helper.Credentials
        };

        _client = new ObservableRepositoryDeployKeysClient(github);
        var repoName = Helper.MakeNameWithTimestamp("public-repo");
        var result = github.Repository.Create(new NewRepository() { Name = repoName, AutoInit = true }).Result;
        _repository = result;
        _owner = _repository.Owner.Login;
    }
 public ObservableRepositoriesClient(IGitHubClient client)
 {
     Ensure.ArgumentNotNull(client, "client");
     
     _client = client.Repository;
     _connection = client.Connection;
     CommitStatus = new ObservableCommitStatusClient(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);
 }
        public ObservableRepositoriesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client            = client.Repository;
            _connection        = client.Connection;
            CommitStatus       = new ObservableCommitStatusClient(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);
        }
            public void RequestsCorrectUrlWithApiOptions()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(gitHubClient);
                var expectedUrl = string.Format("repos/{0}/{1}/keys", "user", "repo");

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

                deployKeysClient.GetAll("user", "repo", options);
                gitHubClient.Connection.Received(1)
                    .Get<List<DeployKey>>(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
                };

                deployKeysClient.GetAll("user", "repo", options);
                gitHubClient.Connection.Received(1)
                    .Get<List<DeployKey>>(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
                };

                deployKeysClient.GetAll("user", "repo", options);
                gitHubClient.Connection.Received(1)
                    .Get<List<DeployKey>>(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;
            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);
            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);
        }
        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);
            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);
        }
            public void CreatesCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(gitHubClient);
                var data = new NewDeployKey { Key = "ABC123", Title = "user@repo" };

                deployKeysClient.Create(1, data);

                gitHubClient.Repository.DeployKeys.Received(1).Create(1, data);
            }
            public void CreatesCorrectUrl()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(gitHubClient);

                deployKeysClient.Delete("user", "repo", 42);

                gitHubClient.Repository.DeployKeys.Received(1).Delete("user", "repo", 42);
            }
            public void EnsuresNonNullArguments()
            {
                var deployKeysClient = new ObservableRepositoryDeployKeysClient(Substitute.For<IGitHubClient>());

                Assert.Throws<ArgumentNullException>(() => deployKeysClient.Create(null, "repo", new NewDeployKey()));
                Assert.Throws<ArgumentNullException>(() => deployKeysClient.Create("user", null, new NewDeployKey()));
                Assert.Throws<ArgumentNullException>(() => deployKeysClient.Create("user", "repo", null));

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

                Assert.Throws<ArgumentException>(() => deployKeysClient.Create("", "repo", new NewDeployKey()));
                Assert.Throws<ArgumentException>(() => deployKeysClient.Create("user", "", new NewDeployKey()));

                Assert.Throws<ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey()));
                Assert.Throws<ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey { Key = "ABC123" }));
                Assert.Throws<ArgumentException>(() => deployKeysClient.Create("user", "repo", new NewDeployKey { Title = "user@repo" }));
            }