add tests for get-command -ShowCommandInfo#4906
Conversation
There was a problem hiding this comment.
I suggest the following, so that we will see what is not matched in the output.
It 'Get-Command -ShowCommandInfo property field test' {
$commandInfo = Get-Command Get-Date -ShowCommandInfo
$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'
}There was a problem hiding this comment.
This should also be structured like the comment above.
There was a problem hiding this comment.
This should also be structured like the comment above.
There was a problem hiding this comment.
This should be BeExactly
There was a problem hiding this comment.
This seems to be doing Get-Command Get-Date -ShowCommandInfo a lot. This should be done once in BeforeAll and then used everywhere.
b087348 to
f6f649d
Compare
|
@adityapatwardhan thanks, your comment is addressed |
There was a problem hiding this comment.
since you executed Get-Command Get-Date -ShowCommandInfo couldn't this just be:
$testcases = @{observed = $commandInfo.Name; testname = "Name"; result = "Get-Date"},
@{observed = $commandInfo.ModuleName; testname = "ModuleName"; result = "Microsoft.PowerShell.Utility"},
@{observed = $commandInfo.Module.Name; testname = "Module"; result = "Microsoft.PowerShell.Utility"},
@{observed = $commandInfo.CommandType; testname = "CommandType"; result = "Cmdlet"},
@{observed = $commandInfo.Definition.Count; testname = "Definition"; result = 1}
It "Get-Command -ShowCommand property test - <testname>" -testcase $testcases {
param ( $observed, $result, $testname )
$observed | Should beExactly $result
}I'm not sure you need to executed Get-Command over and over
f6f649d to
bb5b1ef
Compare
|
@JamesWTruher thanks jim, your comment is resolved |
bb5b1ef to
eee0ece
Compare
|
@JamesWTruher Can you have another look? |
|
@JamesWTruher ping.. |
this is to resolve #4163
added tests for get-command -ShowCommandInfo