diff --git a/test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs b/test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs index ee2163024..1f7998ec5 100644 --- a/test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs +++ b/test/PowerShellEditorServices.Test/Extensions/ExtensionCommandTests.cs @@ -179,5 +179,19 @@ await psesHost.ExecutePSCommandAsync( await Assert.ThrowsAsync( () => extensionCommandService.InvokeCommandAsync("test.scriptblock", editorContext)).ConfigureAwait(true); } + + [Fact] + public async Task CannotRemovePSEditorVariable() + { + ActionPreferenceStopException exception = await Assert.ThrowsAsync( + () => psesHost.ExecutePSCommandAsync( + new PSCommand().AddScript("Remove-Variable psEditor -ErrorAction Stop"), + CancellationToken.None) + ).ConfigureAwait(true); + + Assert.Equal( + "The running command stopped because the preference variable \"ErrorActionPreference\" or common parameter is set to Stop: Cannot remove variable psEditor because it is constant or read-only. If the variable is read-only, try the operation again specifying the Force option.", + exception.Message); + } } }