Esempio n. 1
0
        public async Task RequestsCorrectUrl()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

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

            connection.Received().GetAll <PullRequestReviewComment>(
                Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/pulls/7/comments"),
                Arg.Any <Dictionary <string, string> >(),
                "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
        }
Esempio n. 2
0
        public void PostsToCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            var comment = new PullRequestReviewCommentReplyCreate("Comment content", 5);

            client.CreateReply(1, 13, comment);

            connection.Connection.Received().Post <PullRequestReviewComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls/13/comments"),
                                                                             comment, null, null);
        }
Esempio n. 3
0
        public void PostsToCorrectUrl()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

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

            client.Create("fakeOwner", "fakeRepoName", 13, comment);

            connection.Connection.Received().Post <PullRequestReviewComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepoName/pulls/13/comments"),
                                                                             comment, null, null);
        }
Esempio n. 4
0
        public async Task EnsuresNonNullArguments()
        {
            var client = new PullRequestReviewCommentsClient(Substitute.For <IApiConnection>());

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

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

            await Assert.ThrowsAsync <ArgumentException>(() => client.GetComment("", "name", 1));

            await Assert.ThrowsAsync <ArgumentException>(() => client.GetComment("owner", "", 1));
        }
Esempio n. 5
0
        public void RequestsCorrectUrl()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            client.GetComment("owner", "name", 53);

            connection.Received().Get <PullRequestReviewComment>(
                Arg.Is <Uri>(u => u.ToString() == "repos/owner/name/pulls/comments/53"),
                Arg.Any <Dictionary <string, string> >(),
                "application/vnd.github.squirrel-girl-preview+json");
        }
        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"));
        }
Esempio n. 7
0
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            await AssertEx.Throws <ArgumentNullException>(async() => await client.GetAll(null, "name", 1));

            await AssertEx.Throws <ArgumentException>(async() => await client.GetAll("", "name", 1));

            await AssertEx.Throws <ArgumentNullException>(async() => await client.GetAll("owner", null, 1));

            await AssertEx.Throws <ArgumentException>(async() => await client.GetAll("owner", "", 1));
        }
Esempio n. 8
0
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

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

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

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

            await Assert.ThrowsAsync <ArgumentException>(() => client.Delete("fakeOwner", "", 1));
        }
        public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsWithRepositoryId()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            await client.GetAllForRepository(1);

            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", Args.ApiOptions);
        }
Esempio n. 10
0
        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 async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

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

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

            connection.Received().GetAll <PullRequestReviewComment>(
                Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls/7/comments"), options);
        }
Esempio n. 12
0
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            var body = "New comment content";

            var comment = new PullRequestReviewCommentEdit(body);

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

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

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

            await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("fakeOwner", "", 1, comment));

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit("fakeOwner", null, 1, null));
        }
        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);
        }
Esempio n. 14
0
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            string body      = "Comment content";
            int    inReplyTo = 7;

            var comment = new PullRequestReviewCommentReplyCreate(body, inReplyTo);

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

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

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

            await Assert.ThrowsAsync <ArgumentException>(() => client.CreateReply("fakeOwner", "", 1, comment));

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.CreateReply("fakeOwner", "fakeRepoName", 1, null));
        }
Esempio n. 15
0
        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 RequestsCorrectUrlWithRepositoryId()
        {
            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
            };

            await client.GetAllForRepository(1, request);

            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", Args.ApiOptions);
        }
Esempio n. 17
0
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

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

            var comment = new PullRequestReviewCommentCreate(body, commitId, path, position);

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

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

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

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

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("fakeOwner", "fakeRepoName", 1, null));
        }
        public async Task EnsuresNotNullArguments()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

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

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

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

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

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

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

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

            await Assert.ThrowsAsync <ArgumentException>(() => client.GetAll("", "name", 1, ApiOptions.None));

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