Пример #1
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssuesLabelsClient(connection);

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

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

                await client.GetAllForIssue(1, 42);

                connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), Args.ApiOptions);
            }
Пример #3
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssuesLabelsClient(connection);

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

                connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Args.ApiOptions);
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssuesLabelsClient(connection);

                await client.GetAllForIssue(1, 42);

                connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), null, "application/vnd.github.symmetra-preview+json", Args.ApiOptions);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());

                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<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));
            }
Пример #6
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new IssuesLabelsClient(Substitute.For <IApiConnection>());

                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 RequestsCorrectUrlWithApiOptionsWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new IssuesLabelsClient(connection);

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

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

                connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels"), options);
            }
Пример #8
0
            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new IssuesLabelsClient(connection);

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

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

                connection.Received().GetAll <Label>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), options);
            }
        private Task <IReadOnlyList <Label> > GetLabelsAsync(PullRequestContext context)
        {
            var client = new IssuesLabelsClient(new ApiConnection(context.GithubConnection));

            return(client.GetAllForIssue(context.Payload.Repository.Id, context.Payload.PullRequest.Number));
        }