public async void ShouldSaveCommentsBeforeRetrieveDiff() { await _mainWindowVm.RetrieveDiffs(); _commentsPersist.ClearReceivedCalls(); var pr = PullRequestLocator.FromUrl("https://github.com/owner/newrepo1/pull/122"); _mainWindowVm.PullRequestLocator = pr; var expectedCommentsContainer = CommentsContainer.From(_mainWindowVm.Diffs, _mainWindowVm.GeneralComments); try { await _mainWindowVm.RetrieveDiffs(); } catch { // ignored } _commentsPersist.Received(1) .Save(_pullRequestLocator, Arg.Is <CommentsContainer>(x => x.Equals(expectedCommentsContainer))) .IgnoreAsyncWarning(); }
public async void CanSaveComments() { var expectedCommentsContainer = CommentsContainer.From(_mainWindowVm.Diffs, _mainWindowVm.GeneralComments); await _mainWindowVm.SaveComments(); _commentsPersist.Received(1) .Save(_pullRequestLocator, Arg.Is <CommentsContainer>(x => x.Equals(expectedCommentsContainer))) .IgnoreAsyncWarning(); }
private async Task SaveCommentsWithoutChangeBusyStatus(PullRequestLocator request) { if (request == null || !request.IsValid()) { return; } var commentsContainer = _loadedComments; if (_loadedComments != null) { commentsContainer.AddComments(Diffs.ToList(), GeneralComments); } else { commentsContainer = CommentsContainer.From(Diffs, GeneralComments); } await _commentsPersist.Save(request, commentsContainer); }
public void HappyPath() { var diffs = new List <CommitFileVm>() { _file1, _file2 }; var container = CommentsContainer.From(diffs, "general comments"); Assert.That(container.GeneralComments, Is.EqualTo("general comments")); Assert.That(container.FileComments[0].Comments, Is.EqualTo("Comment1")); Assert.That(container.FileComments[0].FileName, Is.EqualTo("File1")); Assert.That(container.FileComments[0].ReviewStatus, Is.EqualTo(ReviewStatus.Reviewed)); Assert.That(container.FileComments[1].Comments, Is.EqualTo("Comment2")); Assert.That(container.FileComments[1].FileName, Is.EqualTo("File2")); Assert.That(container.FileComments[1].ReviewStatus, Is.EqualTo(ReviewStatus.HasntBeenReviewed)); }
public void ShouldNotSkipEmptyComments_AsWeNeedToSaveReviewStatus() { var diffs = new List <CommitFileVm> { _file1, _file2, _file3 }; _file2.Comments = ""; var container = CommentsContainer.From(diffs, "general comments"); container.FileComments[1].Comments.ShouldBeNullOrEmpty(); container.FileComments[1].FileName.ShouldBe("File2"); container.FileComments.Count.ShouldBe(3); container.FileComments[2].Comments.ShouldBeNullOrEmpty(); container.FileComments[2].FileName.ShouldBe("File3"); }
public void AbleToAddComments_SoCommentsWillBeKept_WhenUserChangeCommitRange() { var diffs = new List <CommitFileVm>() { _file1, _file2, }; var container = CommentsContainer.From(diffs, "general comments"); var commentsInCommitRange = new List <CommitFileVm> {// _file2 is not in commit range, _file3 is new. _file1, _file3 }; container.AddComments(commentsInCommitRange, "new general comments"); container.GeneralComments.ShouldBe("new general comments"); container.FileComments.ShouldContain(x => x.FileName == _file1.GitHubCommitFile.Filename); container.FileComments.ShouldContain(x => x.FileName == _file2.GitHubCommitFile.Filename); container.FileComments.ShouldContain(x => x.FileName == _file3.GitHubCommitFile.Filename); container.FileComments.ShouldContain(x => x.Comments == _file3.Comments); }