forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemove-PSBreakpoint.Tests.ps1
More file actions
74 lines (54 loc) · 2.09 KB
/
Copy pathRemove-PSBreakpoint.Tests.ps1
File metadata and controls
74 lines (54 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Describe "Remove-PSBreakpoint" -Tags "CI" {
# Set up test script
$testScript = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath psbreakpointtestscript.ps1
$script = "`$var = 1
`$var2 = Get-Command
# this is a comment
Get-Date
"
$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
}
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
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
It "Should be able to remove a breakpoint by variable" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
Remove-PSBreakpoint -Breakpoint $variable
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
It "Should be able to remove a breakpoint by command" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
Remove-PSBreakpoint -Breakpoint $command
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
It "Should be able to pipe breakpoint objects to Remove-PSBreakpoint" {
$NumberOfBreakpoints = $(Get-PSBreakpoint).Id.length
$variable | Remove-PSBreakpoint
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
}
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
$(Get-PSBreakpoint).Id.length | Should Be ($NumberOfBreakpoints -1)
}
}
It "Should Remove all breakpoints" {
$(Get-PSBreakpoint).Id.Length | Should Not BeNullOrEmpty
Get-PSBreakpoint | Remove-PSBreakpoint
$(Get-PSBreakpoint).Id.Length | Should Be 0
}
#Clean up after ourselves
Remove-Item $testScript
}