Merge pull request #774 from PowerShell/AliasPesterUnitTest

Add New-Alias Pester and update Set-Alias Pester test
This commit is contained in:
James Truher [MSFT] 2016-04-07 13:10:53 -07:00
commit 62ebca1281
2 changed files with 44 additions and 4 deletions

View file

@ -1,3 +1,43 @@
Describe "New-Alias DRT Unit Tests" -Tags DRT{
It "New-Alias Constant should throw SessionStateException skip now as bug#777" -Skip:$true{
try {
New-Alias -Name "ABCD" -Value "foo" -Option "Constant" -Force:$true
New-Alias -Name "ABCD" -Value "foo" -Force:$true
Throw "Execution OK"
}
catch {
$_.FullyQualifiedErrorId | Should be "AliasNotWritable,Microsoft.PowerShell.Commands.NewAliasCommand"
}
}
It "New-Alias NamePositional And Value Valid" {
New-Alias ABCD -Value "MyCommand" -Scope "0"
$result=Get-Alias -Name ABCD -Scope "0"
$result.Name| Should Be "ABCD"
$result.Definition| Should Be "MyCommand"
$result.Description| Should Be ""
$result.Options| Should Be "None"
}
It "New-Alias NamePositional And ValuePositional Valid" {
New-Alias ABCD "MyCommand" -Scope "0"
$result=Get-Alias -Name ABCD -Scope "0"
$result.Name| Should Be "ABCD"
$result.Definition| Should Be "MyCommand"
$result.Description| Should Be ""
$result.Options| Should Be "None"
}
It "New-Alias Description Valid" {
New-Alias -Name ABCD -Value "MyCommand" -Description "test description" -Scope "0"
$result=Get-Alias -Name ABCD -Scope "0"
$result.Name| Should Be "ABCD"
$result.Definition| Should Be "MyCommand"
$result.Description| Should Be "test description"
$result.Options| Should Be "None"
}
}
Describe "New-Alias" {
It "Should be able to be called using the name and value parameters without error" {
{ New-Alias -Name testAlias -Value 100 } | Should Not Throw

View file

@ -11,14 +11,14 @@ Describe "Set-Alias DRT Unit Tests" -Tags DRT{
}
It "Set-Alias ReadOnly Force"{
Set-Alias -Name ABCD -Value "foo" -Option ReadOnly -PassThru:$true
Set-Alias -Name ABCD -Value "foo" -Option ReadOnly -Force:$true
$result=Get-Alias -Name ABCD
$result.Name| Should Be "ABCD"
$result.Definition| Should Be "foo"
$result.Description| Should Be ""
$result.Options| Should Be "ReadOnly"
Set-Alias -Name ABCD -Value "foo" -Force:$true -PassThru:$true
Set-Alias -Name ABCD -Value "foo" -Force:$true
$result=Get-Alias -Name ABCD
$result.Name| Should Be "ABCD"
$result.Definition| Should Be "foo"
@ -51,8 +51,8 @@ Describe "Set-Alias DRT Unit Tests" -Tags DRT{
$result.Options| Should Be "None"
}
It "Set-Alias Scope Valid"{
Set-Alias -Name ABCD -Value "localfoo" -scope local -PassThru:$true
Set-Alias -Name ABCD -Value "foo1" -scope "1" -PassThru:$true
Set-Alias -Name ABCD -Value "localfoo" -scope local -Force:$true
Set-Alias -Name ABCD -Value "foo1" -scope "1" -Force:$true
$result=Get-Alias -Name ABCD
$result.Name| Should Be "ABCD"