Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
RunspaceCmdlets.Tests.ps144 linesDownload Raw Back to Microsoft.PowerShell.Utility
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3Describe "Get-Runspace cmdlet tests" -Tag "CI" {4    BeforeAll {5        $CurrentRunspace = $ExecutionContext.Host.Runspace6        $ExpectedInstanceId = $CurrentRunspace.InstanceId7        $ExpectedId = $currentRunspace.Id8    }9    It "Get-Runspace should return the current runspace" {10        $runspace = Get-Runspace |Sort-Object -Property id | Select-Object -First 111        $runspace.InstanceId | Should -Be $ExpectedInstanceId12    }13    It "Get-Runspace with runspace InstanceId should return the correct runspace" {14        $runspace = Get-Runspace -InstanceId $CurrentRunspace.InstanceId15        $runspace.InstanceId | Should -Be $ExpectedInstanceId16    }17    It "Get-Runspace with runspace name should return the correct runspace" {18        $runspace = Get-Runspace -Name $currentRunspace.Name19        $runspace.InstanceId | Should -Be $ExpectedInstanceId20    }21    It "Get-Runspace with runspace Id should return the correct runspace" {22        $runspace = Get-Runspace -Id $CurrentRunspace.Id23        $runspace.InstanceId | Should -Be $ExpectedInstanceId24    }25    Context "Multiple Runspaces" {26        BeforeAll {27            $runspaceCount = @(Get-Runspace).count28            $r1 = [runspacefactory]::CreateRunspace()29            $r1.Open()30            $r2 = [runspacefactory]::CreateRunspace()31        }32        AfterAll {33            $r1.Dispose()34            $r2.Dispose()35        }36        It "Get-Runspace should return the new runspaces" {37            $result = Get-Runspace38            # if the ids don't match, we'll get null passed to should39            $result.id | Where-Object {$_ -eq $r1.id } | Should -Be $r1.id40            $result.id | Where-Object {$_ -eq $r2.id } | Should -Be $r2.id41        }42    }43}44