public void NoRelease() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); _tempFile = Path.GetTempFileName(); sut.ChangelogFile = _tempFile; File.WriteAllText(_tempFile, @" # Change Log All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). <!-- Available types of changes: ### Added ### Changed ### Fixed ### Deprecated ### Removed ### Security -->"); // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.False); }
public void UrlInChangeLog() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); _tempFile = Path.GetTempFileName(); sut.ChangelogFile = _tempFile; File.WriteAllText(_tempFile, @" # Change Log ## [Unreleased] ### Changed - This is a unit test [Unreleased]: https://example.com "); // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.True); Assert.That(sut.Value, Is.EqualTo(@"Changed: - This is a unit test ")); }
public void AppendToReleaseNotesProperty() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); sut.AppendToReleaseNotesProperty = @" See full changelog at github."; _tempFile = Path.GetTempFileName(); sut.ChangelogFile = _tempFile; File.WriteAllText(_tempFile, @" # Change Log ## [Unreleased] ### Changed: - This is a unit test"); // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.True); Assert.That(sut.Value, Is.EqualTo(@"Changed: - This is a unit test See full changelog at github. ")); }
public void EmptyUnreleasedWithPreviousRelease() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); _tempFile = Path.GetTempFileName(); sut.ChangelogFile = _tempFile; File.WriteAllText(_tempFile, @" # Change Log ## [Unreleased] ## [1.0] - 2018-06-18 ### Changed - This is a unit test "); // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.True); Assert.That(sut.Value, Is.EqualTo(@"Changed: - This is a unit test ")); }
public void FilterEntriesTrueMyProject1_LongLines() { // Setup _tempFile = Path.GetTempFileName(); var sut = new SetReleaseNotesProperty { BuildEngine = new MockEngine(), ChangelogFile = _tempFile, PackageId = "MyProject1", FilterEntries = true }; File.WriteAllText(_tempFile, @" # Change Log ## [Unreleased] ## [2.4.0] - 2021-01-22 ### Added - [MyProject1] Add 'DoSomething()' method to 'Foo' continued on second line - 'ReadMe.md' Lorem ipsum also continued ### Fixed - [Some.OtherProject] Fix crash in 'Foobar' other project continued - [MyProject1] Fixed 'Something()' something continued ## [2.3.0] "); // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.True); Assert.That(sut.Value, Is.EqualTo(@"Changes since version 2.3.0 Added: - Add 'DoSomething()' method to 'Foo' continued on second line - 'ReadMe.md' Lorem ipsum also continued Fixed: - Fixed 'Something()' something continued ")); }
public void ChangelogFileDoesntExist() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); _tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); sut.ChangelogFile = _tempFile; // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.False); }
public void FilterEntriesWithoutPackage() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); _tempFile = Path.GetTempFileName(); sut.FilterEntries = true; sut.PackageId = "AnotherProject"; sut.ChangelogFile = _tempFile; File.WriteAllText(_tempFile, @" # Change Log ## [Unreleased] ## [2.4.0] - 2021-01-22 ### Added - Add 'DoSomething()' method to 'Foo' ### Fixed - Fix crash in 'Foobar' - 'ReadMe.md' Lorem ipsum ## [2.3.0] "); // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.True); Assert.That(sut.Value, Is.EqualTo(@"Changes since version 2.3.0 Added: - Add 'DoSomething()' method to 'Foo' Fixed: - Fix crash in 'Foobar' - 'ReadMe.md' Lorem ipsum ")); }
public void FilterEntries_UnreleasedUnfilteredWithComment() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); _tempFile = Path.GetTempFileName(); sut.FilterEntries = false; sut.PackageId = "MyProject1"; sut.ChangelogFile = _tempFile; File.WriteAllText(_tempFile, @" # Change Log <!-- comment --> ## [Unreleased] ### Added - [MyProject1] Add 'DoSomething()' method to 'Foo' - 'ReadMe.md' Lorem ipsum ## [2.4.0] - 2021-01-22 "); // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.True); Assert.That(sut.Value, Is.EqualTo(@"Changes since version 2.4.0 Added: - [MyProject1] Add 'DoSomething()' method to 'Foo' - 'ReadMe.md' Lorem ipsum ")); }
public void CustomVersionRegex() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); sut.VersionRegex = @"#+ @d+-@d+-@d+ @@[a-z]+ @(([^)]+)@)|## Unreleased"; _tempFile = Path.GetTempFileName(); File.WriteAllText(_tempFile, @" # Change Log ## Unreleased ### Changed: - This is a unit test ## 2018-07-02 @foo (5.0) ### Added - added unit test"); sut.ChangelogFile = _tempFile; // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.True); Assert.That(sut.Value, Is.EqualTo(@"Changes since version 5.0 Changed: - This is a unit test ")); }
public void ReleaseWithMultipleSubheadings() { // Setup var sut = new SetReleaseNotesProperty(); sut.BuildEngine = new MockEngine(); _tempFile = Path.GetTempFileName(); File.WriteAllText(_tempFile, @" # Change Log ## [1.0] - 2018-06-18 ### Changed - This is a unit test ### Added - added unit test "); sut.ChangelogFile = _tempFile; // Exercise var result = sut.Execute(); // Verify Assert.That(result, Is.True); Assert.That(sut.Value, Is.EqualTo(@"Changed: - This is a unit test Added: - added unit test ")); }