public async Task RequestsCorrectUrlWithRequestWithApiOptionsWithRepositoryId() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableCheckRunsClient(gitHubClient); var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress }; var options = new ApiOptions { PageSize = 1 }; client.GetAllForCheckSuite(1, 1, request, options); connection.Received().Get <List <CheckRunsResponse> >( Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-suites/1/check-runs"), Arg.Is <Dictionary <string, string> >(x => x.Count == 4 && x["per_page"] == "1" && x["check_name"] == "build" && x["status"] == "in_progress" && x["filter"] == "latest"), "application/vnd.github.antiope-preview+json"); }
public async Task EnsuresNonNullArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); var request = new CheckRunRequest { CheckName = "build" }; Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite(null, "repo", 1)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", null, 1)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite(null, "repo", 1, request)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", null, 1, request)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", "repo", 1, null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite(null, "repo", 1, request, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", null, 1, request, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", "repo", 1, null, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite("fake", "repo", 1, request, null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite(1, 1, null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite(1, 1, null, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForCheckSuite(1, 1, request, null)); }
public async Task EnsuresNonEmptyArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); var request = new CheckRunRequest { CheckName = "build" }; Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref")); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref")); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", "")); Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request, ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request, ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request, ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, "")); Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, "", request)); Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, "", request, ApiOptions.None)); }
/// <summary> /// Initializes a new GitHub Checks API client. /// </summary> /// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param> public ObservableChecksClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, nameof(client)); Run = new ObservableCheckRunsClient(client); Suite = new ObservableCheckSuitesClient(client); }
public async Task EnsuresNonEmptyArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); Assert.Throws <ArgumentException>(() => client.Get("", "repo", 1)); Assert.Throws <ArgumentException>(() => client.Get("fake", "", 1)); }
public async Task RequestsCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); client.Get(1, 1); gitHubClient.Check.Run.Received().Get(1, 1); }
public async Task RequestsCorrectUrl() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); client.Get("fake", "repo", 1); gitHubClient.Check.Run.Received().Get("fake", "repo", 1); }
public async Task EnsuresNonEmptyArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); var update = new CheckRunUpdate { Status = CheckStatus.InProgress }; Assert.Throws <ArgumentException>(() => client.Update("", "repo", 1, update)); Assert.Throws <ArgumentException>(() => client.Update("fake", "", 1, update)); }
public async Task EnsuresNonEmptyArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued }; Assert.Throws <ArgumentException>(() => client.Create("", "repo", newCheckRun)); Assert.Throws <ArgumentException>(() => client.Create("fake", "", newCheckRun)); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableCheckRunsClient(gitHubClient); client.GetAllAnnotations(1, 1); connection.Received().Get <List <CheckRunAnnotation> >( Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-runs/1/annotations"), Args.EmptyDictionary, "application/vnd.github.antiope-preview+json"); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableCheckRunsClient(gitHubClient); client.GetAllForCheckSuite("fake", "repo", 1); connection.Received().Get <List <CheckRunsResponse> >( Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/check-suites/1/check-runs"), Args.EmptyDictionary, "application/vnd.github.antiope-preview+json"); }
public async Task RequestsCorrectUrl() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); var update = new CheckRunUpdate { Status = CheckStatus.InProgress }; client.Update("fake", "repo", 1, update); gitHubClient.Check.Run.Received().Update("fake", "repo", 1, update); }
public async Task EnsuresNonNullArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); Assert.Throws <ArgumentNullException>(() => client.GetAllAnnotations(null, "repo", 1)); Assert.Throws <ArgumentNullException>(() => client.GetAllAnnotations("fake", null, 1)); Assert.Throws <ArgumentNullException>(() => client.GetAllAnnotations(null, "repo", 1, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllAnnotations("fake", null, 1, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllAnnotations("fake", "repo", 1, null)); Assert.Throws <ArgumentNullException>(() => client.GetAllAnnotations(1, 1, null)); }
public async Task RequestsCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableCheckRunsClient(gitHubClient); var newCheckRun = new NewCheckRun("status", "123abc") { Status = CheckStatus.Queued }; client.Create(1, newCheckRun); gitHubClient.Check.Run.Received().Create(1, newCheckRun); }
public async Task RequestsCorrectUrlWithApiOptionsWithRepositoryId() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableCheckRunsClient(gitHubClient); var options = new ApiOptions { PageSize = 1 }; client.GetAllAnnotations(1, 1, options); connection.Received().Get <List <CheckRunAnnotation> >( Arg.Is <Uri>(u => u.ToString() == "repositories/1/check-runs/1/annotations"), Arg.Is <Dictionary <string, string> >(x => x.Count == 1 && x["per_page"] == "1"), "application/vnd.github.antiope-preview+json"); }
public async Task RequestsCorrectUrlWithRequest() { var connection = Substitute.For <IConnection>(); var gitHubClient = new GitHubClient(connection); var client = new ObservableCheckRunsClient(gitHubClient); var request = new CheckRunRequest { CheckName = "build", Filter = CheckRunCompletedAtFilter.Latest, Status = CheckStatusFilter.InProgress }; client.GetAllForReference("fake", "repo", "ref", request); connection.Received().Get <List <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"); }