diff --git a/test/powershell/New-Alias.Tests.ps1 b/test/powershell/New-Alias.Tests.ps1 index 2a8d164d2d..b2712d13ba 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 e4e00e8e4e..0865a27df4 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"