2016-03-04 23:48:30 +01:00
|
|
|
Describe "Remove-PSBreakpoint" {
|
|
|
|
# Set up test script
|
|
|
|
$testScript = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath psbreakpointtestscript.ps1
|
|
|
|
|
|
|
|
$script = "`$var = 1
|
2016-03-04 23:52:27 +01:00
|
|
|
`$var2 = Get-Process
|
2016-03-04 23:48:30 +01:00
|
|
|
|
|
|
|
# this is a comment
|
|
|
|
Get-Date
|
2016-03-04 23:52:27 +01:00
|
|
|
"
|
2016-03-04 23:48:30 +01:00
|
|
|
|
|
|
|
$script > $testScript
|
|
|
|
|
|
|
|
BeforeEach {
|
2016-03-04 23:52:27 +01:00
|
|
|
# set some breakpoints
|
|
|
|
$line = Set-PSBreakpoint -Line 1,2,3 -Script $testScript
|
|
|
|
$command = Set-PSBreakpoint -Command "Get-Date" -Script $testScript
|
|
|
|
$variable = Set-PSBreakpoint -Variable var2 -Script $testScript
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Context "Basic Removal Methods Tests" {
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should be able to remove a breakpoint by breakpoint Id" {
|
|
|
|
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
|
|
|
|
$BreakID = $(Get-PSBreakpoint).Id[0]
|
|
|
|
Remove-PSBreakpoint -Id $BreakID
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should be able to remove a breakpoint by variable" {
|
|
|
|
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
|
|
|
|
Remove-PSBreakpoint -Breakpoint $variable
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should be able to remove a breakpoint by command" {
|
|
|
|
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
|
|
|
|
Remove-PSBreakpoint -Breakpoint $command
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should be able to pipe breakpoint objects to Remove-PSBreakpoint" {
|
|
|
|
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
|
|
|
|
$variable | Remove-PSBreakpoint
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Context "Alias Tests" {
|
2016-03-04 23:52:27 +01:00
|
|
|
It "Should remove a breakpoint using the rbp alias" {
|
|
|
|
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
|
|
|
|
$BreakID = $(Get-PSBreakpoint).Id[0]
|
|
|
|
rbp -Id $BreakID
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
|
|
|
|
}
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should Remove all breakpoints" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$(Get-PSBreakpoint).Id.Length | Should Not BeNullOrEmpty
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
Get-PSBreakpoint | Remove-PSBreakpoint
|
2016-03-04 23:48:30 +01:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$(Get-PSBreakpoint).Id.Length | Should Be 0
|
2016-03-04 23:48:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#Clean up after ourselves
|
|
|
|
|
|
|
|
Remove-Item $testScript
|
|
|
|
}
|