public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit(null, "name", "sha")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("", "name", "sha")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit("owner", null, "sha")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("owner", "", "sha")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCommit("owner", "name", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForCommit("owner", "name", "")); }
public void RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); client.GetAllForCommit("fake", "repo", "sha"); connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments")); }
public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForCommit(1, "sha", options); connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"), options); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); await client.GetAllForCommit(1, "sha"); connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"), Args.ApiOptions); }
public async Task RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllForCommit("fake", "repo", "sha", options); connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview", options); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); await client.GetAllForCommit(1, "sha"); connection.Received().GetAll<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview", Args.ApiOptions); }