2016-03-17 10:31:04 +01:00
|
|
|
using Xunit;
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Management.Automation;
|
|
|
|
using System.Management.Automation.Host;
|
|
|
|
using System.Management.Automation.Internal;
|
|
|
|
using System.Management.Automation.Internal.Host;
|
|
|
|
using System.Management.Automation.Runspaces;
|
|
|
|
using Microsoft.PowerShell;
|
2016-04-08 19:59:41 +02:00
|
|
|
using Microsoft.PowerShell.CoreConsoleHost;
|
2016-03-17 10:31:04 +01:00
|
|
|
|
|
|
|
namespace PSTests
|
|
|
|
{
|
2016-03-18 03:11:41 +01:00
|
|
|
[Collection("AssemblyLoadContext")]
|
2016-03-17 10:31:04 +01:00
|
|
|
public class SessionStateTests
|
|
|
|
{
|
|
|
|
[Fact]
|
|
|
|
public void TestDrives()
|
|
|
|
{
|
2016-03-18 03:11:41 +01:00
|
|
|
CultureInfo currentCulture = CultureInfo.CurrentCulture;
|
|
|
|
PSHost hostInterface = new DefaultHost(currentCulture,currentCulture);
|
|
|
|
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
|
|
|
|
InitialSessionState iss = InitialSessionState.CreateDefault2();
|
|
|
|
AutomationEngine engine = new AutomationEngine(hostInterface, runspaceConfiguration, iss);
|
|
|
|
ExecutionContext executionContext = new ExecutionContext(engine, hostInterface, iss);
|
2016-03-17 10:31:04 +01:00
|
|
|
SessionStateInternal sessionState = new SessionStateInternal(executionContext);
|
|
|
|
Collection<PSDriveInfo> drives = sessionState.Drives(null);
|
2016-03-18 04:18:29 +01:00
|
|
|
Assert.NotNull(drives);
|
2016-03-17 10:31:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|