예제 #1
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssueCommentsClient(connection);

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

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

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

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(1, 1, null));

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

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

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None));
            }
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new IssueCommentsClient(connection);

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

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

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

            await AssertEx.Throws <ArgumentException>(async() => await client.GetAllForIssue("owner", "", 1));
        }
        public void RequestsCorrectUrl()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new IssueCommentsClient(connection);

            client.GetAllForIssue("fake", "repo", 3);

            connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"));
        }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssueCommentsClient(connection);

                await client.GetAllForIssue(1, 3);

                connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/3/comments"),
                                                            Arg.Any <Dictionary <string, string> >(),
                                                            "application/vnd.github.squirrel-girl-preview+json",
                                                            Args.ApiOptions);
            }
            public void RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssueCommentsClient(connection);

                client.GetAllForIssue("fake", "repo", 3);

                connection.Received().GetAll <IssueComment>(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
                    Arg.Any <Dictionary <string, string> >(),
                    Arg.Is <string>(s => s == "application/vnd.github.squirrel-girl-preview"),
                    Args.ApiOptions);
            }
예제 #6
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssueCommentsClient(connection);

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

                client.GetAllForIssue("fake", "repo", 3, options);

                connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"), options);
            }
            public async Task RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssueCommentsClient(connection);

                var request = new IssueCommentRequest()
                {
                    Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()),
                };

                await client.GetAllForIssue(1, 3, request);

                connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/3/comments"),
                                                            Arg.Any <Dictionary <string, string> >(),
                                                            "application/vnd.github.squirrel-girl-preview+json",
                                                            Args.ApiOptions);
            }
            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssueCommentsClient(connection);

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

                await client.GetAllForIssue("fake", "repo", 3, options);

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

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

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForIssue(1, 1, null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("", "name", 1));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("owner", "", 1));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("", "name", 1, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None));
            }
            public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssueCommentsClient(connection);

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

                await client.GetAllForIssue(1, 3, options);

                connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"),
                    Arg.Any<Dictionary<string, string>>(),
                    "application/vnd.github.squirrel-girl-preview",
                    options);
            }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssueCommentsClient(connection);

                await client.GetAllForIssue("fake", "repo", 3);

                connection.Received().GetAll<IssueComment>(
                    Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
                    Arg.Any<Dictionary<string, string>>(),
                    "application/vnd.github.squirrel-girl-preview",
                    Args.ApiOptions);
            }
            public void RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssueCommentsClient(connection);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageSize = 1,
                    PageCount = 1
                };
                client.GetAllForIssue("fake", "repo", 3, options);

                connection.Received().GetAll<IssueComment>(
                    Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"), 
                    Arg.Any<Dictionary<string, string>>(),
                    Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview"), 
                    options);
            }