示例#1
0
        WhenCommitHasTwoChilder_andFirstChildIsOnMainBranch_AndSeconIsOnSecond_BuilderShould_AssignSecondIndexOfCommitOnSecondBranchToCommit()
        {
            var mainCommit1_1 = _commitCreator.CreateNewCommit();
            var mainCommit2_2 = _commitCreator.CreateNewCommit();
            var mainCommit2_3 = _commitCreator.CreateNewCommit();

            var branchFromMainCommit1_3            = _commitCreator.CreateNewCommit();
            var branchFromMainCommit2AndParentOf_4 = _commitCreator.CreateNewCommit();

            mainCommit1_1.Parents.Add(mainCommit2_2.Sha);
            mainCommit1_1.Parents.Add(branchFromMainCommit1_3.Sha);


            branchFromMainCommit1_3.Parents.Add(branchFromMainCommit2AndParentOf_4.Sha);
            mainCommit2_2.Parents.Add(mainCommit2_3.Sha);
            mainCommit2_2.Parents.Add(branchFromMainCommit2AndParentOf_4.Sha);

            Commit[] commits = new Commit[] { mainCommit1_1, branchFromMainCommit1_3, mainCommit2_2, branchFromMainCommit2AndParentOf_4, mainCommit2_3 };

            GraphBuilder vrlBuilder = new GraphBuilder();

            vrlBuilder.Build(commits);

            Assert.Equal(1, mainCommit1_1.HIndex);
            Assert.Equal(1, mainCommit2_2.HIndex);
            Assert.Equal(1, mainCommit2_3.HIndex);
            Assert.Equal(2, branchFromMainCommit1_3.HIndex);
            Assert.Equal(2, branchFromMainCommit2AndParentOf_4.HIndex);
        }
示例#2
0
        public Commit CreateNewCommit(params string[] parents)
        {
            var newSha = ShaCreator();
            var commit = new Commit
            {
                Sha        = newSha,
                ParentsIds = parents.Select(p => new ObjectId(p)).ToList(),
                Parents    = parents.ToList()
            };

            return(commit);
        }
示例#3
0
        public void ForEveryCommit_FromMainPath_AssignXIndex_Equals_One()
        {
            var commit3 = _commitCreator.CreateNewCommit();
            var commit2 = _commitCreator.CreateNewCommit(commit3.Sha);
            var commit1 = _commitCreator.CreateNewCommit(commit2.Sha);

            var commitCollection = new Commit[3] {
                commit1, commit2, commit3
            };

            GraphBuilder gb = new GraphBuilder();

            gb.Build(commitCollection);

            Assert.True(commitCollection.All(d => d.HIndex == XIndexOfMainPath));
        }