public void SimpleMdResultsInSimpleHtml() { var testMarkdown = new GenerateReleaseArtifacts(); 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.MarkdownFile = filesForTest.FirstFile; testMarkdown.HtmlFile = filesForTest.SecondFile; Assert.That(testMarkdown.CreateHtmFromMarkdownFile(), Is.True); } }
public void HtmlWithReleaseNotesElementWithContentsIsChanged() { var testMarkdown = new GenerateReleaseArtifacts(); using( var filesForTest = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()+".Test.md"), Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()+".Test.htm"))) { var markdownFile = filesForTest.FirstFile; var htmlFile = filesForTest.SecondFile; File.WriteAllLines(markdownFile, 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.MarkdownFile = markdownFile; testMarkdown.HtmlFile = htmlFile; Assert.That(testMarkdown.CreateHtmFromMarkdownFile(), Is.True); AssertThatXmlIn.File(htmlFile).HasNoMatchForXpath("//span[@class='note']"); AssertThatXmlIn.File(htmlFile).HasSpecifiedNumberOfMatchesForXpath("//*[@class='releasenotes']", 1); } }
public void MissingMarkdownReturnsFalse() { var mockEngine = new MockEngine(); var testMarkdown = new GenerateReleaseArtifacts(); testMarkdown.MarkdownFile = Path.GetRandomFileName(); testMarkdown.BuildEngine = mockEngine; Assert.That(testMarkdown.CreateHtmFromMarkdownFile(), Is.False); Assert.That(mockEngine.LoggedMessages[0], Is.StringMatching("The given markdown file .* does not exist\\.")); }
public void HtmlWithNoReleaseNotesElementIsCompletelyReplaced() { var testMarkdown = new GenerateReleaseArtifacts(); using( var filesForTest = new TwoTempFilesForTest(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()+".Test.md"), Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()+".Test.htm"))) { var markdownFile = filesForTest.FirstFile; var htmlFile = filesForTest.SecondFile; File.WriteAllLines(markdownFile, 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.MarkdownFile = markdownFile; testMarkdown.HtmlFile = htmlFile; Assert.That(testMarkdown.CreateHtmFromMarkdownFile(), Is.True); AssertThatXmlIn.File(htmlFile).HasNoMatchForXpath("//div[@notmarkdown]"); } }