public async Task EnsuresNonNullArguments()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewsClient(connection);

            string body     = "Comment content";
            string path     = "file.css";
            int    position = 7;

            var comment = new DraftPullRequestReviewComment(body, path, position);

            var review = new PullRequestReviewCreate()
            {
                CommitId = "commit",
                Body     = "body",
                Event    = PullRequestReviewEvent.Approve
            };

            review.Comments.Add(comment);

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "fakeRepoName", 1, review));

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("fakeOwner", null, 1, review));

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("fakeOwner", "fakeRepoName", 1, null));

            await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", "fakeRepoName", 1, review));

            await Assert.ThrowsAsync <ArgumentException>(() => client.Create("fakeOwner", "", 1, review));
        }
            public void PostsToCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservablePullRequestReviewsClient(gitHubClient);

                var comment = new DraftPullRequestReviewComment("Comment content", "file.css", 7);
                var review  = new PullRequestReviewCreate()
                {
                    CommitId = "commit",
                    Body     = "body",
                    Event    = PullRequestReviewEvent.Approve
                };

                review.Comments.Add(comment);

                client.Create(1, 13, review);

                gitHubClient.Received().PullRequest.Review.Create(1, 53, review);
            }
        public void PostsToCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewsClient(connection);

            var comment = new DraftPullRequestReviewComment("Comment content", "file.css", 7);

            var review = new PullRequestReviewCreate()
            {
                CommitId = "commit",
                Body     = "body",
                Event    = PullRequestReviewEvent.Approve
            };

            review.Comments.Add(comment);

            client.Create(1, 13, review);

            connection.Received().Post <PullRequestReview>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls/13/reviews"),
                                                           review, null, null);
        }
        public void PullRequestReviewCreateEnsuresArgumentsValue()
        {
            string body = "body";
            string path = "path";
            PullRequestReviewEvent evt = PullRequestReviewEvent.Approve;
            int position = 1;

            var comment = new DraftPullRequestReviewComment(body, path, position);

            var review = new PullRequestReviewCreate()
            {
                Body  = body,
                Event = evt
            };

            review.Comments.Add(comment);


            Assert.Equal(body, review.Body);
            Assert.Equal(evt, review.Event);
            Assert.NotEmpty(review.Comments);
        }