Example #1
0
        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();
        }
Example #2
0
        public void CanCleanHistory_WhenExceedMaxItems()
        {
            var       container = new RepoHistoryContainer();
            const int maxItems  = 10;

            for (var i = 1; i <= maxItems; ++i)
            {
                container.Urls.Add("https://github.com/ebenzhang/ezplayer/pull/" + i);
            }
            var repoHistory = new RecentRepo {
                MaxHistoryItems = maxItems
            };

            repoHistory.From(container);
            Assert.That(repoHistory.PullRequests.Count, Is.EqualTo(maxItems));
            container.Urls.Add("https://github.com/ebenzhang/ezplayer/pull/21000");
            repoHistory.From(container);
            Assert.That(repoHistory.PullRequests.Count, Is.EqualTo(maxItems / 2), "Only half of the MaxItems are kept.");
        }
Example #3
0
        public async void ShouldInsertMostRecentRepoToTheBegining()
        {
            var container = new RepoHistoryContainer();

            for (var i = 1; i <= 4; ++i)
            {
                container.Urls.Add("https://github.com/gitext/gitextensions/pull/" + i);
            }
            var repoHistory = new RecentRepo();

            repoHistory.From(container);

            const string newPrUrl  = "https://github.com/ebenzhang/ezplayer/pull/21000";
            var          newPrInfo = PullRequestLocator.FromUrl(newPrUrl);
            var          persist   = Substitute.For <IRepoHistoryPersist>();
            await repoHistory.Save(newPrInfo, persist);

            repoHistory.PullRequests.First().ShouldBe(newPrInfo);
            repoHistory.Owners.First().ShouldBe("ebenzhang");
            repoHistory.Repositories.First().ShouldBe("ezplayer");
        }