public void GetsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                client.GetAll("fake", "repo", new CommitRequest(), new ApiOptions());
                connection.Received().GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits"), Args.EmptyDictionary, Args.ApiOptions);
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                await client.Get(1, "reference");

                connection.Received().Get<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/reference"));
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                await client.Compare(1, "base", "head");

                connection.Received().Get<CompareResult>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/compare/base...head"));
            }
            public void EnsuresNonEmptyArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);
                var options = new ApiOptions();
                var request = new CommitRequest();

                Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", request, options));
                Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", request, options));
            }
예제 #5
0
            public async Task EnsureNonNullArguments()
            {
                var client = new RepositoryCommitsClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll(null, "repo"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "repo"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("owner", ""));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAll("owner", "repo", null, ApiOptions.None));
            }
예제 #6
0
            public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryCommitsClient(connection);

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

                await client.GetAll(1, options);

                connection.Received().GetAll <GitHubCommit>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits"), Args.EmptyDictionary, options);
            }
예제 #7
0
            public void EnsureNonNullArguments()
            {
                var client = new RepositoryCommitsClient(Substitute.For <IApiConnection>());

                Assert.Throws <ArgumentNullException>(() => client.Compare(null, "repo", "base", "head"));
                Assert.Throws <ArgumentException>(() => client.Compare("", "repo", "base", "head"));

                Assert.Throws <ArgumentNullException>(() => client.Compare("owner", null, "base", "head"));
                Assert.Throws <ArgumentException>(() => client.Compare("owner", "", "base", "head"));

                Assert.Throws <ArgumentNullException>(() => client.Compare("owner", "repo", null, "head"));
                Assert.Throws <ArgumentException>(() => client.Compare("owner", "repo", "", "head"));

                Assert.Throws <ArgumentNullException>(() => client.Compare("owner", "repo", "base", null));
                Assert.Throws <ArgumentException>(() => client.Compare("owner", "repo", "base", ""));
            }
예제 #8
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", "reference"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, "reference"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", "name", null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(1, null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", "reference"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", "reference"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "name", ""));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Get(1, ""));
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Compare(null, "name", "base", "head"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Compare("owner", null, "base", "head"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Compare("owner", "name", null, "head"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Compare("owner", "name", "base", null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Compare(1, null, "head"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.Compare(1, "base", null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.Compare("", "name", "base", "head"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Compare("owner", "", "base", "head"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Compare("owner", "name", "", "head"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Compare("owner", "name", "base", ""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Compare(1, "", "head"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.Compare(1, "base", ""));
            }
예제 #10
0
            public async Task RequestsCorrectUrlWithRepositoryIdParameterized()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryCommitsClient(connection);

                var commitRequest = new CommitRequest
                {
                    Author = "author",
                    Sha    = "sha",
                    Path   = "path",
                    Since  = null,
                    Until  = null
                };

                await client.GetAll(1, commitRequest);

                connection.Received().GetAll <GitHubCommit>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits"),
                                                            Arg.Is <IDictionary <string, string> >(d => d["author"] == "author" && d["sha"] == "sha" &&
                                                                                                   d["path"] == "path" && !d.ContainsKey("since") && !d.ContainsKey("until")), Args.ApiOptions);
            }
            public void EnsuresNonNullArguments()
            {
                var client = new RepositoryCommitsClient(Substitute.For<IApiConnection>());

                Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("", "name", "reference"));
                Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("owner", "", "reference"));
                Assert.ThrowsAsync<ArgumentException>(() => client.GetSha1("owner", "name", ""));
            }
            public void RequestsTheCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                client.GetAll("owner", "name");

                connection.Received()
                    .GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits"), Args.EmptyDictionary, Args.ApiOptions);
            }
            public async Task EnsureNonNullArguments()
            {
                var client = new RepositoryCommitsClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "repo"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "repo"));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "repo", null, ApiOptions.None));
            }
            public void RequestsTheCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                client.Get("owner", "name", "reference");

                connection.Received()
                    .Get<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits/reference"));
            }
            public void EncodesUrl()
            {
                var connection = Substitute.For<IApiConnection>();

                var client = new RepositoryCommitsClient(connection);

                client.Compare("owner", "repo", "base", "shiftkey/my-cool-branch");

                connection.Received()
                    .Get<CompareResult>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/compare/base...shiftkey%2Fmy-cool-branch"));
            }
            public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptionsParameterized()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                var commitRequest = new CommitRequest
                {
                    Author = "author",
                    Sha = "sha",
                    Path = "path",
                    Since = null,
                    Until = null
                };

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

                await client.GetAll(1, commitRequest, options);

                connection.Received().GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits"), Arg.Is<IDictionary<string, string>>(d => d["author"] == "author" && d["sha"] == "sha"
                    && d["path"] == "path" && !d.ContainsKey("since") && !d.ContainsKey("until")), options);
            }
            public async Task RequestsCorrectUrlParameterized()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                var commitRequest = new CommitRequest
                {
                    Author = "author",
                    Sha = "sha",
                    Path = "path",
                    Since = null,
                    Until = null
                };

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

                connection.Received().GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits"),
                    Arg.Is<IDictionary<string, string>>(d => d["author"] == "author" && d["sha"] == "sha"
                        && d["path"] == "path" && !d.ContainsKey("since") && !d.ContainsKey("until")), Args.ApiOptions);
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", (ApiOptions)null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", new CommitRequest()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, new CommitRequest()));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", (CommitRequest)null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", new CommitRequest(), ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, new CommitRequest(), ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", null, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", new CommitRequest(), null));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(1, (ApiOptions)null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(1, (CommitRequest)null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(1, null, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(1, new CommitRequest(), null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", new CommitRequest()));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", new CommitRequest()));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", new CommitRequest(), ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", new CommitRequest(), ApiOptions.None));
            }
            public async Task EnsuresNonEmptyArguments()
            {
                var client = new RepositoryCommitsClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSha1(null, "name", "reference"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSha1("owner", null, "reference"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetSha1("owner", "name", null));
            }
예제 #20
0
            public void GetsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                client.GetAll("owner", "name");

                connection.Received()
                    .GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits"),
                    Arg.Any<Dictionary<string, string>>());
            }
            public void RequestsTheCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                client.GetSha1("owner", "name", "reference");

                connection.Received()
                    .Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits/reference"), null, AcceptHeaders.CommitReferenceSha1Preview);
            }
            public void RequestsTheCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();

                var client = new RepositoryCommitsClient(connection);

                client.Compare("owner", "repo", "base", "head");

                connection.Received()
                    .Get<CompareResult>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/compare/base...head"));
            }
            public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

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

                await client.GetAll(1, options);

                connection.Received().GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits"), Args.EmptyDictionary, options);
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryCommitsClient(connection);

                await client.GetSha1(1, "ref");

                connection.Received().Get<string>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref"),
                    null, "application/vnd.github.chitauri-preview+sha");
            }