diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/Pester.Commands.Cmdlets.GetCommand.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/Pester.Commands.Cmdlets.GetCommand.Tests.ps1 index 2f34d040d5..f54cfe04dd 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/Pester.Commands.Cmdlets.GetCommand.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/Pester.Commands.Cmdlets.GetCommand.Tests.ps1 @@ -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" { @@ -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 - " -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' + } + }