File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
src/PowerShellEditorServices/Services/PowerShellContext/Session
test/PowerShellEditorServices.Test/Session Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,18 @@ internal class PSReadLinePromptContext : IPromptContext
2222 ".." ,
2323 ".." ,
2424 ".." ,
25- #if TEST
26- // When using xUnit (dotnet test) the assemblies are deployed to the
27- // test project folder, invalidating our relative path assumption.
25+ "PSReadLine" ) ;
26+
27+ // When using xUnit (dotnet test) the assemblies are deployed to the
28+ // test project folder, invalidating our relative path assumption.
29+ private static readonly string _psReadLineTestModulePath = Path . Combine (
30+ Path . GetDirectoryName ( typeof ( PSReadLinePromptContext ) . Assembly . Location ) ,
31+ ".." ,
32+ ".." ,
33+ ".." ,
2834 ".." ,
2935 ".." ,
3036 "module" ,
31- #endif
3237 "PSReadLine" ) ;
3338
3439 private static readonly Lazy < CmdletInfo > s_lazyInvokeReadLineForEditorServicesCmdletInfo = new Lazy < CmdletInfo > ( ( ) =>
@@ -79,15 +84,16 @@ internal PSReadLinePromptContext(
7984 internal static bool TryGetPSReadLineProxy (
8085 ILogger logger ,
8186 Runspace runspace ,
82- out PSReadLineProxy readLineProxy )
87+ out PSReadLineProxy readLineProxy ,
88+ bool testing = false )
8389 {
8490 readLineProxy = null ;
8591 logger . LogTrace ( "Attempting to load PSReadLine" ) ;
8692 using ( var pwsh = PowerShell . Create ( ) )
8793 {
8894 pwsh . Runspace = runspace ;
8995 pwsh . AddCommand ( "Microsoft.PowerShell.Core\\ Import-Module" )
90- . AddParameter ( "Name" , _psReadLineModulePath )
96+ . AddParameter ( "Name" , testing ? _psReadLineTestModulePath : _psReadLineModulePath )
9197 . Invoke ( ) ;
9298
9399 var psReadLineType = Type . GetType ( "Microsoft.PowerShell.PSConsoleReadLine, Microsoft.PowerShell.PSReadLine2" ) ;
Original file line number Diff line number Diff line change @@ -154,7 +154,8 @@ public void CanGetPSReadLineProxy()
154154 Assert . True ( PSReadLinePromptContext . TryGetPSReadLineProxy (
155155 NullLogger . Instance ,
156156 PowerShellContextFactory . initialRunspace ,
157- out PSReadLineProxy proxy ) ) ;
157+ out PSReadLineProxy proxy ,
158+ true ) ) ;
158159 }
159160
160161 #region Helper Methods
You can’t perform that action at this time.
0 commit comments