public void ParseLink_should_return_RemoteLink_when_url_starts_with_www() { var linkInline = new LinkInline("www.google.com", "Title"); var link = SimplifiedMarkdownDoc.ParseLink(linkInline); Assert.IsInstanceOf <RemoteLink>(link); }
public void ParseLink_should_return_LocalLink_when_not_a_remote_url() { var linkInline = new LinkInline("../README.md", "Title"); var link = SimplifiedMarkdownDoc.ParseLink(linkInline); Assert.IsInstanceOf <LocalLink>(link); }
public void SetupDocumentCorpus() { // Move to a temp directory tempDirectory = Path.Combine(Path.GetTempPath(), "linter-docs-tests"); Directory.CreateDirectory(tempDirectory); currentDirectory = Environment.CurrentDirectory; Environment.CurrentDirectory = tempDirectory; // Create a non-markdown file for testing purposes Directory.CreateDirectory("test"); var fs = File.Create("test/image.png"); fs.Close(); // Create other markdown file with a heading var otherMarkdownDocPath = Path.GetFullPath(Path.Combine(tempDirectory, "test/test.md")); var otherMarkdownDoc = new SimplifiedMarkdownDoc(); otherMarkdownDoc.Headings.Add(new Heading("#test-heading")); corpus.Add(otherMarkdownDocPath, otherMarkdownDoc); // Create markdown file that would have links to be used in testing. markdownDocToTestPath = Path.GetFullPath(Path.Combine(tempDirectory, "links.md")); markdownDocToTest = new SimplifiedMarkdownDoc(); markdownDocToTest.Headings.Add(new Heading("#local-heading")); corpus.Add(markdownDocToTestPath, markdownDocToTest); // Create same file links sameFileHeadingExistsLink = new LocalLink(new LinkInline("#local-heading", string.Empty)); sameFileHeadingDoesNotExistLink = new LocalLink(new LinkInline("#incorrect-local-heading", string.Empty)); // Create other file links (no heading) otherFileExistsLink = new LocalLink(new LinkInline("test/image.png", string.Empty)); otherFileDoesNotExistLink = new LocalLink(new LinkInline("test/no-image.png", string.Empty)); // Create other directory links. otherDirectoryExistsLink = new LocalLink(new LinkInline("test/", string.Empty)); otherDirectoryDoesNotExistLink = new LocalLink(new LinkInline("no-test/", string.Empty)); // Create other file links with heading otherFileHeadingExistsLink = new LocalLink(new LinkInline("test/test.md#test-heading", string.Empty)); otherFileHeadingDoesNotExistLink = new LocalLink(new LinkInline("test/test.md#no-heading", string.Empty)); }