Skip to content

add tests for get-command -ShowCommandInfo#4906

Merged
adityapatwardhan merged 1 commit into
PowerShell:masterfrom
chunqingchen:getcommandtest
Oct 2, 2017
Merged

add tests for get-command -ShowCommandInfo#4906
adityapatwardhan merged 1 commit into
PowerShell:masterfrom
chunqingchen:getcommandtest

Conversation

@chunqingchen

Copy link
Copy Markdown
Contributor

this is to resolve #4163

added tests for get-command -ShowCommandInfo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' 
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be structured like the comment above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be structured like the comment above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be BeExactly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be doing Get-Command Get-Date -ShowCommandInfo a lot. This should be done once in BeforeAll and then used everywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@chunqingchen

Copy link
Copy Markdown
Contributor Author

@adityapatwardhan thanks, your comment is addressed

@adityapatwardhan adityapatwardhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@chunqingchen

Copy link
Copy Markdown
Contributor Author

@JamesWTruher thanks jim, your comment is resolved

@adityapatwardhan

Copy link
Copy Markdown
Member

@JamesWTruher Can you have another look?

@adityapatwardhan

Copy link
Copy Markdown
Member

@JamesWTruher ping..

@adityapatwardhan adityapatwardhan merged commit 69bce66 into PowerShell:master Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for Get-Command -ShowCommandInfo

5 participants