@@ -9,7 +9,8 @@ Describe 'Invoke-RedstoneRun' {
99
1010 Context ' Invoke-RedstoneRun File Does Not Exist' {
1111 It ' Should Throw' {
12- { Invoke-RedstoneRun (' fileDoesNotExist_{0}.exe' -f (New-Guid ).Guid.Replace(' -' , ' _' )) } | Should - Throw
12+ $randomExe = ' fileDoesNotExist_{0}.exe' -f (New-Guid ).Guid.Replace(' -' , ' _' )
13+ { Invoke-RedstoneRun $randomExe } | Should - Throw
1314 }
1415 }
1516
@@ -294,21 +295,19 @@ Describe 'Invoke-RedstoneRun' {
294295
295296 Context ' Simple WorkingDirectory' {
296297 BeforeAll {
297- $script :randomExe = Get-ChildItem ' C:\Program Files' - Filter ' *.exe' - File - Recurse | Where-Object {
298- $env: Path.Split (' ;' ) -notcontains $_.DirectoryName
299- } | Select-Object - First 1
298+ [IO.FileInfo ] $script :randomExe = ' C:\Program Files\DoesNotExist\fileDoesNotExist_{0}.exe' -f (New-Guid ).Guid.Replace(' -' , ' _' )
300299 }
301300
302- AfterEach {
303- $ script :result .Process | Stop -Process - Force - ErrorAction ' Ignore '
301+ BeforeEach {
302+ Mock Start -Process { param ( $FilePath , $WorkingDirectory ) return $WorkingDirectory }
304303 }
305304
306- It ' Should Throw ' {
307- { $ script :result = Invoke-RedstoneRun - FilePath $script :randomExe.Name - Wait $false } | Should - Throw
305+ It ' Should Not Pass WorkingDirectory ' {
306+ ( Invoke-RedstoneRun - FilePath $script :randomExe.Name ).Process | Should - BeNullOrEmpty
308307 }
309308
310- It ' Should Not Throw ' {
311- { $ script :result = Invoke-RedstoneRun - FilePath $script :randomExe.FullName - WorkingDirectory $script :randomExe.DirectoryName - Wait $false } | Should -Not - Throw
309+ It ' Should Pass WorkingDirectory ' {
310+ ( Invoke-RedstoneRun - FilePath $script :randomExe.FullName - WorkingDirectory $script :randomExe.DirectoryName ).Process | Should - Be ' C:\Program Files\DoesNotExist '
312311 }
313312 }
314313}
0 commit comments