Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/RunspaceCmdlets.Tests.ps1
T

41 lines
1.7 KiB
PowerShell
Raw Normal View History

2016-09-09 12:48:55 -07:00
Describe "Get-Runspace cmdlet tests" -Tag "CI" {
BeforeAll {
$CurrentRunspace = $ExecutionContext.Host.Runspace
$ExpectedInstanceId = $CurrentRunspace.InstanceId
$ExpectedId = $currentRunspace.Id
}
It "Get-Runspace should return the current runspace" {
2016-09-12 16:41:30 -07:00
$runspace = get-runspace |Sort-Object -property id | Select-Object -first 1
2016-09-09 12:48:55 -07:00
$runspace.InstanceId | Should be $ExpectedInstanceId
}
It "Get-Runspace with runspace InstanceId should return the correct runspace" {
$runspace = get-runspace -instanceid $CurrentRunspace.InstanceId
$runspace.InstanceId | Should be $ExpectedInstanceId
}
It "Get-Runspace with runspace name should return the correct runspace" {
$runspace = get-runspace -name $currentRunspace.Name
$runspace.InstanceId | Should be $ExpectedInstanceId
}
2016-09-09 12:48:55 -07:00
It "Get-Runspace with runspace Id should return the correct runspace" {
$runspace = get-runspace -id $CurrentRunspace.Id
$runspace.InstanceId | Should be $ExpectedInstanceId
2017-01-16 13:31:14 -08:00
}
2016-09-09 12:48:55 -07:00
Context "Multiple Runspaces" {
BeforeAll {
$runspaceCount = @(get-runspace).count
$r1 = [runspacefactory]::CreateRunspace()
$r1.Open()
$r2 = [runspacefactory]::CreateRunspace()
}
AfterAll {
$r1.Dispose()
$r2.Dispose()
}
2016-09-12 16:41:30 -07:00
It "Get-Runspace should return the new runspaces" {
$result = get-runspace
# if the ids don't match, we'll get null passed to should
2017-07-22 05:03:49 +01:00
$result.id | Where-Object {$_ -eq $r1.id } | should be $r1.id
$result.id | Where-Object {$_ -eq $r2.id } | should be $r2.id
2016-09-09 12:48:55 -07:00
}
}
}