Files
PowerShell-PowerShell/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1
T
Aditya Patwardhan 486fb97123 Test fixes and code coverage automation fixes. (#5046)
* Test fixes and updates to code coverage automation
* Fixed UpdatableHelpSystem tests and tab completion tests
* Fixed tab completion tests to better disambiguate root/interop namespace.
* Skip SSH test if ssh.exe is not present
2017-10-13 13:54:43 -07:00

49 lines
2.0 KiB
PowerShell

Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') {
It "Should support -IncludeUserName" {
(Get-Process -Id $pid -IncludeUserName).UserName | Should Match $env:USERNAME
}
}
Describe "Get-Process" -Tags "CI" {
# These tests are no good, please replace!
BeforeAll {
$ps = Get-Process
}
It "Should return a type of Object[] for Get-Process cmdlet" -Pending:$IsMacOS {
,$ps | Should BeOfType "System.Object[]"
}
It "Should have not empty Name flags set for Get-Process object" -Pending:$IsMacOS {
$ps | foreach-object { $_.Name | Should Not BeNullOrEmpty }
}
}
Describe "Get-Process Formatting" -Tags "Feature" {
It "Should not have Handle in table format header" {
$types = "System.Diagnostics.Process","System.Diagnostics.Process#IncludeUserName"
foreach ($type in $types) {
$formatData = Get-FormatData -TypeName $type -PowerShellVersion $PSVersionTable.PSVersion
$tableControls = $formatData.FormatViewDefinition | Where-Object {$_.Control -is "System.Management.Automation.TableControl"}
foreach ($tableControl in $tableControls) {
$tableControl.Control.Headers.Label -match "Handle*" | Should BeNullOrEmpty
# verify that rows without headers isn't the handlecount (as PowerShell will create a header that matches the property name)
$tableControl.Control.Rows.Columns.DisplayEntry.Value -eq "HandleCount" | Should BeNullOrEmpty
}
}
}
}
Describe "Process Parent property" -Tags "CI" {
It "Has Parent process property" {
$powershellexe = (get-process -id $PID).mainmodule.filename
& $powershellexe -noprofile -command '(Get-Process -Id $pid).Parent' | Should Not be $null
}
It "Has valid parent process ID property" {
$powershellexe = (get-process -id $PID).mainmodule.filename
& $powershellexe -noprofile -command '(Get-Process -Id $pid).Parent.Id' | Should Be $pid
}
}