public async Task DoesntThrowIfGetFileCalledDuringUpdate() { var thread = CreateThread(@"@@ -1,4 +1,4 @@ Line 1 Line 2 -Line 3 +Line 3 with comment"); using (var diffService = new FakeDiffService()) { var pullRequest = CreatePullRequest(thread); var service = CreateRealSessionService(diffService); var target = new PullRequestSession( service, CreateActor(), pullRequest, CreateLocalRepository(), string.Empty, true); await target.GetFile("test.cs"); // Simulate calling GetFile with a file that's not yet been initialized // while doing the Update. service.WhenForAnyArgs(x => x.Diff(null, null, null, null)) .Do(_ => target.GetFile("other.cs").Forget()); UpdateReadPullRequest(service, pullRequest); await target.Refresh(); } }
public async Task AddsNewReviewCommentToThreadNonHeadFile() { var baseContents = @"Line 1 Line 2 Line 3 Line 4"; var headContents = @"Line 1 Line 2 Line 3 with comment Line 4"; var comment1 = CreateThread(@"@@ -1,4 +1,4 @@ Line 1 Line 2 -Line 3 +Line 3 with comment", "Comment1"); var comment2 = CreateThread(@"@@ -1,4 +1,4 @@ Line 1 Line 2 -Line 3 +Line 3 with comment", "Comment2"); using (var diffService = new FakeDiffService()) { var pullRequest = CreatePullRequest(comment1); var service = CreateRealSessionService(diffService); diffService.AddFile(FilePath, baseContents, "MERGE_BASE"); diffService.AddFile(FilePath, headContents, "123"); var target = new PullRequestSession( service, CreateActor(), pullRequest, CreateLocalRepository(), "owner", true); var file = await target.GetFile(FilePath, "123"); Assert.That(file.InlineCommentThreads[0].Comments, Has.Count.EqualTo(1)); Assert.That(file.InlineCommentThreads[0].LineNumber, Is.EqualTo(2)); pullRequest = CreatePullRequest(comment1, comment2); UpdateReadPullRequest(service, pullRequest); await target.Refresh(); Assert.That(file.InlineCommentThreads[0].Comments, Has.Count.EqualTo(2)); Assert.That(file.InlineCommentThreads[0].LineNumber, Is.EqualTo(2)); } }
public async Task UpdatesThePullRequestModel() { var sessionService = CreateMockSessionService(); var target = new PullRequestSession( sessionService, CreateActor(), CreatePullRequest(), CreateLocalRepository(), "owner", true); var newPullRequest = CreatePullRequest(); UpdateReadPullRequest(sessionService, newPullRequest); await target.Refresh(); Assert.That(newPullRequest, Is.SameAs(target.PullRequest)); }
public async Task IsTrueWhenRefreshedWithPendingReview() { var sessionService = CreateMockSessionService(); var currentUser = CreateActor("grokys"); var target = new PullRequestSession( sessionService, currentUser, CreatePullRequest(), CreateLocalRepository(), "owner", true); Assert.That(target.HasPendingReview, Is.False); var review = CreateReview(author: currentUser, state: PullRequestReviewState.Pending); UpdateReadPullRequest(sessionService, CreatePullRequest(review)); await target.Refresh(); Assert.That(target.HasPendingReview, Is.True); }