2016-07-25 14:01:41 -07:00
|
|
|
Describe "Invoke-Expression" -Tags "CI" {
|
2016-03-04 14:52:27 -08:00
|
|
|
|
2015-11-19 06:21:47 +00:00
|
|
|
Context "Should execute the invoked command validly" {
|
|
|
|
|
|
2016-03-04 14:52:27 -08:00
|
|
|
It "Should return the echoed text" {
|
|
|
|
|
(Invoke-Expression -command "echo pestertest1") | Should be "pestertest1"
|
|
|
|
|
}
|
2015-11-19 06:21:47 +00:00
|
|
|
|
2016-03-04 14:52:27 -08:00
|
|
|
It "Should return the echoed text for the alias" {
|
|
|
|
|
(iex -command "echo pestertest2") | Should Be "pestertest2"
|
|
|
|
|
}
|
2015-11-19 06:21:47 +00:00
|
|
|
|
2016-03-04 14:52:27 -08:00
|
|
|
It "Should return the echoed text from a script" {
|
|
|
|
|
$testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1
|
|
|
|
|
$testcommand = "echo pestertestscript"
|
2016-08-22 06:57:30 -07:00
|
|
|
$testcommand | Add-Content -Path "$testfile"
|
|
|
|
|
(Invoke-Expression "& '$testfile'") | Should Be "pestertestscript"
|
|
|
|
|
Remove-Item "$testfile"
|
2016-03-04 14:52:27 -08:00
|
|
|
}
|
2015-11-19 06:21:47 +00:00
|
|
|
|
2016-03-04 14:52:27 -08:00
|
|
|
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"
|
2016-08-22 06:57:30 -07:00
|
|
|
$testcommand | Add-Content -Path "$testfile"
|
|
|
|
|
(iex "& '$testfile'") | Should Be "pestertestscript"
|
|
|
|
|
Remove-Item "$testfile"
|
2016-03-04 14:52:27 -08:00
|
|
|
}
|
2015-11-19 06:21:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-07-25 14:01:41 -07:00
|
|
|
Describe "Invoke-Expression DRT Unit Tests" -Tags "CI" {
|
2016-04-19 03:01:38 -07:00
|
|
|
It "Invoke-Expression should work"{
|
|
|
|
|
$result=invoke-expression -Command 2+2
|
|
|
|
|
$result|Should Be 4
|
|
|
|
|
}
|
2016-07-25 14:01:41 -07:00
|
|
|
}
|