Example #1
0
        public void HtmlWithReleaseNotesElementWithContentsIsChanged()
        {
            var testMarkdown = new CreateReleaseNotesHtml();

            using (
                var filesForTest = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".Test.md"),
                                                           Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".Test.htm")))
            {
                var ChangelogFile = filesForTest.FirstFile;
                var htmlFile      = filesForTest.SecondFile;
                File.WriteAllLines(ChangelogFile,
                                   new[]
                                   { "## 2.3.9", "* with some random content", "* does some things", "## 2.3.7", "* more", "## 2.2.2", "* things" });
                File.WriteAllLines(htmlFile,
                                   new[]
                {
                    "<html>", "<body>", "<div class='releasenotes'>", "<span class='note'/>", "</div>",
                    "</body>", "</html>"
                });
                testMarkdown.ChangelogFile = ChangelogFile;
                testMarkdown.HtmlFile      = htmlFile;
                Assert.That(testMarkdown.Execute(), Is.True);
                AssertThatXmlIn.File(htmlFile).HasNoMatchForXpath("//span[@class='note']");
                AssertThatXmlIn.File(htmlFile).HasSpecifiedNumberOfMatchesForXpath("//*[@class='releasenotes']", 1);
            }
        }
        public void UpdateDebianChangelogWorks()
        {
            var testMarkdown = new CreateChangelogEntry();

            using (var tempFiles = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), "Test.md"),
                                                           Path.Combine(Path.GetTempPath(), "changelog")))
            {
                var mdFile        = tempFiles.FirstFile;
                var changeLogFile = tempFiles.SecondFile;
                File.WriteAllLines(mdFile, new[] { "## 2.3.10: 4/Sep/2014", "* with some random content", "* does some things" });
                File.WriteAllLines(changeLogFile, new[]
                {
                    "myfavoriteapp (2.1.0~alpha1) unstable; urgency=low", "", "  * Initial Release for Linux.", "",
                    " -- Stephen McConnel <*****@*****.**>  Fri, 12 Jul 2013 14:57:59 -0500", ""
                });
                testMarkdown.ChangelogFile       = mdFile;
                testMarkdown.VersionNumber       = "2.3.11";
                testMarkdown.ProductName         = "myfavoriteapp";
                testMarkdown.ChangelogAuthorInfo = "Steve McConnel <*****@*****.**>";
                testMarkdown.DebianChangelog     = changeLogFile;
                Assert.That(testMarkdown.Execute(), Is.True);
                var newContents = File.ReadAllLines(changeLogFile);
                Assert.AreEqual(newContents.Length, 13, "New changelog entry was not the expected length");
                Assert.That(newContents[0], Does.StartWith("myfavoriteapp (2.3.11) unstable; urgency=low"));
                //Make sure that the author line matches debian standards for time offset and spacing around author name
                Assert.That(newContents[5], Does.Match(" -- " + testMarkdown.ChangelogAuthorInfo + "  .*[+-]\\d\\d\\d\\d"));
            }
        }
        public void UpdateDebianChangelogWorks()
        {
            // Setup
            var sut = new CreateChangelogEntry();

            using (var tempFiles = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), "Test.md"),
                                                           Path.Combine(Path.GetTempPath(), "changelog")))
            {
                var mdFile        = tempFiles.FirstFile;
                var changeLogFile = tempFiles.SecondFile;
                File.WriteAllLines(mdFile, new[] { "## 2.3.10: 4/Sep/2014", "* with some random content", "* does some things" });
                File.WriteAllLines(changeLogFile, new[]
                {
                    "myfavoriteapp (2.1.0~alpha1) unstable; urgency=low", "", "  * Initial Release for Linux.", "",
                    " -- Stephen McConnel <*****@*****.**>  Fri, 12 Jul 2013 14:57:59 -0500", ""
                });
                sut.ChangelogFile   = mdFile;
                sut.VersionNumber   = "2.3.11";
                sut.PackageName     = "myfavoriteapp";
                sut.MaintainerInfo  = "Steve McConnel <*****@*****.**>";
                sut.DebianChangelog = changeLogFile;
                sut.Distribution    = "unstable";
                string expectedDebianChangelog =
                    @"myfavoriteapp (2.3.11) unstable; urgency=low

  * with some random content
  * does some things

 -- Steve McConnel <*****@*****.**>  DATE_NOW

myfavoriteapp (2.1.0~alpha1) unstable; urgency=low

  * Initial Release for Linux.

 -- Stephen McConnel <*****@*****.**>  Fri, 12 Jul 2013 14:57:59 -0500
";
                expectedDebianChangelog = expectedDebianChangelog.Replace("DATE_NOW", CreateChangelogEntry.DebianDate(sut.EntryDate));

                // Execute
                Assert.That(sut.Execute(), Is.True);

                // Verify
                var    newContents     = File.ReadAllLines(changeLogFile);
                string newContentsText = string.Join(Environment.NewLine, newContents);
                Assert.That(newContentsText, Is.EqualTo(expectedDebianChangelog));
                // Make sure that the author line matches debian standards for time offset and spacing around author name
                Assert.That(newContents[5], Does.Match(" -- " + sut.MaintainerInfo + "  .*[+-]\\d\\d\\d\\d"));
            }
        }
