Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
CimInstance.Tests.ps136 linesDownload Raw Back to CimCmdlets
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3 4Describe "CimInstance cmdlet tests" -Tag @("CI") {5    BeforeAll {6        if ( ! $IsWindows ) { return }7        $instance = Get-CimInstance CIM_ComputerSystem8    }9 10    It "CimClass property should not be null" -Pending:(-not $IsWindows) {11        # we can't use equals here as on windows cimclassname12        # is win32_computersystem, but that's not likely to be the13        # case on non-Windows systems14        $instance.CimClass.CimClassName | Should -Match _computersystem15    }16 17    It "Property access should be case insensitive" -Pending:(-not $IsWindows) {18        foreach($property in $instance.psobject.properties.name) {19            $pUpper = $property.ToUpper()20            $pLower = $property.ToLower()21            [string]$pLowerValue = $instance.$pLower -join ","22            [string]$pUpperValue = $instance.$pUpper -join ","23            $pLowerValue | Should -BeExactly $pUpperValue24        }25    }26 27    It "GetCimSessionInstanceId method invocation should return data" -Pending:(-not $IsWindows) {28        $instance.GetCimSessionInstanceId() | Should -BeOfType Guid29    }30 31    It "should produce an error for a non-existing classname" -Pending:(-not $IsWindows) {32        { Get-CimInstance -ClassName thisnameshouldnotexist -ErrorAction Stop } |33            Should -Throw -ErrorId "HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand"34    }35}36