mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Use new Pester syntax: -Parameter for Pester tests in Modules/CimCmdlets (#6306)
* Use new Pester syntax: -Parameter for Pester tests in Modules/CimCmdlets.
This commit is contained in:
committed by
Aditya Patwardhan
parent
30e9e309dc
commit
740c075704
@@ -13,7 +13,7 @@ Try {
|
||||
# we can't use equals here as on windows cimclassname
|
||||
# is win32_computersystem, but that's not likely to be the
|
||||
# case on non-Windows systems
|
||||
$instance.cimClass.CimClassName | should match _computersystem
|
||||
$instance.cimClass.CimClassName | Should -Match _computersystem
|
||||
}
|
||||
It "Property access should be case insensitive" {
|
||||
foreach($property in $instance.psobject.properties.name) {
|
||||
@@ -21,11 +21,11 @@ Try {
|
||||
$pLower = $property.ToLower()
|
||||
[string]$pLowerValue = $pinstance.$pLower -join ","
|
||||
[string]$pUpperValue = $pinstance.$pUpper -join ","
|
||||
$pLowerValue | should be $pUpperValue
|
||||
$pLowerValue | Should -BeExactly $pUpperValue
|
||||
}
|
||||
}
|
||||
It "GetCimSessionInstanceId method invocation should return data" {
|
||||
$instance.GetCimSessionInstanceId() | Should BeOfType "Guid"
|
||||
$instance.GetCimSessionInstanceId() | Should -BeOfType "Guid"
|
||||
}
|
||||
It "should produce an error for a non-existing classname" {
|
||||
try {
|
||||
@@ -33,7 +33,7 @@ Try {
|
||||
throw "expected error did not occur"
|
||||
}
|
||||
catch {
|
||||
$_.FullyQualifiedErrorId | should be "HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand"
|
||||
$_.FullyQualifiedErrorId | Should -Be "HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,24 +20,24 @@ try {
|
||||
$sessionName = [guid]::NewGuid()
|
||||
$session = New-CimSession -ComputerName . -name $sessionName
|
||||
$sessions += $session
|
||||
$session.Name | Should be $sessionName
|
||||
$session.InstanceId | should BeOfType "System.Guid"
|
||||
$session.Name | Should -Be $sessionName
|
||||
$session.InstanceId | Should -BeOfType "System.Guid"
|
||||
}
|
||||
It "A Cim session can be retrieved" {
|
||||
$sessionName = [guid]::NewGuid()
|
||||
$session = New-CimSession -ComputerName . -name $sessionName
|
||||
$sessions += $session
|
||||
(get-cimsession -Name $sessionName).InstanceId | should be $session.InstanceId
|
||||
(get-cimsession -Id $session.Id).InstanceId | should be $session.InstanceId
|
||||
(get-cimsession -InstanceId $session.InstanceId).InstanceId | should be $session.InstanceId
|
||||
(get-cimsession -Name $sessionName).InstanceId | Should -Be $session.InstanceId
|
||||
(get-cimsession -Id $session.Id).InstanceId | Should -Be $session.InstanceId
|
||||
(get-cimsession -InstanceId $session.InstanceId).InstanceId | Should -Be $session.InstanceId
|
||||
}
|
||||
It "A cim session can be removed" {
|
||||
$sessionName = [guid]::NewGuid()
|
||||
$session = New-CimSession -ComputerName . -name $sessionName
|
||||
$sessions += $session
|
||||
$session.Name | Should be $sessionName
|
||||
$session.Name | Should -Be $sessionName
|
||||
$session | Remove-CimSession
|
||||
Get-CimSession $session.Id -ErrorAction SilentlyContinue | should BeNullOrEmpty
|
||||
Get-CimSession $session.Id -ErrorAction SilentlyContinue | Should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ try {
|
||||
|
||||
Describe 'Get-CimClass' -tags "CI" {
|
||||
It 'can get CIM_Error CIM class' {
|
||||
Get-CimClass -ClassName CIM_Error | Should Not BeNullOrEmpty
|
||||
Get-CimClass -ClassName CIM_Error | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
It 'can get class when namespace is specified' {
|
||||
Get-CimClass -ClassName CIM_OperatingSystem -Namespace root/cimv2 | Should Not BeNullOrEmpty
|
||||
Get-CimClass -ClassName CIM_OperatingSystem -Namespace root/cimv2 | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'produces an error when a non-existent class is used' {
|
||||
@@ -20,7 +20,7 @@ try {
|
||||
throw "Expected error did not occur"
|
||||
}
|
||||
catch {
|
||||
$_.FullyQualifiedErrorId | should be "HRESULT 0x80041002,Microsoft.Management.Infrastructure.CimCmdlets.GetCimClassCommand"
|
||||
$_.FullyQualifiedErrorId | Should -Be "HRESULT 0x80041002,Microsoft.Management.Infrastructure.CimCmdlets.GetCimClassCommand"
|
||||
}
|
||||
}
|
||||
It 'produces an error when an improper namespace is used' {
|
||||
@@ -29,7 +29,7 @@ try {
|
||||
throw "Expected error did not occur"
|
||||
}
|
||||
catch {
|
||||
$_.FullyQualifiedErrorId | should be "HRESULT 0x8004100e,Microsoft.Management.Infrastructure.CimCmdlets.GetCimClassCommand"
|
||||
$_.FullyQualifiedErrorId | Should -Be "HRESULT 0x8004100e,Microsoft.Management.Infrastructure.CimCmdlets.GetCimClassCommand"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ try {
|
||||
# feature tests
|
||||
Describe 'Get-CimClass' -tags @("Feature") {
|
||||
It 'can retrieve a class when a method is provided' {
|
||||
Get-CimClass -MethodName Reboot | Should Not BeNullOrEmpty
|
||||
Get-CimClass -MethodName Reboot | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user