public async Task EnsuresNonNullArguments() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", "name", 1, options: null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", "name", 1, request: null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", "name", 1, null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(1, 1, options: null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(1, 1, request: null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(1, 1, null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("", "name", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("owner", "", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("", "name", 1, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None)); }
public void DeletesCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); client.Delete(1, 42); connection.Received().Delete(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/comments/42")); }
private static async Task GetComments(GitHubClient client, StringBuilder content, DateTime fromDate, DateTime toDate, bool isSortByCreated, HashSet <int> commentsAdded) { IssueCommentsClient issueCommentsClient = new IssueCommentsClient(new ApiConnection(client.Connection)); IssueCommentRequest commentRequest = new IssueCommentRequest() { Since = fromDate, Direction = SortDirection.Ascending, Sort = isSortByCreated ? IssueCommentSort.Created : IssueCommentSort.Updated }; ApiOptions commentOptions = new ApiOptions() { PageSize = MaxPerPage, PageCount = 1, StartPage = 1 }; bool hasMoreComments = true; while (hasMoreComments) { var comments = await issueCommentsClient.GetAllForRepository(RepoOwner, RepoName, commentRequest, commentOptions); foreach (var comment in comments) { bool isInDateRange = isSortByCreated ? (comment.CreatedAt >= fromDate && comment.CreatedAt <= toDate) : (comment.UpdatedAt >= fromDate && comment.UpdatedAt <= toDate); if (isInDateRange) { if (!commentsAdded.Contains(comment.Id)) { commentsAdded.Add(comment.Id); bool isInternal = KnownInternalContributors.Contains(comment.User.Login); string issueType = "Comment"; string relation = StoreAndGetIssueRelation(isInternal, issueType); content.AppendLine(comment.User.Login + "\t" + comment.HtmlUrl + "\t" + "NA" + "\t" + comment.AuthorAssociation + "\t" + issueType + "\t" + relation + "\t" + comment.CreatedAt + "\t" + comment.UpdatedAt); contributors.Add(comment.User.Login); } } else { // Outside date range hasMoreComments = false; break; // from inner loop } } if (hasMoreComments && comments.Count == MaxPerPage) { commentOptions.StartPage++; } else { hasMoreComments = false; } } }
public void DeletesCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); client.Delete("fake", "repo", 42); connection.Received().Delete(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42")); }
public async Task EnsuresNonNullArguments() { var client = new IssueCommentsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get(null, "name", 1)); await Assert.ThrowsAsync<ArgumentException>(() => client.Get("", "name", 1)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Get("owner", null, 1)); await Assert.ThrowsAsync<ArgumentException>(() => client.Get("owner", "", 1)); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); client.GetForIssue("fake", "repo", 3); connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments")); }
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 void PostsToCorrectUrl() { const string issueCommentUpdate = "Worthwhile update"; var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); client.Update("fake", "repo", 42, issueCommentUpdate); connection.Received().Patch <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"), Arg.Any <object>()); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await client.Get(1, 42); connection.Received().Get <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/comments/42"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.squirrel-girl-preview+json"); }
public async Task RequestsCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); await client.Get(1, 42); connection.Received().Get<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview"); }
public void RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); client.Get("fake", "repo", 42); connection.Received().Get<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"), Arg.Any<Dictionary<string, string>>(), Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview")); }
public async Task EnsuresNonNullArguments() { var client = new IssueCommentsClient(Substitute.For <IApiConnection>()); await AssertEx.Throws <ArgumentNullException>(async() => await client.Get(null, "name", 1)); await AssertEx.Throws <ArgumentException>(async() => await client.Get("", "name", 1)); await AssertEx.Throws <ArgumentNullException>(async() => await client.Get("owner", null, 1)); await AssertEx.Throws <ArgumentException>(async() => await client.Get("owner", "", 1)); }
public void RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); client.Get("fake", "repo", 42); connection.Received().Get <IssueComment>( Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"), Arg.Any <Dictionary <string, string> >(), Arg.Is <string>(s => s == "application/vnd.github.squirrel-girl-preview")); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await AssertEx.Throws <ArgumentNullException>(async() => await client.GetForRepository(null, "name")); await AssertEx.Throws <ArgumentException>(async() => await client.GetForRepository("", "name")); await AssertEx.Throws <ArgumentNullException>(async() => await client.GetForRepository("owner", null)); await AssertEx.Throws <ArgumentException>(async() => await client.GetForRepository("owner", "")); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); await client.GetAllForRepository("fake", "repo"); connection.Received().GetAll<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview", Args.ApiOptions); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("", "name", 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("owner", "", 1)); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None)); }
public async Task EnsuresArgumentsNotNullOrEmpty() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await AssertEx.Throws <ArgumentNullException>(async() => await client.Delete(null, "name", 42)); await AssertEx.Throws <ArgumentException>(async() => await client.Delete("", "name", 42)); await AssertEx.Throws <ArgumentNullException>(async() => await client.Delete("owner", null, 42)); await AssertEx.Throws <ArgumentException>(async() => await client.Delete("owner", "", 42)); }
public async Task RequestsCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await client.GetAllForRepository("fake", "repo"); connection.Received().GetAll <IssueComment>( Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); }
public void RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); var options = new ApiOptions { PageCount = 1, PageSize = 1, StartPage = 1 }; client.GetAllForRepository("fake", "repo", options); connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"), options); }
public async Task RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); var request = new IssueCommentRequest() { Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()), }; await client.GetAllForIssue(1, 3, request); connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update(null, "name", 42, "x")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update("owner", null, 42, "x")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update("owner", "name", 42, null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.Update(1, 42, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.Update("", "name", 42, "x")); await Assert.ThrowsAsync <ArgumentException>(() => client.Update("owner", "", 42, "x")); }
public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); var options = new ApiOptions { StartPage = 1, PageSize = 1, PageCount = 1 }; await client.GetAllForIssue(1, 3, options); connection.Received().GetAll <IssueComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), Arg.Any <Dictionary <string, string> >(), "application/vnd.github.squirrel-girl-preview+json", options); }
public void RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); var options = new ApiOptions { PageCount = 1, PageSize = 1, StartPage = 1 }; client.GetAllForRepository("fake", "repo", options); connection.Received().GetAll<IssueComment>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"), Arg.Any<Dictionary<string, string>>(), Arg.Is<string>(s => s == "application/vnd.github.squirrel-girl-preview"), options); }
public void RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For <IApiConnection>(); var client = new IssueCommentsClient(connection); var options = new ApiOptions { PageCount = 1, PageSize = 1, StartPage = 1 }; client.GetAllForRepository("fake", "repo", options); connection.Received().GetAll <IssueComment>( Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"), Arg.Any <Dictionary <string, string> >(), Arg.Is <string>(s => s == "application/vnd.github.squirrel-girl-preview"), options); }
public void DeletesCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); client.Delete(1, 42); connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42")); }
public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); var options = new ApiOptions { StartPage = 1, PageSize = 1, PageCount = 1 }; await client.GetAllForIssue(1, 3, options); connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"), Arg.Any<Dictionary<string, string>>(), "application/vnd.github.squirrel-girl-preview", options); }
public async Task EnsuresArgumentsNotNull() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(null, "name", 1, "title")); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", 1, "x")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, 1, "x")); await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", 1, "x")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", 1, null)); }
public void PostsToCorrectUrlWithRepositoryId() { const string issueCommentUpdate = "Worthwhile update"; var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); client.Update(1, 42, issueCommentUpdate); connection.Received().Patch<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42"), Arg.Any<object>()); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(null, "name", 42, "x")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", null, 42, "x")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update("owner", "name", 42, null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Update(1, 42, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.Update("", "name", 42, "x")); await Assert.ThrowsAsync<ArgumentException>(() => client.Update("owner", "", 42, "x")); }
public void DeletesCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); client.Delete("fake", "repo", 42); connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42")); }
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>()); }
public async Task EnsuresArgumentsNotNullOrEmpty() { var connection = Substitute.For<IApiConnection>(); var client = new IssueCommentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete(null, "name", 42)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.Delete("owner", null, 42)); await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("", "name", 42)); await Assert.ThrowsAsync<ArgumentException>(() => client.Delete("owner", "", 42)); }