@@ -88,7 +88,7 @@ public async Task CanQueueParallelPSCommands()
88
88
public async Task CanCancelExecutionWithToken ( )
89
89
{
90
90
using CancellationTokenSource cancellationSource = new ( millisecondsDelay : 1000 ) ;
91
- await Assert . ThrowsAsync < TaskCanceledException > ( ( ) =>
91
+ _ = await Assert . ThrowsAsync < TaskCanceledException > ( ( ) =>
92
92
{
93
93
return psesHost . ExecutePSCommandAsync (
94
94
new PSCommand ( ) . AddScript ( "Start-Sleep 10" ) ,
@@ -170,10 +170,29 @@ await psesHost.ExecuteDelegateAsync(
170
170
[ Fact ]
171
171
public async Task CanHandleBrokenPrompt ( )
172
172
{
173
- await psesHost . ExecutePSCommandAsync (
174
- new PSCommand ( ) . AddScript ( "function prompt { throw }" ) ,
173
+ _ = await Assert . ThrowsAsync < RuntimeException > ( ( ) =>
174
+ {
175
+ return psesHost . ExecutePSCommandAsync (
176
+ new PSCommand ( ) . AddScript ( "function prompt { throw }; prompt" ) ,
177
+ CancellationToken . None ) ;
178
+ } ) . ConfigureAwait ( true ) ;
179
+
180
+ string prompt = await psesHost . ExecuteDelegateAsync (
181
+ nameof ( psesHost . GetPrompt ) ,
182
+ executionOptions : null ,
183
+ ( _ , _ ) => psesHost . GetPrompt ( CancellationToken . None ) ,
175
184
CancellationToken . None ) . ConfigureAwait ( true ) ;
176
185
186
+ Assert . Equal ( PsesInternalHost . DefaultPrompt , prompt ) ;
187
+ }
188
+
189
+ [ Fact ]
190
+ public async Task CanHandleUndefinedPrompt ( )
191
+ {
192
+ Assert . Empty ( await psesHost . ExecutePSCommandAsync < PSObject > (
193
+ new PSCommand ( ) . AddScript ( "Remove-Item function:prompt; Get-Item function:prompt -ErrorAction Ignore" ) ,
194
+ CancellationToken . None ) . ConfigureAwait ( true ) ) ;
195
+
177
196
string prompt = await psesHost . ExecuteDelegateAsync (
178
197
nameof ( psesHost . GetPrompt ) ,
179
198
executionOptions : null ,
0 commit comments