File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
test/PowerShellEditorServices.Test/Session Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 66using System . Threading ;
77using System . Threading . Tasks ;
88using Microsoft . Extensions . Logging . Abstractions ;
9+ using Microsoft . PowerShell . EditorServices . Hosting ;
910using Microsoft . PowerShell . EditorServices . Services . PowerShell . Console ;
1011using Microsoft . PowerShell . EditorServices . Services . PowerShell . Execution ;
1112using Microsoft . PowerShell . EditorServices . Services . PowerShell . Host ;
13+ using Microsoft . PowerShell . EditorServices . Services . PowerShell . Utility ;
1214using Xunit ;
1315
1416namespace Microsoft . PowerShell . EditorServices . Test . Console
@@ -141,6 +143,23 @@ public async Task CanResolveAndLoadProfilesForHostId()
141143 Assert . Equal ( expectedString , result [ 0 ] , ignoreCase : true ) ;
142144 }
143145
146+ [ Fact ]
147+ public async Task CanHandleNoProfiles ( )
148+ {
149+ // Call LoadProfiles with profile paths that won't exist, and assert that it does not
150+ // throw PSInvalidOperationException (which it previously did when it tried to invoke an
151+ // empty command).
152+ ProfilePathInfo emptyProfilePaths = new ( "" , "" , "" , "" ) ;
153+ await psesHost . ExecuteDelegateAsync (
154+ "LoadProfiles" ,
155+ executionOptions : null ,
156+ ( pwsh , _ ) => {
157+ pwsh . LoadProfiles ( emptyProfilePaths ) ;
158+ Assert . Empty ( pwsh . Commands . Commands ) ;
159+ } ,
160+ CancellationToken . None ) . ConfigureAwait ( true ) ;
161+ }
162+
144163 [ Fact ]
145164 public async Task CanLoadPSReadLine ( )
146165 {
You can’t perform that action at this time.
0 commit comments