コード例 #1
0
        public void TestGetMerges(ZipScenario scenario)
        {
            var merges = new ZippedRepo(GetTestRepos(scenario.Sources)).GetMerges().ToList();

            Assert.That(merges.Select(Sha), Is.EquivalentTo(scenario.Merges.Select(c => c.Sha)));
            Assert.That(merges.Select(c => c.Parents.Select(Sha).ToArray()), Is.EqualTo(scenario.Merges.Select(c => c.Parents)));
        }
コード例 #2
0
        public void TestZipScenarios(ZipScenario scenario)
        {
            var config = new Config {
                Sources = GetTestRepoPaths(scenario.Sources),
                Target  = TestData.GetCleanTempDir(),
                Force   = true,
                Silent  = true
            };
            var zipper = new RepoZipper(config);
            var repo   = zipper.Zip();

            var branches = repo.Branches.Where(b => !b.IsRemote).ToList();

            Assert.That(branches.Select(b => b.FriendlyName),
                        Is.EquivalentTo(scenario.Branches.Keys));

            foreach (var branch in branches)
            {
                var commits = RepoUtil.GetPrimaryParents(branch.Tip).Select(c => c.Message).Reverse();
                Assert.That(commits,
                            Is.EqualTo(scenario.Branches[branch.FriendlyName].Select(sha => (repo.Lookup(sha) as Commit).Message)),
                            "Commits do not match for branch: " + branch.FriendlyName
                            );
            }

            // TODO this may be unified with ZippedRepoTest
            var merges = RepoUtil.GetMerges(branches.Select(b => b.Tip)).ToList();             // just retrieve merges for zipped branches

            Assert.That(merges.Select(m => m.Message), Is.EquivalentTo(scenario.Merges.Select(c => Lookup(repo, c.Sha).Message)));

            // We have to skip the 1st parent as this one may be different
            var actual   = merges.Select(c => c.Parents.Skip(1).Select(p => p.Message));
            var expected = scenario.Merges.Select(c => c.Parents.Skip(1).Select(p => Lookup(repo, p).Message));

            Assert.That(actual, Is.EquivalentTo(expected));
        }