public static Issuecomment ToDBIssueComment(this Octokit.IssueComment issue, Issuecomment inIssue, long repo) { inIssue.Id = issue.Id; inIssue.Body = issue.Body; inIssue.CreatedAt = issue.CreatedAt; inIssue.UpdatedAt = issue.UpdatedAt; inIssue.User = (int)(issue.User?.Id); inIssue.IssueRepository = repo; inIssue.IssueNumber = int.Parse(new Uri(issue.HtmlUrl).Segments.Last()); return(inIssue); }
public async void TestIssueHistory() { var firstComment = new IssueComment(1, null, null, null, DateTimeOffset.FromFileTime(0), null, null); var secondComment = new IssueComment(3, null, null, null, DateTimeOffset.FromFileTime(100), null, null); var firstEvent = new EventInfo(2, null, null, null, null, EventInfoState.Assigned, null, DateTimeOffset.FromFileTime(50)); GitHubClientMock.Setup( ghc => ghc.Issue.Comment.GetAllForIssue(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>())) .Returns(() => { var t = new Task<IReadOnlyList<IssueComment>>( () => new ReadOnlyCollection<IssueComment>(new List<IssueComment> {firstComment,secondComment})); t.Start(); return t; }); GitHubClientMock.Setup( ghc => ghc.Issue.Events.GetAllForIssue(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>())) .Returns(() => { var t = new Task<IReadOnlyList<EventInfo>>(() => new ReadOnlyCollection<EventInfo>(new List<EventInfo> { firstEvent })); t.Start(); return t; }); var vm = new IssueViewModel("repo", 1, "owner"); await vm.Refresh(); var history = vm.HistoryViewModel.IssueHistory.ToList(); Assert.AreEqual(firstComment, history[0]); Assert.AreEqual(firstEvent, history[1]); Assert.AreEqual(secondComment, history[2]); }