Example #4
0
        public void SimpleMdResultsInSimpleHtml()
        {
            var testMarkdown = new CreateReleaseNotesHtml();

            using (
                var filesForTest = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".Test.md"),
                                                           Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".Test.htm")))
            {
                File.WriteAllLines(filesForTest.FirstFile,
                                   new[]
                                   { "## 2.3.9", "* with some random content", "* does some things", "## 2.3.7", "* more", "## 2.2.2", "* things" });
                testMarkdown.ChangelogFile = filesForTest.FirstFile;
                testMarkdown.HtmlFile      = filesForTest.SecondFile;
                Assert.That(testMarkdown.Execute(), Is.True);
            }
        }
        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 UpdateDebianChangelogAllMdListItemsWork()
        {
            // Setup
            var sut = new CreateChangelogEntry();

            using (var tempFiles = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), "Test.md"),
                                                           Path.Combine(Path.GetTempPath(), "changelog")))
            {
                var ChangelogFile = tempFiles.FirstFile;
                File.WriteAllLines(ChangelogFile, new[]
                {
                    "## 3.0.97 Beta",
                    "- Update French UI Translation",
                    "+ When importing, Bloom no longer",
                    "  1. makes images transparent when importing.",
                    "  4. compresses images transparent when importing.",
                    "  9. saves copyright/license back to the original files",
                    "    * extra indented list",
                    "* Fix insertion of unwanted space before bolded, underlined, and italicized portions of words",
                });
                var debianChangelog = tempFiles.SecondFile;
                File.WriteAllLines(debianChangelog, new[]
                {
                    "Bloom (3.0.82 Beta) unstable; urgency=low", "", "  * Older release", "",
                    " -- Stephen McConnel <*****@*****.**>  Fri, 12 Jul 2014 14:57:59 -0500", ""
                });
                sut.ChangelogFile   = ChangelogFile;
                sut.VersionNumber   = "3.0.97 Beta";
                sut.PackageName     = "myfavoriteapp";
                sut.MaintainerInfo  = "John Hatton <*****@*****.**>";
                sut.DebianChangelog = debianChangelog;

                // Execute
                Assert.That(sut.Execute(), Is.True);

                // Verify
                var newContents = File.ReadAllLines(debianChangelog);
                Assert.That(newContents[0], Does.Contain("3.0.97 Beta"));
                Assert.That(newContents[2], Does.StartWith("  *"));
                Assert.That(newContents[3], Does.StartWith("  *"));
                Assert.That(newContents[4], Does.StartWith("    *"));
                Assert.That(newContents[5], Does.StartWith("    *"));
                Assert.That(newContents[6], Does.StartWith("    *"));
                Assert.That(newContents[7], Does.StartWith("    *"));                 // The 3rd (and further) level indentation isn't currently supported
                Assert.That(newContents[8], Does.StartWith("  *"));
            }
        }
        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));
            }
        }
Example #8
0
        public void HtmlWithNoReleaseNotesElementIsCompletelyReplaced()
        {
            var testMarkdown = new CreateReleaseNotesHtml();

            using (
                var filesForTest = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".Test.md"),
                                                           Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".Test.htm")))
            {
                var ChangelogFile = filesForTest.FirstFile;
                var htmlFile      = filesForTest.SecondFile;
                File.WriteAllLines(ChangelogFile,
                                   new[]
                                   { "## 2.3.9", "* with some random content", "* does some things", "## 2.3.7", "* more", "## 2.2.2", "* things" });
                File.WriteAllLines(htmlFile,
                                   new[] { "<html>", "<body>", "<div class='notmarkdown'/>", "</body>", "</html>" });
                testMarkdown.ChangelogFile = ChangelogFile;
                testMarkdown.HtmlFile      = htmlFile;
                Assert.That(testMarkdown.Execute(), Is.True);
                AssertThatXmlIn.File(htmlFile).HasNoMatchForXpath("//div[@notmarkdown]");
            }
        }
Example #9
0
        public void RemovesKACHead()
        {
            var testMarkdown = new CreateReleaseNotesHtml();

            using (
                var filesForTest = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".Test.md"),
                                                           Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".Test.htm")))
            {
                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]

## [2.3.4] - 2020-12-09

### Changed
- This to that.

## [1.2.3] - 2020-12-08

### Added
- New features.

### Fixed
- All bugs.";

                string expectedHtml =
                    @"<html><head></head><body><div class='releasenotes'>
<h2>[2.3.4] - 2020-12-09</h2>
<h3>Changed</h3>
<ul>
<li>This to that.</li>
</ul>
<h2>[1.2.3] - 2020-12-08</h2>
<h3>Added</h3>
<ul>
<li>New features.</li>
</ul>
<h3>Fixed</h3>
<ul>
<li>All bugs.</li>
</ul>
</div></body></html>";

                File.WriteAllText(filesForTest.FirstFile, changelogContent);
                testMarkdown.ChangelogFile = filesForTest.FirstFile;
                testMarkdown.HtmlFile      = filesForTest.SecondFile;
                // SUT
                Assert.That(testMarkdown.Execute(), Is.True);
                string actualHtml = File.ReadAllText(filesForTest.SecondFile);
                Assert.That(actualHtml, Is.EqualTo(expectedHtml));
            }
        }
        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));
            }
        }