Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 1489285

Browse files
author
Steven Kirk
committed
Added failing test.
The signal that the current session's PR model has been changed isn't getting to the live file.
1 parent b9d176a commit 1489285

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/GitHub.InlineReviews.UnitTests/Services/PullRequestSessionManagerTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,36 @@ public async Task CommitShaIsUpdatedOnTextChange()
644644
Assert.Null(file.CommitSha);
645645
}
646646

647+
[Fact]
648+
public async Task UpdatingCurrentSessionPullRequestTriggersLinesChanged()
649+
{
650+
var textView = CreateTextView();
651+
var sessionService = CreateSessionService();
652+
var expectedLineNumber = 2;
653+
var threads = new[]
654+
{
655+
CreateInlineCommentThreadModel(expectedLineNumber),
656+
};
657+
658+
sessionService.BuildCommentThreads(null, null, null).ReturnsForAnyArgs(threads);
659+
660+
var target = new PullRequestSessionManager(
661+
CreatePullRequestService(),
662+
sessionService,
663+
CreateRepositoryHosts(),
664+
new FakeTeamExplorerServiceHolder(CreateRepositoryModel()));
665+
var file = await target.GetLiveFile(FilePath, textView, textView.TextBuffer);
666+
var raised = false;
667+
var pullRequest = target.CurrentSession.PullRequest;
668+
669+
file.LinesChanged.Subscribe(x => raised = x.Count == 1 && x[0] == expectedLineNumber);
670+
671+
// LinesChanged should be raised even if the IPullRequestModel is the same.
672+
await target.CurrentSession.Update(target.CurrentSession.PullRequest);
673+
674+
Assert.True(raised);
675+
}
676+
647677
static IPullRequestReviewCommentModel CreateComment(
648678
string diffHunk,
649679
string body = "Comment",

0 commit comments

Comments
 (0)