@@ -14,6 +14,7 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
14
14
/ bin/ chmod 777 " $file1 "
15
15
/ bin/ chmod 777 " $file2 "
16
16
}
17
+ $commandInfo = Get-Command Get-Date - ShowCommandInfo
17
18
}
18
19
19
20
It " Test wildcard with drive relative directory path" {
@@ -49,4 +50,52 @@ Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
49
50
Pop-Location
50
51
}
51
52
53
+ It " Get-Command -ShowCommandInfo property field test" {
54
+ $properties = ($commandInfo | Get-Member - MemberType NoteProperty)
55
+ $propertiesAsString = $properties.name | out-string
56
+ $propertiesAsString | Should MatchExactly ' CommandType'
57
+ $propertiesAsString | Should MatchExactly ' Definition'
58
+ $propertiesAsString | Should MatchExactly ' Module'
59
+ $propertiesAsString | Should MatchExactly ' ModuleName'
60
+ $propertiesAsString | Should MatchExactly ' Name'
61
+ $propertiesAsString | Should MatchExactly ' ParameterSets'
62
+ }
63
+
64
+ $testcases = @ (
65
+ @ {observed = $commandInfo.Name ; testname = " Name" ; result = " Get-Date" }
66
+ @ {observed = $commandInfo.ModuleName ; testname = " Name" ; result = " Microsoft.PowerShell.Utility" }
67
+ @ {observed = $commandInfo.Module.Name ; testname = " ModuleName" ; result = " Microsoft.PowerShell.Utility" }
68
+ @ {observed = $commandInfo.CommandType ; testname = " CommandType" ; result = " Cmdlet" }
69
+ @ {observed = $commandInfo.Definition.Count ; testname = " Definition" ; result = 1 }
70
+ )
71
+
72
+ It " Get-Command -ShowCommandInfo property test - <testname>" - TestCases $testcases {
73
+ param (
74
+ $observed ,
75
+ $result
76
+ )
77
+ $observed | Should BeExactly $result
78
+ }
79
+
80
+
81
+ It " Get-Command -ShowCommandInfo ParameterSets property field test" {
82
+ $properties = ($commandInfo.ParameterSets [0 ] | Get-Member - MemberType NoteProperty)
83
+ $propertiesAsString = $properties.name | out-string
84
+ $propertiesAsString | Should MatchExactly ' IsDefault'
85
+ $propertiesAsString | Should MatchExactly ' Name'
86
+ $propertiesAsString | Should MatchExactly ' Parameters'
87
+ }
88
+
89
+ It " Get-Command -ShowCommandInfo Parameters property field test" {
90
+ $properties = ($commandInfo.ParameterSets [0 ].Parameters | Get-Member - MemberType NoteProperty)
91
+ $propertiesAsString = $properties.name | out-string
92
+ $propertiesAsString | Should MatchExactly ' HasParameterSet'
93
+ $propertiesAsString | Should MatchExactly ' IsMandatory'
94
+ $propertiesAsString | Should MatchExactly ' Name'
95
+ $propertiesAsString | Should MatchExactly ' ParameterType'
96
+ $propertiesAsString | Should MatchExactly ' Position'
97
+ $propertiesAsString | Should MatchExactly ' ValidParamSetValues'
98
+ $propertiesAsString | Should MatchExactly ' ValueFromPipeline'
99
+ }
100
+
52
101
}
0 commit comments