mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Merge branch 'master' into UnitTest_Temp
This commit is contained in:
commit
9733f5e8e7
157 files changed
+18618
-707
No files matched your search
@@ -1,5 +1,5 @@
|
||||
Describe "Add-Type" {
|
||||
It "Should not throw given a simple class definition" {
|
||||
It "Should not throw given a simple class definition" -Skip {
|
||||
{ Add-Type -TypeDefinition "public static class foo { }" } | Should Not Throw
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,6 @@
|
||||
# While Core PowerShell does not support the JSON cmdlets, a third
|
||||
# party C# library, [Json.NET](http://www.newtonsoft.com/json), can be
|
||||
# loaded into PowerShell and used directly.
|
||||
|
||||
# http://www.newtonsoft.com/json/help/html/ParsingLINQtoJSON.htm
|
||||
|
||||
Describe "Json.NET LINQ Parsing" {
|
||||
# load third party Json.NET library
|
||||
$base = [System.AppContext]::BaseDirectory
|
||||
$path = Join-Path $base Newtonsoft.Json.dll
|
||||
[Microsoft.PowerShell.CoreCLR.AssemblyExtensions]::LoadFrom($path)
|
||||
|
||||
BeforeEach {
|
||||
$jsonFile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath TestJson.json
|
||||
$jsonData = (Get-Content $jsonFile | Out-String)
|
||||
|
||||
@@ -154,4 +154,4 @@ Running Pester Tests
|
||||
--------------------
|
||||
|
||||
Go to the top level of the PowerShell repository and run:
|
||||
`./bin/powershell -c "Invoke-Pester test/powershell"`
|
||||
`Start-PSPester` inside a self-hosted copy of PowerShell.
|
||||
@@ -1,3 +1,88 @@
|
||||
|
||||
Describe "Set-Alias DRT Unit Tests" -Tags DRT{
|
||||
It "Set-Alias Invalid Scope Name should throw PSArgumentException"{
|
||||
try {
|
||||
Set-Alias -Name "ABCD" -Value "foo" -Scope "bogus"
|
||||
Throw "Execution OK"
|
||||
}
|
||||
catch {
|
||||
$_.FullyQualifiedErrorId | Should be "Argument,Microsoft.PowerShell.Commands.SetAliasCommand"
|
||||
}
|
||||
}
|
||||
|
||||
It "Set-Alias ReadOnly Force"{
|
||||
Set-Alias -Name ABCD -Value "foo" -Option ReadOnly -PassThru:$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
|
||||
$result=Get-Alias -Name ABCD
|
||||
$result.Name| Should Be "ABCD"
|
||||
$result.Definition| Should Be "foo"
|
||||
$result.Description| Should Be ""
|
||||
$result.Options| Should Be "None"
|
||||
}
|
||||
|
||||
It "Set-Alias Name And Value Valid"{
|
||||
Set-Alias -Name ABCD -Value "MyCommand"
|
||||
$result=Get-Alias -Name ABCD
|
||||
$result.Name| Should Be "ABCD"
|
||||
$result.Definition| Should Be "MyCommand"
|
||||
$result.Description| Should Be ""
|
||||
$result.Options| Should Be "None"
|
||||
}
|
||||
It "Set-Alias Name And Value Positional Valid"{
|
||||
Set-Alias -Name ABCD "foo"
|
||||
$result=Get-Alias ABCD
|
||||
$result.Name| Should Be "ABCD"
|
||||
$result.Definition| Should Be "foo"
|
||||
$result.Description| Should Be ""
|
||||
$result.Options| Should Be "None"
|
||||
}
|
||||
It "Set-Alias Description Valid"{
|
||||
Set-Alias -Name ABCD -Value "MyCommand" -Description "test description"
|
||||
$result=Get-Alias -Name ABCD
|
||||
$result.Name| Should Be "ABCD"
|
||||
$result.Definition| Should Be "MyCommand"
|
||||
$result.Description| Should Be "test description"
|
||||
$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
|
||||
|
||||
$result=Get-Alias -Name ABCD
|
||||
$result.Name| Should Be "ABCD"
|
||||
$result.Definition| Should Be "localfoo"
|
||||
$result.Description| Should Be ""
|
||||
$result.Options| Should Be "None"
|
||||
|
||||
$result=Get-Alias -Name ABCD -scope local
|
||||
$result.Name| Should Be "ABCD"
|
||||
$result.Definition| Should Be "localfoo"
|
||||
$result.Description| Should Be ""
|
||||
$result.Options| Should Be "None"
|
||||
|
||||
$result=Get-Alias -Name ABCD -scope "1"
|
||||
$result.Name| Should Be "ABCD"
|
||||
$result.Definition| Should Be "foo1"
|
||||
$result.Description| Should Be ""
|
||||
$result.Options| Should Be "None"
|
||||
}
|
||||
It "Set-Alias Expose Bug 1062958, BugId:905449"{
|
||||
try {
|
||||
Set-Alias -Name "ABCD" -Value "foo" -Scope "-1"
|
||||
Throw "Execution OK"
|
||||
}
|
||||
catch {
|
||||
$_.FullyQualifiedErrorId | Should be "ArgumentOutOfRange,Microsoft.PowerShell.Commands.SetAliasCommand"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Set-Alias" {
|
||||
Mock Get-Date { return "Friday, October 30, 2015 3:38:08 PM" }
|
||||
It "Should be able to set alias without error" {
|
||||
|
||||
Reference in new issue
Block a user