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

            client.GetAllForCommit("fake", "repo", "sha");

            connection.Received().GetAll <CommitComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"));
        }
Esempio n. 2
0
        public async Task RequestsCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new RepositoryCommentsClient(connection);

            await client.GetAllForCommit(1, "sha");

            connection.Received().GetAll <CommitComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"),
                                                         Args.ApiOptions);
        }
        public async Task RequestsCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new RepositoryCommentsClient(connection);

            await client.GetAllForCommit(1, "sha");

            connection.Received().GetAll <CommitComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"),
                                                         Arg.Any <Dictionary <string, string> >(),
                                                         "application/vnd.github.squirrel-girl-preview+json",
                                                         Args.ApiOptions);
        }
Esempio n. 4
0
        public async Task RequestsCorrectUrlWithApiOptions()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new RepositoryCommentsClient(connection);

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

            await client.GetAllForCommit("fake", "repo", "sha", options);

            connection.Received().GetAll <CommitComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), options);
        }
        public async Task RequestsCorrectUrlWithApiOptions()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new RepositoryCommentsClient(connection);

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

            await client.GetAllForCommit("fake", "repo", "sha", options);

            connection.Received().GetAll <CommitComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any <Dictionary <string, string> >(),
                                                         "application/vnd.github.squirrel-girl-preview+json", options);
        }
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new RepositoryCommentsClient(connection);

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

            await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForCommit("", "name", "sha"));

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

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

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

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