@@ -131,6 +131,45 @@ public void SetInvalidColorOptions()
131131 Assert . True ( throws , "Invalid color value should throw" ) ;
132132 }
133133
134+ [ SkippableFact ]
135+ public void SetPromptTextOption ( )
136+ {
137+ // For prompt texts with VT sequences, reset all attributes if not already.
138+ string [ ] promptTexts_1 = new [ ] { "\x1b [91m> " } ;
139+ string [ ] promptTexts_2 = new [ ] { "\x1b [91m> " , "\x1b [92m> " , "\x1b [93m> " } ;
140+ string [ ] promptTexts_3 = new [ ] { "> " } ;
141+ string [ ] promptTexts_4 = new [ ] { "> " , "] " } ;
142+ string [ ] promptTexts_5 = new [ ] { "\x1b [93m> \x1b [0m" } ;
143+
144+ PSConsoleReadLine . SetOptions ( new SetPSReadLineOption {
145+ PromptText = promptTexts_1 ,
146+ } ) ;
147+ Assert . Equal ( "\x1b [91m> \x1b [0m" , promptTexts_1 [ 0 ] ) ;
148+
149+ PSConsoleReadLine . SetOptions ( new SetPSReadLineOption {
150+ PromptText = promptTexts_2 ,
151+ } ) ;
152+ Assert . Equal ( "\x1b [91m> \x1b [0m" , promptTexts_2 [ 0 ] ) ;
153+ Assert . Equal ( "\x1b [92m> \x1b [0m" , promptTexts_2 [ 1 ] ) ;
154+ Assert . Equal ( "\x1b [93m> " , promptTexts_2 [ 2 ] ) ;
155+
156+ PSConsoleReadLine . SetOptions ( new SetPSReadLineOption {
157+ PromptText = promptTexts_3 ,
158+ } ) ;
159+ Assert . Equal ( "> " , promptTexts_3 [ 0 ] ) ;
160+
161+ PSConsoleReadLine . SetOptions ( new SetPSReadLineOption {
162+ PromptText = promptTexts_4 ,
163+ } ) ;
164+ Assert . Equal ( "> " , promptTexts_4 [ 0 ] ) ;
165+ Assert . Equal ( "] " , promptTexts_4 [ 1 ] ) ;
166+
167+ PSConsoleReadLine . SetOptions ( new SetPSReadLineOption {
168+ PromptText = promptTexts_5 ,
169+ } ) ;
170+ Assert . Equal ( "\x1b [93m> \x1b [0m" , promptTexts_5 [ 0 ] ) ;
171+ }
172+
134173 [ SkippableFact ]
135174 [ ExcludeFromCodeCoverage ]
136175 public void UselessStuffForBetterCoverage ( )
0 commit comments