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); }
public async Task Execute_does_not_replace_commit_references_if_no_entry_can_be_found() { // ARRANGE var testData = new TestDataFactory(); var sut = new ResolveEntryReferencesTask(m_Logger); var footer = new ChangeLogEntryFooter( new CommitMessageFooterName("footer-name"), new CommitReferenceTextElement("some-text", TestGitIds.Id3) ); var changelog = new ApplicationChangeLog() { testData.GetSingleVersionChangeLog("1.0", entries: new[] { testData.GetChangeLogEntry(commit: TestGitIds.Id1), testData.GetChangeLogEntry(commit: TestGitIds.Id2, footers: new[] { footer }) }) }; // ACT var result = await sut.RunAsync(changelog); // ASSERT Assert.Equal(ChangeLogTaskResult.Success, result); var commitReference = Assert.IsType <CommitReferenceTextElement>(footer.Value); Assert.Equal("some-text", commitReference.Text); Assert.Equal(TestGitIds.Id3, commitReference.CommitId); }
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); }
public async Task Execute_replaces_commit_references_if_commit_refers_to_a_change_log_entry_in_a_different_version() { // ARRANGE var testData = new TestDataFactory(); var sut = new ResolveEntryReferencesTask(m_Logger); var footer = new ChangeLogEntryFooter( new CommitMessageFooterName("footer-name"), new CommitReferenceTextElement("some-text", TestGitIds.Id1) ); var entry1 = testData.GetChangeLogEntry(commit: TestGitIds.Id1); var entry2 = testData.GetChangeLogEntry(commit: TestGitIds.Id2, footers: new[] { footer }); var changelog = new ApplicationChangeLog() { testData.GetSingleVersionChangeLog("2.0", entries: new[] { entry1 }), testData.GetSingleVersionChangeLog("1.0", entries: new[] { entry2 }) }; // ACT var result = await sut.RunAsync(changelog); // ASSERT Assert.Equal(ChangeLogTaskResult.Success, result); var entryReference = Assert.IsType <ChangeLogEntryReferenceTextElement>(footer.Value); Assert.Equal("some-text", entryReference.Text); Assert.Same(entry1, entryReference.Entry); }
/// <summary> /// Gets the display name for the footer's name. /// </summary> /// <returns> /// Returns the display name for the footer's name as configured in <paramref name="configuration"/>. /// If no display name is configured for the scope, returns the footer name. /// </returns> public static string GetFooterDisplayName(this ChangeLogEntryFooter footer, ChangeLogConfiguration configuration) { var displayName = configuration.Footers .FirstOrDefault(c => !String.IsNullOrWhiteSpace(c.Name) && new CommitMessageFooterName(c.Name).Equals(footer.Name) )?.DisplayName; return(!String.IsNullOrWhiteSpace(displayName) ? displayName : footer.Name.Value); }
public void Value_cannot_be_set_to_null_or_a_whitespace_value(string footerValue) { var sut = new ChangeLogEntryFooter( new CommitMessageFooterName("irrelevant"), new PlainTextElement("Some Text") ); Assert.Throws <ArgumentException>(() => sut.Value = null !); Assert.Throws <ArgumentException>(() => sut.Value = new PlainTextElement(footerValue)); }
private ApplicationChangeLog GetChangeLogFromFooter(ChangeLogEntryFooter footer) { var testData = new TestDataFactory(); return(new ApplicationChangeLog() { testData.GetSingleVersionChangeLog("1.0", entries: new[] { testData.GetChangeLogEntry(footers: new[] { footer }) }) }); }
public void Constructor_initializes_properties() { // ARRANGE var name = new CommitMessageFooterName("Some-Name"); var value = "some value"; // ACT var sut = new ChangeLogEntryFooter(name, value); // ASSERT Assert.Equal(name, sut.Name); Assert.Equal(value, sut.Value); }
public void FromCommitMessageFooter_returns_expected_footer() { // ARRANGE var name = new CommitMessageFooterName("Some-Name"); var value = "some value"; var commitMessageFooter = new CommitMessageFooter(name, value); // ACT var sut = ChangeLogEntryFooter.FromCommitMessageFooter(commitMessageFooter); // ASSERT Assert.Equal(name, sut.Name); Assert.Equal(value, sut.Value); }
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); }
[InlineData("footerName", "FOOTERNAME")] // Scope must be compared case-insensitive public void GetFooterDisplayName_returns_expected_display_name(string configuredFooter, string footerName) { // ARRANGE var configuration = new ChangeLogConfiguration() { Footers = new[] { new ChangeLogConfiguration.FooterConfiguration() { Name = configuredFooter, DisplayName = "Footer Display Name" } } }; var footer = new ChangeLogEntryFooter(new CommitMessageFooterName(footerName), "Irrelevant"); // ACT var displayName = footer.GetFooterDisplayName(configuration); // ASSERT Assert.Equal("Footer Display Name", displayName); }
[InlineData("footerName", "FOOTERNAME")] // Scope must be compared case-insensitive public void GetFooterDisplayName_returns_expected_display_name(string configuredFooter, string footerName) { // ARRANGE var configuration = new ChangeLogConfiguration() { Footers = new Dictionary <string, ChangeLogConfiguration.FooterConfiguration>() { { configuredFooter, new ChangeLogConfiguration.FooterConfiguration() { DisplayName = "Footer Display Name" } } } }; var footer = new ChangeLogEntryFooter(new CommitMessageFooterName(footerName), new PlainTextElement("Irrelevant")); // ACT var displayName = footer.GetFooterDisplayName(configuration); // ASSERT Assert.Equal("Footer Display Name", displayName); }
public void GetFooterDisplayName_returns_footer_name_if_display_name_is_empty(string configuredDisplayName) { // ARRANGE var footerName = "footerName"; var configuration = new ChangeLogConfiguration() { Footers = new[] { new ChangeLogConfiguration.FooterConfiguration() { Name = footerName, DisplayName = configuredDisplayName } } }; var footer = new ChangeLogEntryFooter(new CommitMessageFooterName(footerName), "Irrelevant"); // ACT var displayName = footer.GetFooterDisplayName(configuration); // ASSERT Assert.Equal(footerName, displayName); }
public void GetFooterDisplayName_returns_footer_name_if_no_display_name_is_configured() { // ARRANGE var footerName = "footerName"; var configuration = new ChangeLogConfiguration() { Footers = new Dictionary <string, ChangeLogConfiguration.FooterConfiguration>() { { "someOtherFooter", new ChangeLogConfiguration.FooterConfiguration() { DisplayName = "Footer Display Name" } } } }; var footer = new ChangeLogEntryFooter(new CommitMessageFooterName(footerName), new PlainTextElement("Irrelevant")); // ACT var displayName = footer.GetFooterDisplayName(configuration); // ASSERT Assert.Equal(footerName, displayName); }
public ChangeLogEntryFooterViewModel(ChangeLogConfiguration configuration, ChangeLogEntryFooter model) { m_Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); m_Model = model ?? throw new ArgumentNullException(nameof(model)); }
internal XunitSerializableChangeLogEntryFooter(ChangeLogEntryFooter value) => Value = value;