@@ -58,7 +58,7 @@ public void RendererTests_TextValidation()
5858 }
5959
6060 var pipeline = Displayer . DefaultPipeline ;
61- var renderer = new ConsoleRenderer ( includeDebug : true ) ;
61+ var renderer = new ConsoleRenderer ( new DisplayOptions ( ) { IncludeDebug = true } ) ;
6262
6363 foreach ( var markdown in markdowns )
6464 {
@@ -76,9 +76,13 @@ public void RendererTests_TextValidation()
7676 }
7777 }
7878
79- [ TestMethod ]
80- public void RendererTests_CodeInlineTest ( )
81- => AssertMarkdownYieldsFormat ( "codeInline" , "in line code" , new Style ( foreground : Color . Yellow , background : Color . Blue ) ) ;
79+ [ DataTestMethod ]
80+ [ DataRow ( false ) ]
81+ [ DataRow ( true ) ]
82+ public void RendererTests_CodeInlineTest ( bool useCrazy )
83+ {
84+ AssertMarkdownYieldsFormat ( "codeInline" , "in line code" , new Style ( foreground : Color . Yellow , background : Color . Blue ) , useCrazy ) ;
85+ }
8286
8387 [ DataTestMethod ]
8488 [ DataRow ( "bold" , Decoration . Bold ) ]
@@ -87,25 +91,40 @@ public void RendererTests_CodeInlineTest()
8791 [ DataRow ( "subscript" , Decoration . SlowBlink ) ]
8892 [ DataRow ( "superscript" , Decoration . RapidBlink ) ]
8993 [ DataRow ( "inserted" , Decoration . Underline ) ]
90- public void RendererTests_EmphasisInlineTest ( string text , Decoration decoration )
91- => AssertMarkdownYieldsFormat ( "emphasisInline" , text , new Style ( decoration : decoration ) ) ;
94+ public void RendererTests_EmphasisInlineTest ( string text , Decoration decoration )
95+ {
96+ AssertMarkdownYieldsFormat ( "emphasisInline" , text , new Style ( decoration : decoration ) , useCrazy : false ) ;
97+ AssertMarkdownYieldsFormat ( "emphasisInline" , text , new Style ( decoration : decoration ) , useCrazy : true ) ;
98+ }
9299
93- [ TestMethod ]
94- public void RendererTests_MarkedTest ( )
95- => AssertMarkdownYieldsFormat ( "emphasisInline" , "marked" , new Style ( foreground : Color . Black , background : Color . Yellow ) ) ;
100+ [ DataTestMethod ]
101+ [ DataRow ( false ) ]
102+ [ DataRow ( true ) ]
103+ public void RendererTests_MarkedTest ( bool useCrazy )
104+ {
105+ AssertMarkdownYieldsFormat ( "emphasisInline" , "marked" , new Style ( foreground : Color . Black , background : Color . Yellow ) , useCrazy ) ;
106+ }
96107
97- [ TestMethod ]
98- public void RendererTests_HeaderTest ( )
108+ [ DataTestMethod ]
109+ [ DataRow ( false ) ]
110+ [ DataRow ( true ) ]
111+ public void RendererTests_HeaderTest ( bool useCrazy )
99112 => AssertMarkdownYieldsFormat (
100113 "headingBlock" ,
101- "# Level One # ## Level Two ## ### Level Three ###" ,
102- new Style ( decoration : Decoration . Bold | Decoration . Invert | Decoration . Underline ) ) ;
114+ text : useCrazy
115+ ? "Level One Level Two Level Three"
116+ : "# Level One # ## Level Two ## ### Level Three ###" ,
117+ new Style ( decoration : Decoration . Bold | Decoration . Invert | Decoration . Underline ) ,
118+ useCrazy ) ;
103119
104120 [ DataTestMethod ]
105121 [ DataRow ( "htmlBlock" , "<table> <tr> <td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td> </tr> </table>" ) ]
106122 [ DataRow ( "htmlInline" , "<span>html</span>" ) ]
107- public void RendererTests_HtmlTest ( string name , string text )
108- => AssertMarkdownYieldsFormat ( name , text , new Style ( foreground : Color . Black , background : Color . Green ) ) ;
123+ public void RendererTests_HtmlTest ( string name , string text )
124+ {
125+ AssertMarkdownYieldsFormat ( name , text , new Style ( foreground : Color . Black , background : Color . Green ) , useCrazy : false ) ;
126+ AssertMarkdownYieldsFormat ( name , text , new Style ( foreground : Color . Black , background : Color . Green ) , useCrazy : true ) ;
127+ }
109128
110129 [ TestMethod ]
111130 public void RendererTests_LinkTest ( )
@@ -123,7 +142,7 @@ public void RendererTests_LinkTest()
123142 new ( "9" , "https://www.nine.com/nine.jpg" , true ) ,
124143 } ;
125144
126- var renderer = new ConsoleRenderer ( includeDebug : true ) ;
145+ var renderer = new ConsoleRenderer ( new DisplayOptions ( ) { IncludeDebug = true } ) ;
127146
128147 ConsoleUnderTest . Write ( Renderer ( GetResourceContent ( "linkInline" , "md" ) , renderer ) ) ;
129148
@@ -140,17 +159,22 @@ public void RendererTests_LinkTest()
140159 [ DataRow ( "quote 2." , Decoration . Italic ) ]
141160 [ DataRow ( "should even" , Decoration . Italic | Decoration . Bold ) ]
142161 public void RendererTests_QuoteBlockTest ( string text , Decoration decoration )
143- => AssertMarkdownYieldsFormat ( "quoteBlock" , text , new Style ( decoration : decoration ) ) ;
162+ {
163+ AssertMarkdownYieldsFormat ( "quoteBlock" , text , new Style ( decoration : decoration ) , useCrazy : false ) ;
164+ AssertMarkdownYieldsFormat ( "quoteBlock" , text , new Style ( decoration : decoration ) , useCrazy : true ) ;
165+ }
144166
145- private void AssertMarkdownYieldsFormat ( string name , string text , Style style )
167+ private void AssertMarkdownYieldsFormat ( string name , string text , Style style , bool useCrazy )
146168 {
169+ Style format = useCrazy ? c_crazyFormat : style ;
170+ DisplayOptions options = useCrazy ? m_crazyOptions : new DisplayOptions ( ) ;
147171 var markdown = GetResourceContent ( name , "md" ) ;
148172
149- var renderHook = new TestRenderHook ( text , style ) ;
173+ var renderHook = new TestRenderHook ( text , format ) ;
150174 ConsoleUnderTest . Pipeline . Attach ( renderHook ) ;
151175
152176 Logger . LogMessage ( $ "Rendering { name } ") ;
153- ConsoleUnderTest . Write ( Renderer ( markdown ) ) ;
177+ ConsoleUnderTest . Write ( Renderer ( markdown , options : options ) ) ;
154178
155179 renderHook . AssertFormattedTextFound ( ) ;
156180 }
@@ -164,10 +188,13 @@ private string GetResourceContent(string name, string extension)
164188 return reader . ReadToEnd ( ) ;
165189 }
166190
167- private static IRenderable Renderer ( string text , ConsoleRenderer ? renderer = default , MarkdownPipeline ? pipeline = default )
191+ private static IRenderable Renderer ( string text , ConsoleRenderer ? renderer = default , MarkdownPipeline ? pipeline = default , DisplayOptions ? options = default )
168192 {
169193 var document = Markdown . Parse ( text , pipeline ?? Displayer . DefaultPipeline ) ;
170- renderer ??= new ConsoleRenderer ( includeDebug : true ) ;
194+ options ??= new ( ) ;
195+ options = options . Clone ( ) ;
196+ options . IncludeDebug = true ;
197+ renderer ??= new ConsoleRenderer ( options ) ;
171198 renderer . Clear ( ) ;
172199 renderer . Render ( document ) ;
173200 Assert . IsNotNull ( renderer . Root ) ;
@@ -222,6 +249,27 @@ private static Dictionary<string, int> Counts(string text)
222249 private int m_count ;
223250 }
224251
252+ private const string c_crazyFormat = "red on purple" ;
253+ private readonly static DisplayOptions m_crazyOptions = new DisplayOptions
254+ {
255+ Bold = c_crazyFormat ,
256+ CodeBlock = c_crazyFormat ,
257+ CodeInLine = c_crazyFormat ,
258+ Header = c_crazyFormat ,
259+ HtmlBlock = c_crazyFormat ,
260+ HtmlInline = c_crazyFormat ,
261+ Inserted = c_crazyFormat ,
262+ Italic = c_crazyFormat ,
263+ Marked = c_crazyFormat ,
264+ QuotedBlock = c_crazyFormat ,
265+ Strikethrough = c_crazyFormat ,
266+ Subscript = c_crazyFormat ,
267+ Superscript = c_crazyFormat ,
268+ UnknownDelimiterChar = c_crazyFormat ,
269+ UnknownDelimiterContent = c_crazyFormat ,
270+ WrapHeader = false ,
271+ } ;
272+
225273 private const string c_resources = "resources" ;
226274 }
227275}
0 commit comments