diff --git a/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs b/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs index 41d5cbb82..d66c46938 100644 --- a/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs +++ b/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs @@ -88,7 +88,7 @@ public async Task CanQueueParallelPSCommands() public async Task CanCancelExecutionWithToken() { using CancellationTokenSource cancellationSource = new(millisecondsDelay: 1000); - await Assert.ThrowsAsync(() => + _ = await Assert.ThrowsAsync(() => { return psesHost.ExecutePSCommandAsync( new PSCommand().AddScript("Start-Sleep 10"), @@ -170,10 +170,29 @@ await psesHost.ExecuteDelegateAsync( [Fact] public async Task CanHandleBrokenPrompt() { - await psesHost.ExecutePSCommandAsync( - new PSCommand().AddScript("function prompt { throw }"), + _ = await Assert.ThrowsAsync(() => + { + return psesHost.ExecutePSCommandAsync( + new PSCommand().AddScript("function prompt { throw }; prompt"), + CancellationToken.None); + }).ConfigureAwait(true); + + string prompt = await psesHost.ExecuteDelegateAsync( + nameof(psesHost.GetPrompt), + executionOptions: null, + (_, _) => psesHost.GetPrompt(CancellationToken.None), CancellationToken.None).ConfigureAwait(true); + Assert.Equal(PsesInternalHost.DefaultPrompt, prompt); + } + + [Fact] + public async Task CanHandleUndefinedPrompt() + { + Assert.Empty(await psesHost.ExecutePSCommandAsync( + new PSCommand().AddScript("Remove-Item function:prompt; Get-Item function:prompt -ErrorAction Ignore"), + CancellationToken.None).ConfigureAwait(true)); + string prompt = await psesHost.ExecuteDelegateAsync( nameof(psesHost.GetPrompt), executionOptions: null,