Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public async Task CanQueueParallelPSCommands()
public async Task CanCancelExecutionWithToken()
{
using CancellationTokenSource cancellationSource = new(millisecondsDelay: 1000);
await Assert.ThrowsAsync<TaskCanceledException>(() =>
_ = await Assert.ThrowsAsync<TaskCanceledException>(() =>
{
return psesHost.ExecutePSCommandAsync(
new PSCommand().AddScript("Start-Sleep 10"),
Expand Down Expand Up @@ -170,10 +170,29 @@ await psesHost.ExecuteDelegateAsync(
[Fact]
public async Task CanHandleBrokenPrompt()
{
await psesHost.ExecutePSCommandAsync(
new PSCommand().AddScript("function prompt { throw }"),
_ = await Assert.ThrowsAsync<RuntimeException>(() =>
{
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<PSObject>(
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,
Expand Down