Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/powershell/Language/Scripting/Indexer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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' {
Expand Down