@@ -9,7 +9,8 @@ Describe 'Invoke-RedstoneRun' {
9
9
10
10
Context ' Invoke-RedstoneRun File Does Not Exist' {
11
11
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
13
14
}
14
15
}
15
16
@@ -294,21 +295,19 @@ Describe 'Invoke-RedstoneRun' {
294
295
295
296
Context ' Simple WorkingDirectory' {
296
297
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(' -' , ' _' )
300
299
}
301
300
302
- AfterEach {
303
- $ script :result .Process | Stop -Process - Force - ErrorAction ' Ignore '
301
+ BeforeEach {
302
+ Mock Start -Process { param ( $FilePath , $WorkingDirectory ) return $WorkingDirectory }
304
303
}
305
304
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
308
307
}
309
308
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 '
312
311
}
313
312
}
314
313
}
0 commit comments