Skip to content

Commit

Permalink
Adding BeGreaterThan assertion.
Browse files Browse the repository at this point in the history
  • Loading branch information
splatteredbits committed Oct 20, 2014
1 parent d41fb17 commit 2c9366f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Functions/Assertions/BeGreaterThan.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Set-StrictMode -Version Latest

InModuleScope Pester {
Describe "PesterBeGreaterThan" {
It "passes if value greater than expected" {
Test-PositiveAssertion (PesterBeGreaterThan 2 1)
2 | Should BeGreaterThan 1
}
It "fails if values equal" {
Test-NegativeAssertion (PesterBeGreaterThan 3 3)
}

It "fails if value less than expected" {
Test-NegativeAssertion (PesterBeGreaterThan 4 5)
}
}

}
10 changes: 10 additions & 0 deletions Functions/Assertions/BeGreaterThan.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

function PesterBeGreaterThan($value, $expected)
{
return( $value -gt $expected )
}

function PesterBeGreaterThanFailureMessage($value,$expected)
{
"Expected {0} to be greater than {1}" -f $value,$expected
}
5 changes: 5 additions & 0 deletions en-US/about_should.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ SHOULD MEMBERS
$actual="Actual value"
$actual | Should BeExactly "Actual value" # Test will pass
$actual | Should BeExactly "actual value" # Test will fail

BeGreaterThan
Asserts that a number is greater than an expected value. Uses PowerShell's -gt operator to compare the two values.

$Error.Count | Should BeGreaterThan 0

Exist
Does not perform any comparison but checks if the object calling Exist
Expand Down

0 comments on commit 2c9366f

Please sign in to comment.