Files
PowerShell-PowerShell/test/powershell/Modules/Microsoft.PowerShell.Management/Get-Process.Tests.ps1
T
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00

51 lines
2.1 KiB
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
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
}
}