コード例 #1
0
        public void StampMarkdownWorksWithDefault()
        {
            var testMarkdown = new StampChangelogFileWithVersion();

            using (var tempFiles = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), "Test.md"), null))
            {
                File.WriteAllLines(tempFiles.FirstFile,
                                   new[] { "## DEV_VERSION_NUMBER: DEV_RELEASE_DATE", "*with some random content", "*does some things" });
                testMarkdown.ChangelogFile = tempFiles.FirstFile;
                testMarkdown.VersionNumber = "2.3.10";
                Assert.That(testMarkdown.Execute(), Is.True);
                var newContents = File.ReadAllLines(tempFiles.FirstFile);
                Assert.That(newContents.Length == 3);
                Assert.That(newContents[0], Is.EqualTo($"## 2.3.10 {DateTime.Now:yyyy-MM-dd}"));
            }
        }
        public void StampMarkdownDoesNothingWhenTold()
        {
            var testMarkdown = new StampChangelogFileWithVersion();

            using (var tempFiles = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), "Test.md"), null))
            {
                var devVersionLine = "## DEV_VERSION_NUMBER: DEV_RELEASE_DATE";
                File.WriteAllLines(tempFiles.FirstFile,
                                   new[] { devVersionLine, "*with some random content", "*does some things" });
                testMarkdown.ChangelogFile      = tempFiles.FirstFile;
                testMarkdown.VersionNumber      = "2.3.10";
                testMarkdown.StampChangelogFile = false;
                Assert.That(testMarkdown.Execute(), Is.True);
                var newContents = File.ReadAllLines(tempFiles.FirstFile);
                Assert.That(newContents.Length == 3);
                Assert.That(newContents[0], Is.EqualTo(devVersionLine));
            }
        }
コード例 #3
0
        public void ProcessesKeepAChangelogFormat()
        {
            var testMarkdown = new StampChangelogFileWithVersion();

            using (var tempFiles = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), "CHANGELOG.md"), null))
            {
                string changelogContent =
                    @"# 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
-->

## [Unreleased]

### Changed
- This to that.

## [1.2.3] - 2020-12-08

### Added
- New features.

### Fixed
- All bugs.
";

                string expectedNewChangelogContent =
                    @"# 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
-->

## [Unreleased]

## [2.3.10] - DATE_HERE

### Changed
- This to that.

## [1.2.3] - 2020-12-08

### Added
- New features.

### Fixed
- All bugs.
";
                expectedNewChangelogContent = expectedNewChangelogContent.Replace("DATE_HERE", DateTime.Today.ToString("yyyy-MM-dd"));
                File.WriteAllText(tempFiles.FirstFile, changelogContent);
                testMarkdown.ChangelogFile = tempFiles.FirstFile;
                testMarkdown.VersionNumber = "2.3.10";
                // SUT
                Assert.That(testMarkdown.Execute(), Is.True);
                var newContents = File.ReadAllText(tempFiles.FirstFile);
                Assert.That(newContents, Is.EqualTo(expectedNewChangelogContent));
            }
        }