mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Add tests for 'New-Object -ComObject' (#4776)
This commit is contained in:
1 parent
3815a95242
commit
a3e193a6b3
1 file changed
+36
@@ -165,3 +165,39 @@ Describe "New-Object DRT basic functionality" -Tags "CI" {
|
||||
$result.foo | Should Be 123
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$defaultParamValues = $PSdefaultParameterValues.Clone()
|
||||
$PSDefaultParameterValues["it:skip"] = ![System.Management.Automation.Platform]::IsWindowsDesktop
|
||||
|
||||
Describe "New-Object COM functionality" -Tags "CI" {
|
||||
$testCases = @(
|
||||
@{
|
||||
Name = 'Microsoft.Update.AutoUpdate'
|
||||
Property = 'Settings'
|
||||
Type = 'Object'
|
||||
}
|
||||
@{
|
||||
Name = 'Microsoft.Update.SystemInfo'
|
||||
Property = 'RebootRequired'
|
||||
Type = 'Bool'
|
||||
}
|
||||
)
|
||||
|
||||
It "Should be able to create <Name> with property <Property> of Type <Type>" -TestCases $testCases {
|
||||
param($Name, $Property, $Type)
|
||||
$comObject = New-Object -ComObject $name
|
||||
$comObject.$Property | should not be $null
|
||||
$comObject.$Property | should beoftype $Type
|
||||
}
|
||||
|
||||
It "Should fail with correct error when creating a COM object that dose not exist" {
|
||||
{New-Object -ComObject 'doesnotexist'} | shouldBeErrorId 'NoCOMClassIdentified,Microsoft.PowerShell.Commands.NewObjectCommand'
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
$global:PSdefaultParameterValues = $defaultParamValues
|
||||
}
|
||||
Reference in new issue
Block a user