@@ -162,14 +162,14 @@ public void RendererTests_MarkedTest(bool useCrazy)
162162 [ DataRow ( false ) ]
163163 [ DataRow ( true ) ]
164164 public void RendererTests_HeaderTest ( bool useCrazy )
165- // The default DisplayOptions configures H1 as a centered FigletTextStyle, so H1's
166- // literal text ("Level One") is replaced by FIGlet ASCII art and is not asserted
167- // here. H2 and H3 still fall through to the default Header style.
165+ // The default DisplayOptions configures H1 as a FigletTextStyle, so H1's literal
166+ // text ("Level One") is replaced by FIGlet ASCII art and is not asserted here.
167+ // H2 and H3 still fall through to the default Header style.
168168 => AssertMarkdownYieldsFormat (
169169 "headingBlock" ,
170170 text : useCrazy
171- ? "Level Two Level Three"
172- : "## Level Two ## ### Level Three ###" ,
171+ ? "Level Two with here Level Three with bold word "
172+ : "## Level Two with code here ## ### Level Three with bold word ###" ,
173173 new Style ( decoration : Decoration . Bold | Decoration . Invert | Decoration . Underline ) ,
174174 useCrazy ) ;
175175
@@ -245,9 +245,9 @@ public void RendererTests_FigletHeaderOnlyAppliesToConfiguredLevel()
245245 Assert . DoesNotContain ( "Level One" , output ,
246246 $ "H1 should be FIGlet rendered:\n { output } ") ;
247247 // H2 and H3 should still be rendered as styled markup wrapped in '#'s.
248- Assert . Contains ( "## Level Two ##" , output ,
248+ Assert . Contains ( "## Level Two with code here ##" , output ,
249249 $ "H2 should remain styled with '##' wrapping:\n { output } ") ;
250- Assert . Contains ( "### Level Three ###" , output ,
250+ Assert . Contains ( "### Level Three with bold word ###" , output ,
251251 $ "H3 should remain styled with '###' wrapping:\n { output } ") ;
252252 }
253253
@@ -264,9 +264,56 @@ public void RendererTests_FigletDefaultCanBeOverriddenWithTextStyle()
264264 ConsoleUnderTest . Write ( Renderer ( GetResourceContent ( "headingBlock" , "md" ) , options ) ) ;
265265
266266 var output = ConsoleUnderTest . Output ;
267- Assert . Contains ( "# Level One #" , output , $ "H1 should be wrapped with '#':\n { output } ") ;
268- Assert . Contains ( "## Level Two ##" , output , $ "H2 should be wrapped with '##':\n { output } ") ;
269- Assert . Contains ( "### Level Three ###" , output , $ "H3 should be wrapped with '###':\n { output } ") ;
267+ Assert . Contains ( "# Level One #" , output , $ "H1 should be wrapped with '#':\n { output } ") ;
268+ Assert . Contains ( "## Level Two with code here ##" , output , $ "H2 should be wrapped with '##':\n { output } ") ;
269+ Assert . Contains ( "### Level Three with bold word ###" , output , $ "H3 should be wrapped with '###':\n { output } ") ;
270+ }
271+
272+ [ TestMethod ]
273+ public void RendererTests_FigletEmptyHeadingFallsBackToStyledMarkup ( )
274+ {
275+ // FigletText cannot render an empty string. When the heading has no text the
276+ // renderer should fall through to the styled-markup path so the level marker
277+ // (e.g. "# #" with WrapHeader=true) is still emitted.
278+ DisplayOptions options = new ( ) ;
279+ // Sanity check: H1 is configured to use FIGlet by default.
280+ Assert . IsInstanceOfType < FigletTextStyle > ( options . EffectiveHeader ( 1 ) ) ;
281+
282+ ConsoleUnderTest . Write ( Renderer ( "#\n " , options ) ) ;
283+
284+ var output = ConsoleUnderTest . Output ;
285+ Assert . Contains ( "#" , output ,
286+ $ "Empty H1 should fall back to styled '#'-wrapped markup:\n { output } ") ;
287+ }
288+
289+ [ TestMethod ]
290+ public void RendererTests_FigletFontPathLoadsCustomFont ( )
291+ {
292+ // When FontPath is set the renderer should load the custom .flf font and use it
293+ // to render the FIGlet text. Compare the output against the default font to make
294+ // sure something actually changed.
295+ const string markdown = "# Hi\n " ;
296+ var defaultOptions = new DisplayOptions ( ) ;
297+ ConsoleUnderTest . Write ( Renderer ( markdown , defaultOptions ) ) ;
298+ var defaultOutput = ConsoleUnderTest . Output ;
299+
300+ NewConsole ( ) ;
301+
302+ var fontPath = Path . Combine ( DataPath , "fonts" , "shadow.flf" ) ;
303+ Assert . IsTrue ( File . Exists ( fontPath ) , $ "Test font file should exist at { fontPath } ") ;
304+
305+ var customOptions = new DisplayOptions
306+ {
307+ Headers = new ( ) { new FigletTextStyle ( fontPath : fontPath ) } ,
308+ } ;
309+ ConsoleUnderTest . Write ( Renderer ( markdown , customOptions ) ) ;
310+ var customOutput = ConsoleUnderTest . Output ;
311+
312+ Assert . AreNotEqual ( defaultOutput , customOutput ,
313+ $ "FIGlet output should differ when a custom FontPath is supplied.\n Default:\n { defaultOutput } \n Custom:\n { customOutput } ") ;
314+ // FIGlet output should still contain ASCII-art glyph characters.
315+ Assert . IsTrue ( customOutput . Contains ( '|' ) || customOutput . Contains ( '\\ ' ) ,
316+ $ "Expected FIGlet glyph characters in custom-font output:\n { customOutput } ") ;
270317 }
271318
272319 [ TestMethod ]
0 commit comments