public async Task PostsToCorrectUrlWithRepositoryId() { var newComment = new NewCommitComment("body"); var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); await client.Create(1, "sha", newComment); connection.Received().Post<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/sha/comments"), Arg.Any<object>()); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", "sha", new NewCommitComment("body"))); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, "sha", new NewCommitComment("body"))); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null, new NewCommitComment("body"))); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", "sha", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, null, new NewCommitComment("body"))); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, "sha", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", "sha", new NewCommitComment("body"))); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", "sha", new NewCommitComment("body"))); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "name", "", new NewCommitComment("body"))); await Assert.ThrowsAsync<ArgumentException>(() => client.Create(1, "", new NewCommitComment("body"))); }
public void PostsToCorrectUrl() { NewCommitComment newComment = new NewCommitComment("body"); var connection = Substitute.For<IApiConnection>(); var client = new RepositoryCommentsClient(connection); client.Create("fake", "repo", "sha", newComment); connection.Received().Post<CommitComment>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any<object>()); }