Skip to content

Commit 2e1b598

Browse files
committed
Add regression test for throw
1 parent cceedab commit 2e1b598

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
using System.Threading;
77
using System.Threading.Tasks;
88
using Microsoft.Extensions.Logging.Abstractions;
9-
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host;
109
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Console;
10+
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution;
11+
using Microsoft.PowerShell.EditorServices.Services.PowerShell.Host;
1112
using Xunit;
1213

1314
namespace Microsoft.PowerShell.EditorServices.Test.Console
@@ -41,6 +42,20 @@ public async Task CanExecutePSCommand()
4142
Assert.Equal("foo", result[0]);
4243
}
4344

45+
[Trait("Category", "PsesInternalHost")]
46+
[Fact]
47+
public async Task CanHandleThrow()
48+
{
49+
// TODO: Fix this so it doesn't throw!
50+
_ = await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() =>
51+
{
52+
return psesHost.ExecutePSCommandAsync(
53+
new PSCommand().AddScript("throw"),
54+
CancellationToken.None,
55+
new PowerShellExecutionOptions { ThrowOnError = false });
56+
}).ConfigureAwait(true);
57+
}
58+
4459
[Trait("Category", "PsesInternalHost")]
4560
[Fact]
4661
public async Task CanQueueParallelPSCommands()

0 commit comments

Comments
 (0)