Beispiel #1
0
        public void GivenNodeInBranch_WhenRemoved_ThenNotShownInBranch()
        {
            Tree t = new Tree();

            ICommit c1 = new CommitStub("h1");
            ICommit c2 = new CommitStub("h2", c1);
            ICommit c3 = new CommitStub("h3", c2);

            t.SetCommits(new[] { c1, c2, c3 });

            IBranch b = new BranchStub("b", c3.Hash);

            t.AddBranch(b, new[] { c1.Hash, c2.Hash, c3.Hash });

            INode n2 = t.GetNode(c2.Hash);

            Assert.NotNull(n2);

            // Act.
            t.RemoveNode(n2);

            // Verify.
            INode[] nodesInBranch = t.EnumerateNodes(b).ToArray();
            Assert.Equal(2, nodesInBranch.Length);
            Assert.Equal(c1.Hash, nodesInBranch[0].Commit.Hash);
            Assert.Equal(c3.Hash, nodesInBranch[1].Commit.Hash);
        }
Beispiel #2
0
        private CommitStub CreateCommitWithAuthor()
        {
            SignatureStub author = new SignatureStub {
                Name = AuthorName, EMail = AuthorEMail, When = _authorWhen
            };
            CommitStub commit =
                new CommitStub {
                Author = author, Committer = author, Treeish = Treeish1, Message = Message
            };

            return(commit);
        }
Beispiel #3
0
        public void GivenNodeWithSameCommitter_ThenReturnsExpectedText()
        {
            CommitStub commit = CreateCommitWithAuthor();
            NodeStub   node   = new NodeStub(commit);

            GraphTooltipHelper helper = new GraphTooltipHelper();
            string             result = helper.MakeNodeTooltip(node);

            Assert.Equal(
                $"{Treeish1} - {Message}" +
                $"{LineSeparator}{AuthorName} @ {_authorWhen}",
                result);
        }
Beispiel #4
0
        private void Run(TagPickerTestCase testCase)
        {
            INode MockNode(string hash, DateTimeOffset?date)
            {
                ICommit commit = new CommitStub(hash, date ?? DateTimeOffset.MinValue);
                INode   node   = new NodeStub(commit);

                return(node);
            }

            IBranch MockBranch(string name)
            {
                if (string.IsNullOrWhiteSpace(name))
                {
                    return(null);
                }

                return(new Branch(name, null));
            }

            ITagPickingOptions tpo = TagPickingOptions.Set(
                testCase.Mode,
                testCase.TakeCount,
                testCase.IncludeOrphanedTags);
            TagPicker p = new TagPicker(tpo);

            ITag ta = new Tag(testCase.TagAName, null);
            ITag tb = new Tag(testCase.TagBName, null);
            ITag tc = new Tag(testCase.TagCName, null);

            INode na = MockNode("na", testCase.CommitADate);
            INode nb = MockNode("nb", testCase.CommitBDate);
            INode nc = MockNode("nc", testCase.CommitCDate);

            IBranch ba = MockBranch(testCase.BranchAName);
            IBranch bb = MockBranch(testCase.BranchBName);
            IBranch bc = MockBranch(testCase.BranchCName);

            var tagInfos = new[]
            {
                new TagInfo(ta, na, ba),
                new TagInfo(tb, nb, bb),
                new TagInfo(tc, nc, bc)
            };

            p.PreProcessAllTags(tagInfos);

            Assert.Equal(testCase.ExpectedTagAPicked, p.CheckIfTagShouldBePicked(ta));
            Assert.Equal(testCase.ExpectedTagBPicked, p.CheckIfTagShouldBePicked(tb));
            Assert.Equal(testCase.ExpectedTagCPicked, p.CheckIfTagShouldBePicked(tc));
        }
Beispiel #5
0
        public void GivenSetOfCommits_ThenEnumeratesThemUp()
        {
            ICommit a = new CommitStub("a");
            ICommit b = new CommitStub("b", a);
            ICommit c = new CommitStub("c", b);
            ICommit d = new CommitStub("d", c);

            CommitsData cd = new CommitsData(new[] { a, b, c, d });

            // Act.
            ICommit[] commits = cd.EnumerateUpTheHistoryFrom(d).Take(25).ToArray();

            // Verify.
            Assert.Equal(new[] { d, c, b, a }, commits);
        }
Beispiel #6
0
        public void GivenNodeWithDifferentCommitter_ThenReturnsExpectedText()
        {
            CommitStub    commit    = CreateCommitWithAuthor();
            SignatureStub committer =
                new SignatureStub {
                Name = CommitterName, EMail = CommitterEMail, When = _committerWhen
            };

            commit.Committer = committer;
            NodeStub node = new NodeStub(commit);

            GraphTooltipHelper helper = new GraphTooltipHelper();
            string             result = helper.MakeNodeTooltip(node);

            Assert.Equal(
                $"{Treeish1} - {Message}" +
                $"{LineSeparator}{AuthorName} @ {_authorWhen}" +
                $"{LineSeparator}Committed by: {CommitterName} @ {_committerWhen}",
                result);
        }