Exemple #1
0
        public void GivenTwoNodesWithAbsorbedCommits_ThenReturnsExpectedTextForEdgeWithTheSecondNumberIncluded()
        {
            int absorbedCount1 = 2;
            int absorbedCount2 = 3;

            var absorbedCommits1 = Enumerable.Repeat(new CommitStub(), absorbedCount1).ToArray();
            var absorbedCommits2 = Enumerable.Repeat(new CommitStub(), absorbedCount2).ToArray();

            NodeStub node1 = new NodeStub(new CommitStub {
                Treeish = Treeish1
            })
            {
                AbsorbedParentCommits = absorbedCommits1
            };
            NodeStub node2 = new NodeStub(new CommitStub {
                Treeish = Treeish2
            })
            {
                AbsorbedParentCommits = absorbedCommits2
            };

            GraphTooltipHelper helper = new GraphTooltipHelper();
            string             result = helper.MakeEdgeTooltip(node1, node2);

            Assert.Equal($"{Treeish1} -> ({absorbedCount2} more commits), {Treeish2}", result);
        }
Exemple #2
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);
        }
Exemple #3
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));
        }
Exemple #4
0
        public void GivenTwoSimpleNodes_ThenReturnsExpectedTextForEdge()
        {
            NodeStub node1 = new NodeStub(new CommitStub {
                Treeish = Treeish1
            });
            NodeStub node2 = new NodeStub(new CommitStub {
                Treeish = Treeish2
            });

            GraphTooltipHelper helper = new GraphTooltipHelper();
            string             result = helper.MakeEdgeTooltip(node1, node2);

            Assert.Equal($"{Treeish1} -> {Treeish2}", result);
        }
Exemple #5
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);
        }