public async Task EnsuresArgumentsNotNull() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1).ToTask()); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("", "name", 1).ToTask()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1).ToTask()); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForIssue("owner", "", 1).ToTask()); }
public async Task EnsuresNonNullArguments() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); Assert.Throws <ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1)); Assert.Throws <ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1)); Assert.Throws <ArgumentNullException>(() => client.GetAllForIssue(null, "name", 1, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForIssue("owner", null, 1, ApiOptions.None)); Assert.Throws <ArgumentNullException>(() => client.GetAllForIssue("owner", "name", 1, null)); Assert.Throws <ArgumentNullException>(() => client.GetAllForIssue(1, 1, null)); Assert.Throws <ArgumentException>(() => client.GetAllForIssue("", "name", 1)); Assert.Throws <ArgumentException>(() => client.GetAllForIssue("owner", "", 1)); Assert.Throws <ArgumentException>(() => client.GetAllForIssue("", "name", 1, ApiOptions.None)); Assert.Throws <ArgumentException>(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None)); }
public void RequestsCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); client.GetAllForIssue(1, 3); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repositories/1/issues/3/comments", UriKind.Relative), Arg.Any <IDictionary <string, string> >(), "application/vnd.github.squirrel-girl-preview"); }
public void RequestsCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); client.GetAllForIssue(1, 3); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repositories/1/issues/3/comments", UriKind.Relative), Args.EmptyDictionary, null); }
public void RequestsCorrectUrl() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); client.GetAllForIssue("fake", "repo", 3); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), null, null); }
public void RequestsCorrectUrl() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); client.GetAllForIssue("fake", "repo", 3); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), Args.EmptyDictionary, "application/vnd.github.squirrel-girl-preview"); }
public async Task ReturnsIssueCommentWithReactions() { var comments = await _issueCommentsClient.GetAllForIssue("alfhenrik-test", "repo-with-issue-comment-reactions", 1).ToList(); Assert.NotEmpty(comments); var comment = comments[0]; Assert.NotNull(comment.Reactions); Assert.Equal(3, comment.Reactions.TotalCount); Assert.Equal(1, comment.Reactions.Plus1); Assert.Equal(1, comment.Reactions.Hooray); Assert.Equal(1, comment.Reactions.Heart); Assert.Equal(0, comment.Reactions.Laugh); Assert.Equal(0, comment.Reactions.Confused); Assert.Equal(0, comment.Reactions.Minus1); }
public void RequestsCorrectUrlWithRepositoryIdWithApiOptions() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); var options = new ApiOptions { StartPage = 1, PageSize = 1, PageCount = 1 }; client.GetAllForIssue(1, 3, options); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repositories/1/issues/3/comments", UriKind.Relative), Arg.Is <IDictionary <string, string> >(d => d.Count == 2), null); }
public void RequestsCorrectUrlWithApiOptions() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); var options = new ApiOptions { StartPage = 1, PageSize = 1, PageCount = 1 }; client.GetAllForIssue("fake", "repo", 3, options); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), Arg.Is <IDictionary <string, string> >(d => d.Count == 2), "application/vnd.github.squirrel-girl-preview"); }
public void RequestsCorrectUrlWithApiOptions() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); var options = new ApiOptions() { StartPage = 1, PageSize = 1, PageCount = 1 }; client.GetAllForIssue("fake", "repo", 3, options); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), Arg.Any <Dictionary <string, string> >(), null); }
public void RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest() { var gitHubClient = Substitute.For <IGitHubClient>(); var client = new ObservableIssueCommentsClient(gitHubClient); var request = new IssueCommentRequest() { Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()), }; client.GetAllForIssue(1, 3, request); gitHubClient.Connection.Received(1).Get <List <IssueComment> >( new Uri("repositories/1/issues/3/comments", UriKind.Relative), Arg.Is <Dictionary <string, string> >(d => d.Count == 3 && d["since"] == "2016-11-23T11:11:11Z"), "application/vnd.github.squirrel-girl-preview"); }