forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-Item.Tests.ps1
More file actions
17 lines (16 loc) · 989 Bytes
/
Copy pathSet-Item.Tests.ps1
File metadata and controls
17 lines (16 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Describe "Set-Item" -Tag "CI" {
$testCases = @{ Path = "variable:SetItemTestCase"; Value = "TestData"; Validate = { $SetItemTestCase | Should be "TestData" }; Reset = {remove-item variable:SetItemTestCase} },
@{ Path = "alias:SetItemTestCase"; Value = "Get-Alias"; Validate = { (Get-Alias SetItemTestCase).Definition | should be "Get-Alias"}; Reset = { remove-item alias:SetItemTestCase } },
@{ Path = "function:SetItemTestCase"; Value = { 1 }; Validate = { SetItemTestCase | should be 1 }; Reset = { remove-item function:SetItemTestCase } },
@{ Path = "env:SetItemTestCase"; Value = { 1 }; Validate = { $env:SetItemTestCase | should be 1 }; Reset = { remove-item env:SetItemTestCase } }
It "Set-Item should be able to handle <Path>" -TestCase $testCases {
param ( $Path, $Value, $Validate, $Reset )
Set-item -path $path -Value $value
try {
& $Validate
}
finally {
& $reset
}
}
}