forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoke-Expression.Tests.ps1
More file actions
35 lines (30 loc) · 1.2 KB
/
Copy pathInvoke-Expression.Tests.ps1
File metadata and controls
35 lines (30 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Describe "Invoke-Expression" -Tags "CI" {
Context "Should execute the invoked command validly" {
It "Should return the echoed text" {
(Invoke-Expression -command "echo pestertest1") | Should be "pestertest1"
}
It "Should return the echoed text for the alias" {
(iex -command "echo pestertest2") | Should Be "pestertest2"
}
It "Should return the echoed text from a script" {
$testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1
$testcommand = "echo pestertestscript"
$testcommand | Add-Content -Path "$testfile"
(Invoke-Expression "& '$testfile'") | Should Be "pestertestscript"
Remove-Item "$testfile"
}
It "Should return the echoed text from a script from the alias" {
$testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1
$testcommand = "echo pestertestscript"
$testcommand | Add-Content -Path "$testfile"
(iex "& '$testfile'") | Should Be "pestertestscript"
Remove-Item "$testfile"
}
}
}
Describe "Invoke-Expression DRT Unit Tests" -Tags "CI" {
It "Invoke-Expression should work"{
$result=invoke-expression -Command 2+2
$result|Should Be 4
}
}