From a3ed623c645735786cd757f0af73314b47f6e356 Mon Sep 17 00:00:00 2001 From: JumpingYang001 Date: Wed, 6 Apr 2016 01:24:00 -0700 Subject: [PATCH 1/2] Add New-Alias Pester and update Set-Alias Pester test --- test/powershell/New-Alias.Tests.ps1 | 40 +++++++++++++++++++++++++++++ test/powershell/Set-Alias.Tests.ps1 | 8 +++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/test/powershell/New-Alias.Tests.ps1 b/test/powershell/New-Alias.Tests.ps1 index 2a8d164d2..b2712d13b 100644 --- a/test/powershell/New-Alias.Tests.ps1 +++ b/test/powershell/New-Alias.Tests.ps1 @@ -1,3 +1,43 @@ +Describe "New-Alias DRT Unit Tests" -Tags DRT{ + It "New-Alias Constant should throw SessionStateException"{ + 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 diff --git a/test/powershell/Set-Alias.Tests.ps1 b/test/powershell/Set-Alias.Tests.ps1 index e4e00e8e4..0865a27df 100644 --- a/test/powershell/Set-Alias.Tests.ps1 +++ b/test/powershell/Set-Alias.Tests.ps1 @@ -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" From c4421eaa300849039dc12c037cc44ed882ce2fa7 Mon Sep 17 00:00:00 2001 From: JumpingYang001 Date: Wed, 6 Apr 2016 19:57:05 -0700 Subject: [PATCH 2/2] Update Skip bug 777 for New-Alias Pester unit test --- test/powershell/New-Alias.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/New-Alias.Tests.ps1 b/test/powershell/New-Alias.Tests.ps1 index b2712d13b..279233419 100644 --- a/test/powershell/New-Alias.Tests.ps1 +++ b/test/powershell/New-Alias.Tests.ps1 @@ -1,5 +1,5 @@ Describe "New-Alias DRT Unit Tests" -Tags DRT{ - It "New-Alias Constant should throw SessionStateException"{ + 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