using Explorer.Application; namespace Explorer.Application.Tests; public class MarkdownParserTests { [Fact] public void Parses_headings_lists_and_tables() { var doc = MarkdownParser.Parse(""" # Title Intro paragraph. ## Locations - One - Two | A | B | | --- | --- | | 1 | 2 | """); Assert.Contains(doc.Blocks, b => b is MarkdownHeading h && h.Level == 1 && h.Text == "Title"); Assert.Equal("Locations", Assert.Single(doc.Headings).Text); var list = Assert.IsType(doc.Blocks.First(b => b is MarkdownList)); Assert.Equal(["One", "Two"], list.Items); var table = Assert.IsType(doc.Blocks.First(b => b is MarkdownTable)); Assert.Equal(["A", "B"], table.Headers); Assert.Equal(["1", "2"], Assert.Single(table.Rows)); } [Fact] public void Parses_fenced_code() { var doc = MarkdownParser.Parse(""" ```powershell dotnet build ``` """); var code = Assert.IsType(Assert.Single(doc.Blocks)); Assert.Equal("powershell", code.Language); Assert.Equal("dotnet build", code.Text); } [Fact] public void User_guide_in_the_repo_parses() { var dir = new DirectoryInfo(AppContext.BaseDirectory); string? path = null; while (dir is not null) { var candidate = Path.Combine(dir.FullName, "docs", "Documentation.md"); if (File.Exists(candidate)) { path = candidate; break; } dir = dir.Parent; } Assert.NotNull(path); var doc = MarkdownParser.Parse(File.ReadAllText(path)); Assert.Contains(doc.Headings, h => h.Text == "Locations"); Assert.Contains(doc.Headings, h => h.Text == "File Operations Queue"); Assert.Contains(doc.Blocks, b => b is MarkdownTable); } }