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));
            }
Esempio n. 2
0
            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));
            }
Esempio n. 3
0
            public void EnsureNonNullArguments()
            {
                var client = new RepositoryCommitsClient(Substitute.For <IApiConnection>());

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

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

                Assert.Throws <ArgumentNullException>(() => client.GetAll("owner", "repo", null));
            }
Esempio n. 4
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));
            }
Esempio n. 5
0
            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 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);
            }
Esempio n. 7
0
            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);
            }
Esempio n. 8
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryCommitsClient(connection);

                await client.GetAll(1);

                connection.Received().GetAll <GitHubCommit>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits"), Args.EmptyDictionary, Args.ApiOptions);
            }
Esempio n. 9
0
            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);
            }
Esempio n. 10
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> >());
            }
Esempio n. 11
0
            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryCommitsClient(connection);

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

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

                connection.Received().GetAll <GitHubCommit>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/commits"), Args.EmptyDictionary, options);
            }
Esempio n. 12
0
            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 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 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 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 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);
            }
Esempio n. 18
0
            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));
            }
Esempio n. 19
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 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);
            }