Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Remove-PSBreakpoint.Tests.ps1
T

74 lines
2.1 KiB
PowerShell
Raw Normal View History

2016-07-25 14:01:41 -07:00
Describe "Remove-PSBreakpoint" -Tags "CI" {
2016-03-04 14:48:30 -08:00
# Set up test script
$testScript = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath psbreakpointtestscript.ps1
$script = "`$var = 1
2016-04-25 14:41:17 -07:00
`$var2 = Get-Command
2016-03-04 14:48:30 -08:00
# this is a comment
Get-Date
"
2016-03-04 14:48:30 -08:00
$script > $testScript
BeforeEach {
# 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 14:48:30 -08:00
}
Context "Basic Removal Methods Tests" {
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 14:48:30 -08:00
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
2016-03-04 14:48:30 -08:00
It "Should be able to remove a breakpoint by variable" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
Remove-PSBreakpoint -Breakpoint $variable
2016-03-04 14:48:30 -08:00
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
2016-03-04 14:48:30 -08:00
It "Should be able to remove a breakpoint by command" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
Remove-PSBreakpoint -Breakpoint $command
2016-03-04 14:48:30 -08:00
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
2016-03-04 14:48:30 -08:00
It "Should be able to pipe breakpoint objects to Remove-PSBreakpoint" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
$variable | Remove-PSBreakpoint
2016-03-04 14:48:30 -08:00
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
2016-03-04 14:48:30 -08:00
}
Context "Alias Tests" {
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 14:48:30 -08:00
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
2016-03-04 14:48:30 -08:00
}
It "Should Remove all breakpoints" {
$(Get-PSBreakpoint).Id.Length | Should Not BeNullOrEmpty
2016-03-04 14:48:30 -08:00
Get-PSBreakpoint | Remove-PSBreakpoint
2016-03-04 14:48:30 -08:00
$(Get-PSBreakpoint).Id.Length | Should Be 0
2016-03-04 14:48:30 -08:00
}
#Clean up after ourselves
Remove-Item $testScript
}