Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrofigo committed Sep 5, 2023
1 parent a44b4d6 commit 9cb5515
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions source/Nuke.Common.Tests/ChangelogTasksTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,43 @@ public void ReadChangelog_EmptyChangelogFile_ThrowsInformativeException(string f

act.Should().Throw<Exception>().WithMessage("Changelog should have at least one release note section");
}

[Theory]
[InlineData("changelog_reference_1.0.0_variant_1.md", "1.4.0")]
[InlineData("changelog_reference_1.0.0_variant_2.md", "1.0.0")]
[InlineData("changelog_reference_1.0.0_variant_3.md", "1.4.0")]
[InlineData("changelog_reference_1.0.0_variant_5.md", "0.2.3")]
[InlineData("changelog_reference_NUKE_variant_1.md", "1.2.3")]
[InlineData("changelog_reference_NUKE_variant_2.md", "1.0.0")]
public void ReadChangelogLatestVersion_ValidChangelogFile_ReturnsLatestVersion(string fileName, string latestVersion)
{
var file = PathToChangelogReferenceFiles / fileName;

ChangelogTasks.ReadChangelog(file).LatestVersion.ToNormalizedString().Should().Be(latestVersion);
}

[Theory]
[InlineData("changelog_reference_1.0.0_variant_1.md")]
[InlineData("changelog_reference_1.0.0_variant_2.md")]
[InlineData("changelog_reference_1.0.0_variant_3.md")]
[InlineData("changelog_reference_1.0.0_variant_5.md")]
[InlineData("changelog_reference_NUKE_variant_1.md")]
[InlineData("changelog_reference_NUKE_variant_2.md")]
public void ReadChangelogLatestVersion_ValidChangelogFile_ReturnsAVersion(string fileName)
{
var file = PathToChangelogReferenceFiles / fileName;

ChangelogTasks.ReadChangelog(file).LatestVersion.Should().NotBeNull();
}

[Theory]
[InlineData("changelog_reference_1.0.0_variant_4.md")]
public void ReadChangelogLatestVersion_ValidChangelogFileButNoReleaseSection_ReturnsNull(string fileName)
{
var file = PathToChangelogReferenceFiles / fileName;

ChangelogTasks.ReadChangelog(file).LatestVersion.Should().BeNull();
}

[UsedImplicitly]
public static IEnumerable<object[]> AllChangelogReference_1_0_0_Files
Expand Down

0 comments on commit 9cb5515

Please sign in to comment.