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

Commit b0c74c9

Browse files
committed
Add test for OpenPROnGitHub command
1 parent 8c1c21b commit b0c74c9

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/GitHub.App/SampleData/PullRequestListViewModelDesigner.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public PullRequestListViewModelDesigner()
3434
Assignee = new AccountDesigner { Login = "haacked", IsUser = true },
3535
});
3636
prs.Add(new PullRequestModel(409, "Fix publish button style and a really, really long name for this thing... OMG look how long this name is yusssss",
37-
new AccountDesigner { Login = "shana", IsUser = true },
37+
new AccountDesigner { Login = "shana", IsUser = true },
3838
DateTimeOffset.Now - TimeSpan.FromHours(5))
3939
{
4040
CommentCount = 27,
@@ -76,5 +76,6 @@ public PullRequestListViewModelDesigner()
7676

7777
public ReactiveCommand<object> OpenPullRequest { get; }
7878
public ReactiveCommand<object> CreatePullRequest { get; }
79+
public ReactiveCommand<object> OpenPROnGitHub { get; }
7980
}
8081
}

src/GitHub.Exports.Reactive/ViewModels/IPullRequestListViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ public interface IPullRequestListViewModel : IViewModel, ICanNavigate, IHasBusy
4141
IAccount SelectedAssignee { get; set; }
4242
ReactiveCommand<object> OpenPullRequest { get; }
4343
ReactiveCommand<object> CreatePullRequest { get; }
44+
ReactiveCommand<object> OpenPROnGitHub { get; }
4445
}
4546
}

src/UnitTests/GitHub.App/ViewModels/PullRequestListViewModelTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using GitHub.Services;
88
using GitHub.Settings;
99
using GitHub.ViewModels;
10+
using GitHub.Primitives;
1011
using NSubstitute;
1112
using Xunit;
1213

@@ -90,6 +91,23 @@ public void ResettingAuthorToNoneShouldNotTriggerFilter()
9091
prViewModel.PullRequests.Received(2).Filter = AnyFilter;
9192
}
9293

94+
[Theory]
95+
[InlineData("https://github.com/owner/repo", 666, "https://github.com/owner/repo/pull/666")]
96+
public void OpenPROnGitHubShouldOpenBrowser(string cloneUrl, int pullNumber, string expectUrl)
97+
{
98+
var repositoryHost = CreateRepositoryHost();
99+
var repository = Substitute.For<ILocalRepositoryModel>();
100+
var settings = CreateSettings();
101+
var browser = Substitute.For<IVisualStudioBrowser>();
102+
var prViewModel = new PullRequestListViewModel(repositoryHost, repository, settings, browser);
103+
prViewModel.SelectedRepository = Substitute.For<IRemoteRepositoryModel>();
104+
prViewModel.SelectedRepository.CloneUrl.Returns(new UriString(cloneUrl));
105+
106+
prViewModel.OpenPROnGitHub.Execute(pullNumber);
107+
108+
browser.ReceivedWithAnyArgs(1).OpenUrl(new Uri(expectUrl));
109+
}
110+
93111
Func<IPullRequestModel, int, IList<IPullRequestModel>, bool> AnyFilter =>
94112
Arg.Any<Func<IPullRequestModel, int, IList<IPullRequestModel>, bool>>();
95113

0 commit comments

Comments
 (0)