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

Commit 0999f2c

Browse files
Fixing test and adding tests
1 parent 5064ec4 commit 0999f2c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/GitHub.InlineReviews/ViewModels/PullRequestReviewCommentViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public PullRequestReviewCommentViewModel(
6161
.ToProperty(this, x => x.CanStartReview);
6262

6363
commitCaption = pendingReviewAndIdObservable
64-
.Select(list => !list[1] ? Resources.EditComment : list[0] ? Resources.AddReviewComment : Resources.AddSingleComment)
64+
.Select(list => !list[1] ? Resources.EditComment : list[0] ? Resources.AddSingleComment : Resources.AddReviewComment)
6565
.ToProperty(this, x => x.CommitCaption);
6666

6767
StartReview = ReactiveCommand.CreateAsyncTask(

test/GitHub.InlineReviews.UnitTests/ViewModels/PullRequestReviewCommentViewModelTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ public void IsTrueWhenSessionHasNoPendingReview()
3030

3131
Assert.That(target.CanStartReview, Is.True);
3232
}
33+
34+
[Test]
35+
public void IsFalseWhenEditingExistingComment()
36+
{
37+
var session = CreateSession(false);
38+
39+
var pullRequestReviewCommentModel = Substitute.For<IPullRequestReviewCommentModel>();
40+
pullRequestReviewCommentModel.Id.Returns(1);
41+
42+
var target = CreateTarget(session, pullRequestReviewCommentModel: pullRequestReviewCommentModel);
43+
44+
Assert.That(target.CanStartReview, Is.False);
45+
}
3346
}
3447

3548
public class TheBeginEditProperty
@@ -147,6 +160,19 @@ public void IsAddSingleCommentWhenSessionHasNoPendingReview()
147160

148161
Assert.That(target.CommitCaption, Is.EqualTo("Add a single comment"));
149162
}
163+
164+
[Test]
165+
public void IsEditCommentWhenEditingExistingComment()
166+
{
167+
var session = CreateSession(false);
168+
169+
var pullRequestReviewCommentModel = Substitute.For<IPullRequestReviewCommentModel>();
170+
pullRequestReviewCommentModel.Id.Returns(1);
171+
172+
var target = CreateTarget(session, pullRequestReviewCommentModel: pullRequestReviewCommentModel);
173+
174+
Assert.That(target.CommitCaption, Is.EqualTo("Edit Comment"));
175+
}
150176
}
151177

152178
public class TheStartReviewCommand

0 commit comments

Comments
 (0)