Use CIM cmdlets instead of WMI cmdlets in tests (#11423)
This commit is contained in:
parent
59db1f619e
commit
ee71081432
|
@ -12,17 +12,17 @@ Describe 'Tests for indexers' -Tags "CI" {
|
|||
$hashtable["Hello There"] | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'Wmi object implements an indexer' -Skip:$IsCoreCLR {
|
||||
It 'CimClass implements an indexer' -Skip:(-not $IsWindows) {
|
||||
|
||||
$service = Get-WmiObject -List -Amended Win32_Service
|
||||
$service = Get-CimClass -ClassName Win32_Service
|
||||
|
||||
$service.Properties["DisplayName"].Name | Should -BeExactly 'DisplayName'
|
||||
$service.CimClassProperties["DisplayName"].Name | Should -BeExactly 'DisplayName'
|
||||
}
|
||||
|
||||
It 'Accessing a Indexed property of a wmi object that does not exist should return $NULL' -skip:$IsCoreCLR {
|
||||
It 'Accessing a Indexed property of a CimClass that does not exist should return $NULL' -Skip:(-not $IsWindows) {
|
||||
|
||||
$service = Get-WmiObject -List -Amended Win32_Service
|
||||
$service.Properties["Hello There"] | Should -BeNullOrEmpty
|
||||
$service = Get-CimClass -ClassName Win32_Service
|
||||
$service.CimClassProperties["Hello There"] | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'ITuple implementations can be indexed' {
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
Describe 'Test for cmdlet to support Ordered Attribute on hash literal nodes' -Tags "CI" {
|
||||
BeforeAll {
|
||||
If (-not $IsCoreCLR) {
|
||||
Get-WmiObject -Query "select * from win32_environment where name='TestWmiInstance'" | Remove-WmiObject
|
||||
}
|
||||
}
|
||||
AfterAll {
|
||||
If (-not $IsCoreCLR) {
|
||||
Get-WmiObject -Query "select * from win32_environment where name='TestWmiInstance'" | Remove-WmiObject
|
||||
}
|
||||
}
|
||||
|
||||
It 'New-Object - Property Parameter Must take IDictionary' {
|
||||
$a = new-object psobject -property ([ordered]@{one=1;two=2})
|
||||
$a | Should -Not -BeNullOrEmpty
|
||||
|
@ -45,15 +34,30 @@ Describe 'Test for cmdlet to support Ordered Attribute on hash literal nodes' -T
|
|||
It '$a should not be $null' { $script:a | Should -Not -BeNullOrEmpty }
|
||||
}
|
||||
|
||||
It 'Set-WmiInstance cmdlet - Argument parameter must take IDictionary' -skip:$IsCoreCLR {
|
||||
Context 'New-CimInstance cmdlet' {
|
||||
BeforeAll {
|
||||
If ($IsWindows) {
|
||||
Get-CimInstance -ClassName Win32_Environment -Filter "name='TestCimInstance'" | Remove-CimInstance
|
||||
}
|
||||
}
|
||||
AfterAll {
|
||||
If ($IsWindows) {
|
||||
Get-CimInstance -ClassName Win32_Environment -Filter "name='TestCimInstance'" | Remove-CimInstance
|
||||
}
|
||||
}
|
||||
|
||||
$script:a = $null
|
||||
It 'Property parameter must take IDictionary' -Skip:(-not $IsWindows) {
|
||||
|
||||
{ $script:a = set-wmiinstance -class win32_environment -argument ([ordered]@{Name="TestWmiInstance";
|
||||
VariableValue="testvalu234e";
|
||||
UserName="<SYSTEM>"}) } | Should -Not -Throw
|
||||
$script:a | Should -Not -BeNullOrEmpty
|
||||
$script:a.Name | Should -BeExactly "TestWmiInstance"
|
||||
$script:a = $null
|
||||
|
||||
{ $script:a = New-CimInstance -ClassName Win32_Environment -Property ([ordered]@{
|
||||
Name="TestCimInstance";
|
||||
VariableValue="testvalu234e";
|
||||
UserName=[System.Environment]::UserName
|
||||
}) -ClientOnly } | Should -Not -Throw
|
||||
$script:a | Should -Not -BeNullOrEmpty
|
||||
$script:a.Name | Should -BeExactly "TestCimInstance"
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Select-Object cmdlet - Property parameter (Calculated properties) must take IDictionary' {
|
||||
|
|
Loading…
Reference in a new issue