@@ -74,7 +74,6 @@ public void RendererProduceNameAndSynopsis()
74
74
{
75
75
LinkName = "PowerShell made by Microsoft Hackathon" ,
76
76
LinkUri = "www.microsoft.com"
77
-
78
77
}
79
78
) ;
80
79
@@ -100,7 +99,7 @@ public void RendererProduceNameAndSynopsis()
100
99
Assert . Equal ( 1 , parameter2 . Length ) ;
101
100
Assert . Equal ( "This is the path parameter description." , parameter2 [ 0 ] ) ;
102
101
103
- string [ ] example1 = EndToEndTests . GetXmlContent ( maml , "/msh:helpItems/command:command/command:examples/command:example[maml:title= 'Example 1']/dev:code" ) ;
102
+ string [ ] example1 = EndToEndTests . GetXmlContent ( maml , "/msh:helpItems/command:command/command:examples/command:example[contains( maml:title, 'Example 1') ]/dev:code" ) ;
104
103
Assert . Equal ( 1 , example1 . Length ) ;
105
104
Assert . Equal ( "PS:> Get-Help -YouNeedIt" , example1 [ 0 ] ) ;
106
105
}
@@ -167,9 +166,65 @@ public void RendererProduceEscapeXmlSpecialChars()
167
166
168
167
string [ ] synopsis = EndToEndTests . GetXmlContent ( maml , "/msh:helpItems/command:command/command:details/maml:description/maml:para" ) ;
169
168
Assert . Equal ( 1 , synopsis . Length ) ;
170
- Assert . Equal ( synopsis [ 0 ] , command . Synopsis . Text ) ;
169
+ Assert . Equal ( command . Synopsis . Text , synopsis [ 0 ] ) ;
171
170
}
172
171
172
+ [ Fact ]
173
+ public void RendererProducePaddedExampleTitle ( )
174
+ {
175
+ MamlRenderer renderer = new MamlRenderer ( ) ;
176
+ MamlCommand command = new MamlCommand ( )
177
+ {
178
+ Name = "Get-Foo" ,
179
+ Synopsis = new SectionBody ( "This is a description" )
180
+ } ;
181
+
182
+ var example1 = new MamlExample ( )
183
+ {
184
+ Title = "Example 1" ,
185
+ Code = "PS:> Get-Help -YouNeedIt" ,
186
+ Remarks = "This does stuff!"
187
+ } ;
188
+
189
+ var example10 = new MamlExample ( )
190
+ {
191
+ Title = "Example 10" ,
192
+ Code = "PS:> Get-Help -YouNeedIt" ,
193
+ Remarks = "This does stuff!"
194
+ } ;
195
+
196
+ var exampleWithTitle = new MamlExample ( )
197
+ {
198
+ Title = "Example 11: With a title" ,
199
+ Code = "PS:> Get-Help -YouNeedIt" ,
200
+ Remarks = "This does stuff!"
201
+ } ;
202
+
203
+ var exampleWithLongTitle = new MamlExample ( )
204
+ {
205
+ Title = "Example 12: " . PadRight ( 66 , 'A' ) ,
206
+ Code = "PS:> Get-Help -YouNeedIt" ,
207
+ Remarks = "This does stuff!"
208
+ } ;
209
+
210
+ command . Examples . Add ( example1 ) ;
211
+ command . Examples . Add ( example10 ) ;
212
+ command . Examples . Add ( exampleWithTitle ) ;
213
+ command . Examples . Add ( exampleWithLongTitle ) ;
214
+
215
+ string maml = renderer . MamlModelToString ( new [ ] { command } ) ;
216
+
217
+ // Check that example header is padded by dashes (-) unless to long
218
+ string [ ] example = EndToEndTests . GetXmlContent ( maml , "/msh:helpItems/command:command/command:examples/command:example/maml:title" ) ;
219
+ Assert . Equal ( 4 , example . Length ) ;
220
+ Assert . Equal ( 63 , example [ 0 ] . Length ) ;
221
+ Assert . Equal ( 64 , example [ 1 ] . Length ) ;
222
+ Assert . Equal ( 66 , example [ 3 ] . Length ) ;
223
+ Assert . Matches ( $ "^-+ { example1 . Title } -+$", example [ 0 ] ) ;
224
+ Assert . Matches ( $ "^-+ { example10 . Title } -+$", example [ 1 ] ) ;
225
+ Assert . Matches ( $ "^-+ { exampleWithTitle . Title } -+$", example [ 2 ] ) ;
226
+ Assert . Matches ( $ "^{ exampleWithLongTitle . Title } $", example [ 3 ] ) ;
227
+ }
173
228
}
174
229
175
230
}
0 commit comments