public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new CheckRunsClient(connection); await client.GetAllForReference(1, "ref"); connection.Received().GetAll <CheckRunsResponse>( Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits/ref/check-runs"), Args.EmptyDictionary, "application/vnd.github.antiope-preview+json", Args.ApiOptions); }
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.GetAllForReference(1, "ref", request); connection.Received().GetAll <CheckRunsResponse>( Arg.Is <Uri>(u => u.ToString() == "repositories/1/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", Args.ApiOptions); }
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)); }