public async Task EnsuresNonNullArguments() { var client = new CommitsClient(Substitute.For <IApiConnection>()); var newCommit = new NewCommit("message", "tree", new[] { "parent1", "parent2" }); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "name", newCommit)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", null, newCommit)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", "name", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", "name", newCommit)); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("owner", "", newCommit)); }
public void PostsToTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new CommitsClient(connection); var parents = new List <string> { "sha-reference1", "sha-reference2" }; var newCommit = new NewCommit("message", "tree", parents); client.Create(1, newCommit); connection.Received().Post <Commit>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/git/commits"), Arg.Is <NewCommit>(nc => nc.Message == "message" && nc.Tree == "tree" && nc.Parents.Count() == 2)); }