示例#1
0
        public async Task Executes_ignores_leading_and_trailing_whitespace_in_footer_values(string commitId, string footerValue)
        {
            // ARRANGE
            var footer         = new ChangeLogEntryFooter(new CommitMessageFooterName("some-footer"), new PlainTextElement(footerValue));
            var expectedCommit = new TestDataFactory().GetGitCommit();

            m_GitRepositoryMock
            .Setup(x => x.TryGetCommit(commitId))
            .Returns(expectedCommit);

            var sut = new ParseCommitReferencesTask(m_Logger, m_GitRepositoryMock.Object);

            // ACT
            var result = await sut.RunAsync(GetChangeLogFromFooter(footer));

            // ASSERT
            Assert.Equal(ChangeLogTaskResult.Success, result);

            var commitLink = Assert.IsType <CommitReferenceTextElement>(footer.Value);

            Assert.Equal(expectedCommit.Id, commitLink.CommitId);
            Assert.Equal(footerValue, commitLink.Text);

            m_GitRepositoryMock.Verify(x => x.TryGetCommit(It.IsAny <string>()), Times.Once);
            m_GitRepositoryMock.Verify(x => x.TryGetCommit(commitId), Times.Once);
        }
示例#2
0
        public async Task Executes_does_not_add_a_commit_link_if_a_link_is_already_set(string footerValue)
        {
            // ARRANGE
            var uri            = new Uri("https://example.com");
            var footer         = new ChangeLogEntryFooter(new CommitMessageFooterName("some-footer"), new WebLinkTextElement(footerValue, uri));
            var expectedCommit = new TestDataFactory().GetGitCommit();

            m_GitRepositoryMock
            .Setup(x => x.TryGetCommit(footerValue))
            .Returns(expectedCommit);

            var sut = new ParseCommitReferencesTask(m_Logger, m_GitRepositoryMock.Object);

            // ACT
            var result = await sut.RunAsync(GetChangeLogFromFooter(footer));

            // ASSERT
            Assert.Equal(ChangeLogTaskResult.Success, result);

            Assert.NotNull(footer.Value);
            var webLink = Assert.IsType <WebLinkTextElement>(footer.Value);

            Assert.Equal(uri, webLink.Uri);
            Assert.Equal(footerValue, webLink.Text);

            m_GitRepositoryMock.Verify(x => x.TryGetCommit(It.IsAny <string>()), Times.Once);
            m_GitRepositoryMock.Verify(x => x.TryGetCommit(footerValue), Times.Once);
        }
示例#3
0
        public async Task Executes_ignores_footer_values_that_are_not_valid_commit_ids(string footerValue)
        {
            // ARRANGE
            var footer = new ChangeLogEntryFooter(new CommitMessageFooterName("some-footer"), new PlainTextElement(footerValue));

            var sut = new ParseCommitReferencesTask(m_Logger, m_GitRepositoryMock.Object);

            // ACT
            var result = await sut.RunAsync(GetChangeLogFromFooter(footer));

            // ASSERT
            Assert.IsType <PlainTextElement>(footer.Value);

            m_GitRepositoryMock.Verify(x => x.TryGetCommit(It.IsAny <string>()), Times.Never);
        }