PowerShell/test/powershell/Set-PSBreakpoint.Tests.ps1

41 lines
1.2 KiB
PowerShell
Raw Normal View History

2015-12-28 20:05:48 +01:00
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
Describe "Set-PSBreakpoint" {
# Set up test script
2016-02-05 17:53:44 +01:00
$testScript = Join-Path -Path $here -ChildPath psbreakpointtestscript.ps1
2015-12-28 20:05:48 +01:00
"`$var = 1 " > $testScript
It "Should be able to set a psbreakpoint on a line" {
$lineNumber = 1
2016-02-05 23:57:08 +01:00
$brk = Set-PSBreakpoint -Line $lineNumber -Script $testScript
$brk.Line | Should Be $lineNumber
Remove-PSBreakPoint -Id $brk.Id
2015-12-28 20:05:48 +01:00
}
It "Should throw when a string is entered for a line number" {
{
$lineNumber = "one"
2016-02-05 23:57:08 +01:00
Set-PSBreakpoint -Line $lineNumber -Script $testScript
2015-12-28 20:05:48 +01:00
} | Should Throw
}
It "Should be able to set a psbreakpoint on a Command" {
$command = "theCommand"
2016-02-05 23:57:08 +01:00
$brk = Set-PSBreakpoint -Command $command -Script $testScript
$brk.Command | Should Be $command
Remove-PSBreakPoint -Id $brk.Id
2015-12-28 20:05:48 +01:00
}
It "Should be able to set a psbreakpoint on a variable" {
$var = "theVariable"
2016-02-05 23:57:08 +01:00
$brk = Set-PSBreakpoint -Command $var -Script $testScript
$brk.Command | Should Be $var
Remove-PSBreakPoint -Id $brk.Id
2015-12-28 20:05:48 +01:00
}
# clean up after ourselves
Remove-Item -Path $testScript
2015-10-22 18:15:19 +02:00
}