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

                var request = new CheckRunRequest {
                    CheckName = "build"
                };

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("", "repo", "ref"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "", "ref"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "repo", ""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request, ApiOptions.None));

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference(1, "", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference(1, "", request, ApiOptions.None));
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                var request = new CheckRunRequest {
                    CheckName = "build"
                };

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCheckSuite(null, "repo", 1, request));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", null, 1, request));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", "repo", 1, null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCheckSuite(null, "repo", 1, request, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", null, 1, request, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", "repo", 1, null, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", "repo", 1, request, null));

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCheckSuite(1, 1, request, null));
            }
            public async Task EnsuresNonEmptyArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                await Assert.ThrowsAsync <ArgumentException>(() => client.Get("", "repo", 1));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Get("fake", "", 1));
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                await client.Get(1, 1);

                connection.Received().Get <CheckRun>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-runs/1"),
                    null,
                    "application/vnd.github.antiope-preview+json");
            }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                await client.GetAllAnnotations("fake", "repo", 1);

                connection.Received().GetAll <CheckRunAnnotation>(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/check-runs/1/annotations"),
                    null,
                    "application/vnd.github.antiope-preview+json",
                    Args.ApiOptions);
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                await client.GetAllForCheckSuite(1, 1);

                connection.Received().GetAll <CheckRunsResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites/1/check-runs"),
                    Args.EmptyDictionary,
                    "application/vnd.github.antiope-preview+json",
                    Args.ApiOptions);
            }
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                await client.GetAllForReference("fake", "repo", "ref");

                connection.Received().GetAll <CheckRunsResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"),
                    Args.EmptyDictionary,
                    "application/vnd.github.antiope-preview+json",
                    Args.ApiOptions);
            }
Example #8
0
            public async Task EnsuresNonEmptyArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                var update = new CheckRunUpdate {
                    Status = CheckStatus.InProgress
                };

                await Assert.ThrowsAsync <ArgumentException>(() => client.Update("", "repo", 1, update));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Update("fake", "", 1, update));
            }
            public async Task EnsuresNonEmptyArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                var newCheckRun = new NewCheckRun("status", "123abc")
                {
                    Status = CheckStatus.Queued
                };

                await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", "repo", newCheckRun));

                await Assert.ThrowsAsync <ArgumentException>(() => client.Create("fake", "", newCheckRun));
            }
Example #10
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                var update = new CheckRunUpdate {
                    Status = CheckStatus.InProgress
                };

                await client.Update("fake", "repo", 1, update);

                connection.Received().Patch <CheckRun>(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/check-runs/1"),
                    update,
                    "application/vnd.github.antiope-preview+json");
            }
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

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

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

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllAnnotations("fake", "repo", 1, null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllAnnotations(1, 1, null));
            }
            public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                var options = new ApiOptions {
                    PageSize = 1
                };

                await client.GetAllAnnotations(1, 1, options);

                connection.Received().GetAll <CheckRunAnnotation>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-runs/1/annotations"),
                    null,
                    "application/vnd.github.antiope-preview+json",
                    options);
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                var newCheckRun = new NewCheckRun("status", "123abc")
                {
                    Status = CheckStatus.Queued
                };

                await client.Create(1, newCheckRun);

                connection.Received().Post <CheckRun>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-runs"),
                    newCheckRun,
                    "application/vnd.github.antiope-preview+json");
            }
            public async Task RequestsCorrectUrlWithRequestWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                var request = new CheckRunRequest {
                    CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress
                };

                await client.GetAllForCheckSuite(1, 1, request);

                connection.Received().GetAll <CheckRunsResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites/1/check-runs"),
                    Arg.Is <Dictionary <string, string> >(x =>
                                                          x.Count == 3 &&
                                                          x["check_name"] == "build" &&
                                                          x["status"] == "in_progress" &&
                                                          x["filter"] == "latest"),
                    "application/vnd.github.antiope-preview+json",
                    Args.ApiOptions);
            }
            public async Task RequestsCorrectUrlWithRequestWithApiOptions()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckRunsClient(connection);

                var request = new CheckRunRequest {
                    CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress
                };
                var options = new ApiOptions {
                    PageSize = 1
                };

                await client.GetAllForReference("fake", "repo", "ref", request, options);

                connection.Received().GetAll <CheckRunsResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-runs"),
                    Arg.Is <Dictionary <string, string> >(x =>
                                                          x.Count == 3 &&
                                                          x["check_name"] == "build" &&
                                                          x["status"] == "in_progress" &&
                                                          x["filter"] == "latest"),
                    "application/vnd.github.antiope-preview+json",
                    options);
            }
 /// <summary>
 /// Initializes a new GitHub Checks API client.
 /// </summary>
 /// <param name="apiConnection">An API connection</param>
 public ChecksClient(ApiConnection apiConnection)
 {
     Run   = new CheckRunsClient(apiConnection);
     Suite = new CheckSuitesClient(apiConnection);
 }