public void CanConvertToUrl() { var locator = new PullRequestLocator() { Owner = "EbenZhang", PullRequestNumber = 100, Repository = "PReviewer", }; var url = locator.ToUrl(); Assert.That(url, Is.EqualTo("https://github.com/EbenZhang/PReviewer/pull/100")); }
public async Task LoadRepoHistory() { using (new ScopeGuard(() => IsProcessing = true, () => IsProcessing = false)) { var historyContainer = await _repoHistoryPersist.Load(); RecentRepoes.From(historyContainer); PullRequestLocator = RecentRepoes.PullRequests.FirstOrDefault(); if (PullRequestLocator != null) { PullRequestUrl = PullRequestLocator.ToUrl(); } else { PullRequestLocator = PullRequestLocator.Empty; } } }
private void CoercePullRequestUrlAndLocator() { _prePullRequestLocator = PullRequestLocator; if (IsUrlMode) { try { PullRequestLocator.UpdateWith(PullRequestUrl); } catch (Exception ex) { throw new UriFormatException(ex.ToString()); } } else { PullRequestUrl = PullRequestLocator.ToUrl(); } }
public async void WhenRetrieveDiffs_ShouldAdjustRepoPositionInHistory_SoItWillBeTheDefaultRepo() { var container = new RepoHistoryContainer() { Owners = new List <string> { "owner1", "owner2" }, Repositories = new List <string> { "repo1", "repo2" }, Urls = new List <string> { "https://github.com/owner/repo1/pull/122", "https://github.com/owner/repo2/pull/121" }, }; var persist = Substitute.For <IRepoHistoryPersist>(); var repoHistory = new RecentRepo(); repoHistory.From(container); var prInfo = new PullRequestLocator(); prInfo.UpdateWith(container.Urls.First()); await repoHistory.Save(prInfo, persist); persist.Received(1).Save(Arg.Is <RepoHistoryContainer>(x => x.Urls.First() == prInfo.ToUrl())).IgnoreAsyncWarning(); }
public async void ShouldUpdatePRUrlAccordingly() { var prInfo = new PullRequestLocator { Owner = "1stOwner", Repository = "1stRepo", PullRequestNumber = 1 }; var persist = Substitute.For <IRepoHistoryPersist>(); var repoHistory = new RecentRepo(); await repoHistory.Save(prInfo, persist); Assert.That(repoHistory.PullRequests.Select(r => r.ToUrl()), Contains.Item(prInfo.ToUrl())); }