Project DescriptionA .NET port of Groovy's Power Assert, which prints out a decomposition of your expression tree (with values) whenever an assertion fails
An excellent description of groovy's PowerAssert can be found at
http://dontmindthelanguage.wordpress.com/2009/12/11/groovy-1-7-power-assert/
What does Power Assert .NET do?
Given the following unit test:
[Test]
public void RunComplexExpression()
{
int x = 11;
int y = 6;
DateTime d = new DateTime(2010, 3, 1);
PAssert.IsTrue(() => x + 5 == d.Month * y);
}
Power Assert will cause a failure with the following message:
System.Exception : IsTrue failed, expression was:
x + 5 == d.Month * y
| | | | | | |
| | | | | | 6
| | | | | 18
| | | | 3
| | | 01/03/2010 00:00:00
| | False
| 16
11
Equals vs ==
Given the following unit test:
[Test]
public void EqualsButNotOperatorEquals()
{
var t1 = new Tuple<string>("foo");
var t2 = new Tuple<string>("foo");
PAssert.IsTrue(() => t1 == t2);
}
Power Assert will cause a failure with the following message:
System.Exception : IsTrue failed, expression was:
t1 == t2
| | |
| | (foo)
| False, but would have been True if you'd called .Equals()
(foo)
Pull requests and feature requests are welcomed!