Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
/bin/chmod 777 "$file1"
/bin/chmod 777 "$file2"
}
$commandInfo = Get-Command Get-Date -ShowCommandInfo
}

It "Test wildcard with drive relative directory path" {
Expand Down Expand Up @@ -49,4 +50,52 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
Pop-Location
}

It "Get-Command -ShowCommandInfo property field test" {
$properties = ($commandInfo | Get-Member -MemberType NoteProperty)
$propertiesAsString = $properties.name | out-string
$propertiesAsString | Should MatchExactly 'CommandType'
$propertiesAsString | Should MatchExactly 'Definition'
$propertiesAsString | Should MatchExactly 'Module'
$propertiesAsString | Should MatchExactly 'ModuleName'
$propertiesAsString | Should MatchExactly 'Name'
$propertiesAsString | Should MatchExactly 'ParameterSets'
}

$testcases = @(
@{observed = $commandInfo.Name; testname = "Name"; result = "Get-Date"}
@{observed = $commandInfo.ModuleName; testname = "Name"; result = "Microsoft.PowerShell.Utility"}
@{observed = $commandInfo.Module.Name; testname = "ModuleName"; result = "Microsoft.PowerShell.Utility"}
@{observed = $commandInfo.CommandType; testname = "CommandType"; result = "Cmdlet"}
@{observed = $commandInfo.Definition.Count; testname = "Definition"; result = 1}
)

It "Get-Command -ShowCommandInfo property test - <testname>" -TestCases $testcases{
param (
$observed,
$result
)
$observed | Should BeExactly $result
}


It "Get-Command -ShowCommandInfo ParameterSets property field test" {
$properties = ($commandInfo.ParameterSets[0] | Get-Member -MemberType NoteProperty)
$propertiesAsString = $properties.name | out-string
$propertiesAsString | Should MatchExactly 'IsDefault'
$propertiesAsString | Should MatchExactly 'Name'
$propertiesAsString | Should MatchExactly 'Parameters'
}

It "Get-Command -ShowCommandInfo Parameters property field test" {
$properties = ($commandInfo.ParameterSets[0].Parameters | Get-Member -MemberType NoteProperty)
$propertiesAsString = $properties.name | out-string
$propertiesAsString | Should MatchExactly 'HasParameterSet'
$propertiesAsString | Should MatchExactly 'IsMandatory'
$propertiesAsString | Should MatchExactly 'Name'
$propertiesAsString | Should MatchExactly 'ParameterType'
$propertiesAsString | Should MatchExactly 'Position'
$propertiesAsString | Should MatchExactly 'ValidParamSetValues'
$propertiesAsString | Should MatchExactly 'ValueFromPipeline'
}

}