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

                var request = new CheckSuiteRequest();

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

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.Get("fake", "", 1));
            }
Пример #3
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Rerequest("fake", null, 1));
            }
Пример #4
0
            public async Task EnsuresNonEmptyArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) });

                await Assert.ThrowsAsync <ArgumentException>(() => client.UpdatePreferences("", "repo", preferences));

                await Assert.ThrowsAsync <ArgumentException>(() => client.UpdatePreferences("fake", "", preferences));
            }
Пример #5
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                await client.Get(1, 1);

                connection.Received().Get <CheckSuite>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites/1"),
                    Arg.Any <Dictionary <string, string> >(),
                    "application/vnd.github.antiope-preview+json");
            }
Пример #6
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = MockedIApiConnection.PostReturnsHttpStatus(HttpStatusCode.Created);
                var client     = new CheckSuitesClient(connection);

                await client.Rerequest(1, 1);

                connection.Connection.Received().Post(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites/1/rerequest"),
                    Args.Object,
                    "application/vnd.github.antiope-preview+json");
            }
Пример #7
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                await client.GetAllForReference(1, "ref");

                connection.Received().GetAll <CheckSuitesResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits/ref/check-suites"),
                    Args.EmptyDictionary,
                    "application/vnd.github.antiope-preview+json",
                    Args.ApiOptions);
            }
Пример #8
0
            public async Task RequestsCorrectUrl()
            {
                var connection = MockedIApiConnection.PostReturnsHttpStatus(HttpStatusCode.Created);
                var client     = new CheckSuitesClient(connection);

                var request = new CheckSuiteTriggerRequest("123abc");

                await client.Request("fake", "repo", request);

                connection.Connection.Received().Post(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/check-suite-requests"),
                    request,
                    "application/vnd.github.antiope-preview+json");
            }
Пример #9
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var newCheckSuite = new NewCheckSuite("123abc");

                await client.Create(1, newCheckSuite);

                connection.Received().Post <CheckSuite>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites"),
                    newCheckSuite,
                    "application/vnd.github.antiope-preview+json");
            }
Пример #10
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var preferences = new CheckSuitePreferences(new[] { new CheckSuitePreferenceAutoTrigger(123, true) });

                await client.UpdatePreferences(1, preferences);

                connection.Received().Patch <CheckSuitePreferencesResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites/preferences"),
                    preferences,
                    "application/vnd.github.antiope-preview+json");
            }
Пример #11
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var newCheckSuite = new NewCheckSuite("123abc");

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

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(1, null));
            }
Пример #12
0
            public async Task RequestsCorrectUrlWithRequestWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var request = new CheckSuiteRequest
                {
                    AppId     = 123,
                    CheckName = "build"
                };

                await client.GetAllForReference(1, "ref", request);

                connection.Received().GetAll <CheckSuitesResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits/ref/check-suites"),
                    Arg.Is <Dictionary <string, string> >(x =>
                                                          x["app_id"] == "123" &&
                                                          x["check_name"] == "build"),
                    "application/vnd.github.antiope-preview+json",
                    Args.ApiOptions);
            }
Пример #13
0
 /// <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);
 }