@@ -136,4 +136,66 @@ public void When_parsing_text_with_links_it_should_output_ordered_segments()
136136 textBlock1 ! . TextSegments [ 6 ] . As < IndicatorSegment > ( ) . Indicator . Should ( ) . Be ( SegmentIndicator . Link ) ;
137137 textBlock1 ! . TextSegments [ 6 ] . As < IndicatorSegment > ( ) . IndicatorPosition . Should ( ) . Be ( SegmentIndicatorPosition . End ) ;
138138 }
139+
140+ [ TestMethod ]
141+ public void When_parsing_text_with_placeholders_it_should_output_ordered_segments ( )
142+ {
143+ //-----------------------------------------------------------------------------------------------------------
144+ // Arrange
145+ //-----------------------------------------------------------------------------------------------------------
146+ var markdown = FileReader . ReadFile ( "TextEmphasis.basic-placeholders.md" ) ;
147+
148+ var componentSupplier = new PassThroughComponentSupplier ( ) ;
149+ var parser = new MarkdownParser < object > ( componentSupplier ) ;
150+
151+ //-----------------------------------------------------------------------------------------------------------
152+ // Act
153+ //-----------------------------------------------------------------------------------------------------------
154+ var parseResult = parser . Parse ( markdown ) ;
155+
156+ //-----------------------------------------------------------------------------------------------------------
157+ // Assert
158+ //-----------------------------------------------------------------------------------------------------------
159+ parseResult . Count . Should ( ) . Be ( 3 ) ;
160+
161+ parseResult [ 0 ] . Should ( ) . BeOfType < TextBlock > ( ) ;
162+ var textBlock0 = parseResult [ 0 ] as TextBlock ;
163+ textBlock0 ! . TextSegments . Length . Should ( ) . Be ( 3 ) ;
164+ textBlock0 ! . TextSegments [ 0 ] . As < TextSegment > ( ) . Text . Should ( ) . Be ( "Use " ) ;
165+ textBlock0 ! . TextSegments [ 1 ] . As < IndicatorSegment > ( ) . Indicator . Should ( ) . Be ( SegmentIndicator . Placeholder ) ;
166+ textBlock0 ! . TextSegments [ 1 ] . As < IndicatorSegment > ( ) . IndicatorPosition . Should ( ) . Be ( SegmentIndicatorPosition . Start ) ;
167+ textBlock0 ! . TextSegments [ 1 ] . As < PlaceholderSegment > ( ) . Title . Should ( ) . Be ( "placeholder x" ) ;
168+ textBlock0 ! . TextSegments [ 1 ] . As < PlaceholderSegment > ( ) . Url . Should ( ) . Be ( "placeholder x" ) ;
169+ textBlock0 ! . TextSegments [ 1 ] . As < PlaceholderSegment > ( ) . ToString ( ) . Should ( ) . Be ( "placeholder x" ) ;
170+ textBlock0 ! . TextSegments [ 2 ] . As < TextSegment > ( ) . Text . Should ( ) . Be ( " within sentence." ) ;
171+
172+ parseResult [ 1 ] . Should ( ) . BeOfType < TextBlock > ( ) ;
173+ var textBlock1 = parseResult [ 1 ] as TextBlock ;
174+ textBlock1 ! . TextSegments . Length . Should ( ) . Be ( 10 ) ;
175+ textBlock1 ! . TextSegments [ 0 ] . As < TextSegment > ( ) . Text . Should ( ) . Be ( "Paragraphs " ) ;
176+ textBlock1 ! . TextSegments [ 1 ] . As < IndicatorSegment > ( ) . Indicator . Should ( ) . Be ( SegmentIndicator . Strong ) ;
177+ textBlock1 ! . TextSegments [ 1 ] . As < IndicatorSegment > ( ) . IndicatorPosition . Should ( ) . Be ( SegmentIndicatorPosition . Start ) ;
178+ textBlock1 ! . TextSegments [ 2 ] . As < TextSegment > ( ) . Text . Should ( ) . Be ( "are " ) ;
179+ textBlock1 ! . TextSegments [ 3 ] . As < IndicatorSegment > ( ) . Indicator . Should ( ) . Be ( SegmentIndicator . Italic ) ;
180+ textBlock1 ! . TextSegments [ 3 ] . As < IndicatorSegment > ( ) . IndicatorPosition . Should ( ) . Be ( SegmentIndicatorPosition . Start ) ;
181+ textBlock1 ! . TextSegments [ 4 ] . As < TextSegment > ( ) . Text . Should ( ) . Be ( "separated " ) ;
182+ textBlock1 ! . TextSegments [ 5 ] . As < IndicatorSegment > ( ) . Indicator . Should ( ) . Be ( SegmentIndicator . Placeholder ) ;
183+ textBlock1 ! . TextSegments [ 5 ] . As < PlaceholderSegment > ( ) . Title . Should ( ) . Be ( "placeholder y" ) ;
184+ textBlock1 ! . TextSegments [ 5 ] . As < PlaceholderSegment > ( ) . Url . Should ( ) . Be ( "placeholder y" ) ;
185+ textBlock1 ! . TextSegments [ 5 ] . As < PlaceholderSegment > ( ) . ToString ( ) . Should ( ) . Be ( "placeholder y" ) ;
186+ textBlock1 ! . TextSegments [ 6 ] . As < IndicatorSegment > ( ) . Indicator . Should ( ) . Be ( SegmentIndicator . Italic ) ;
187+ textBlock1 ! . TextSegments [ 6 ] . As < IndicatorSegment > ( ) . IndicatorPosition . Should ( ) . Be ( SegmentIndicatorPosition . End ) ;
188+ textBlock1 ! . TextSegments [ 7 ] . As < TextSegment > ( ) . Text . Should ( ) . Be ( " by" ) ;
189+ textBlock1 ! . TextSegments [ 8 ] . As < IndicatorSegment > ( ) . Indicator . Should ( ) . Be ( SegmentIndicator . Strong ) ;
190+ textBlock1 ! . TextSegments [ 8 ] . As < IndicatorSegment > ( ) . IndicatorPosition . Should ( ) . Be ( SegmentIndicatorPosition . End ) ;
191+ textBlock1 ! . TextSegments [ 9 ] . As < TextSegment > ( ) . Text . Should ( ) . Be ( " a blank line." ) ;
192+
193+ parseResult [ 2 ] . Should ( ) . BeOfType < TextBlock > ( ) ;
194+ var textBlock2 = parseResult [ 2 ] as TextBlock ;
195+ textBlock2 ! . TextSegments . Length . Should ( ) . Be ( 1 ) ;
196+ textBlock2 ! . TextSegments [ 0 ] . As < IndicatorSegment > ( ) . Indicator . Should ( ) . Be ( SegmentIndicator . Placeholder ) ;
197+ textBlock2 ! . TextSegments [ 0 ] . As < PlaceholderSegment > ( ) . Title . Should ( ) . Be ( "placeholder z" ) ;
198+ textBlock2 ! . TextSegments [ 0 ] . As < PlaceholderSegment > ( ) . Url . Should ( ) . Be ( "placeholder z" ) ;
199+ textBlock2 ! . TextSegments [ 0 ] . As < PlaceholderSegment > ( ) . ToString ( ) . Should ( ) . Be ( "placeholder z" ) ;
200+ }
139201}
0 commit comments