public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await AssertEx.Throws <ArgumentNullException>(async() => await client.Create(null, "name", 1, "title")); await AssertEx.Throws <ArgumentException>(async() => await client.Create("", "name", 1, "x")); await AssertEx.Throws <ArgumentNullException>(async() => await client.Create("owner", null, 1, "x")); await AssertEx.Throws <ArgumentException>(async() => await client.Create("owner", "", 1, "x")); await AssertEx.Throws <ArgumentNullException>(async() => await client.Create("owner", "name", 1, null)); }
public void PostsToCorrectUrl() { const string newComment = "some title"; var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); client.Create("fake", "repo", 1, newComment); connection.Received().Post <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/1/comments"), Arg.Any <object>()); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null, "name", 1, "x")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", null, 1, "x")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create("owner", "name", 1, null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(1, 1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("", "name", 1, "x")); await Assert.ThrowsAsync <ArgumentException>(() => client.Create("owner", "", 1, "x")); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", 1, "x")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, 1, "x")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", 1, null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, 1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", 1, "x")); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", 1, "x")); }
public void PostsToCorrectUrlWithRepositoryId() { const string newComment = "some title"; var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); client.Create(1, 1, newComment); connection.Received().Post<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/1/comments"), Arg.Any<object>()); }