Skip to content

Commit ed69d9f

Browse files
committed
Add initialRunspace field to Test.PowershellContextFactory
So that it can be used independent of the context service.
1 parent 2cd9bdc commit ed69d9f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

test/PowerShellEditorServices.Test/PowerShellContextFactory.cs

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using Microsoft.Extensions.Logging;
5-
using Microsoft.Extensions.Logging.Abstractions;
6-
using Microsoft.PowerShell.EditorServices.Hosting;
7-
using Microsoft.PowerShell.EditorServices.Services;
8-
using Microsoft.PowerShell.EditorServices.Services.PowerShellContext;
9-
using Microsoft.PowerShell.EditorServices.Test.Shared;
104
using System;
115
using System.Collections.Generic;
126
using System.IO;
137
using System.Management.Automation;
148
using System.Threading;
159
using System.Threading.Tasks;
10+
using Microsoft.Extensions.Logging;
11+
using Microsoft.Extensions.Logging.Abstractions;
12+
using Microsoft.PowerShell.EditorServices.Hosting;
13+
using Microsoft.PowerShell.EditorServices.Services;
14+
using Microsoft.PowerShell.EditorServices.Services.PowerShellContext;
15+
using Microsoft.PowerShell.EditorServices.Test.Shared;
1616

1717
namespace Microsoft.PowerShell.EditorServices.Test
1818
{
@@ -32,6 +32,8 @@ internal static class PowerShellContextFactory
3232
Path.GetFullPath(
3333
TestUtilities.NormalizePath("../../../../PowerShellEditorServices.Test.Shared/ProfileTest.ps1")));
3434

35+
public static System.Management.Automation.Runspaces.Runspace initialRunspace;
36+
3537
public static PowerShellContextService Create(ILogger logger)
3638
{
3739
PowerShellContextService powerShellContext = new PowerShellContextService(logger, null, isPSReadLineEnabled: false);
@@ -50,14 +52,15 @@ public static PowerShellContextService Create(ILogger logger)
5052
consoleReplEnabled: false,
5153
usesLegacyReadLine: false);
5254

53-
54-
powerShellContext.Initialize(
55-
TestProfilePaths,
56-
PowerShellContextService.CreateRunspace(
55+
initialRunspace = PowerShellContextService.CreateRunspace(
5756
testHostDetails,
5857
powerShellContext,
5958
new TestPSHostUserInterface(powerShellContext, logger),
60-
logger),
59+
logger);
60+
61+
powerShellContext.Initialize(
62+
TestProfilePaths,
63+
initialRunspace,
6164
ownsInitialRunspace: true,
6265
consoleHost: null);
6366

0 commit comments

Comments
 (0)