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

            client.GetAllForRepository("fakeOwner", "fakeRepoName");

            connection.Received().GetAll<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepoName/pulls/comments"),
                Arg.Is<Dictionary<string, string>>(d => d.Count == 2
                        && d["direction"] == "asc"
                        && d["sort"] == "created"));
        }
        public async Task EnsuresArgumentsNotNull()
        {
            var client = new PullRequestReviewCommentsClient(Substitute.For<IApiConnection>());

            var request = new PullRequestReviewCommentRequest();

            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request));
            await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request));
            await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null));
        }
        public void RequestsCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new PullRequestReviewCommentsClient(connection);

            var request = new PullRequestReviewCommentRequest
            {
                Direction = SortDirection.Descending,
                Since = new DateTimeOffset(2013, 11, 15, 11, 43, 01, 00, new TimeSpan()),
                Sort = PullRequestReviewCommentSort.Updated,
            };

            client.GetAllForRepository("fakeOwner", "fakeRepoName", request);

            connection.Received().GetAll<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepoName/pulls/comments"),
                Arg.Is<Dictionary<string, string>>(d => d.Count == 3
                        && d["direction"] == "desc"
                        && d["since"] == "2013-11-15T11:43:01Z"
                        && d["sort"] == "updated"));
        }
        public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsWithApiOptions()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new PullRequestReviewCommentsClient(connection);

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

            await client.GetAllForRepository("fakeOwner", "fakeRepoName", options);

            connection.Received().GetAll<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepoName/pulls/comments"),
                Arg.Is<Dictionary<string, string>>(d => d.Count == 2
                        && d["direction"] == "asc"
                        && d["sort"] == "created"), options);
        }
        public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsWithApiOptionsWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new PullRequestReviewCommentsClient(connection);

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

            await client.GetAllForRepository(1, options);

            connection.Received().GetAll<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/comments"),
                Arg.Is<Dictionary<string, string>>(d => d.Count == 2
                        && d["direction"] == "asc"
                        && d["sort"] == "created"),
                "application/vnd.github.squirrel-girl-preview", options);
        }
        public async Task RequestsCorrectUrlWithoutSelectedSortingArguments()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new PullRequestReviewCommentsClient(connection);

            await client.GetAllForRepository("owner", "name");

            connection.Received().GetAll<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/pulls/comments"),
                Arg.Is<Dictionary<string, string>>(d => d.Count == 2
                        && d["direction"] == "asc"
                        && d["sort"] == "created"),
                "application/vnd.github.squirrel-girl-preview",
                Args.ApiOptions);
        }
        public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new PullRequestReviewCommentsClient(connection);

            var request = new PullRequestReviewCommentRequest
            {
                Direction = SortDirection.Descending,
                Since = new DateTimeOffset(2013, 11, 15, 11, 43, 01, 00, new TimeSpan()),
                Sort = PullRequestReviewCommentSort.Updated
            };

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

            await client.GetAllForRepository(1, request, options);

            connection.Received().GetAll<PullRequestReviewComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/pulls/comments"),
                Arg.Is<Dictionary<string, string>>(d => d.Count == 3
                        && d["direction"] == "desc"
                        && d["since"] == "2013-11-15T11:43:01Z"
                        && d["sort"] == "updated"),
                "application/vnd.github.squirrel-girl-preview", options);
        }