Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16618/DotNetMock.Tests/Dynamic
Modified Files:
ExpectationMethodTests.cs PredicateTests.cs
Log Message:
RFE 1108902 - The cheapest way to make the error messages nicer.
- Identify the method call that failed and the argument index that failed.
- For a couple predicates (IsNull & IsEqual) provide more info through the ToString() method.
- Need to add more ToString implementations for the rest of the predicates.
- Roman's MethodCall abstraction is useful here. stringification of method calls could be done there.
Index: ExpectationMethodTests.cs
===================================================================
RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic/ExpectationMethodTests.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ExpectationMethodTests.cs 12 Feb 2005 18:10:36 -0000 1.6
--- ExpectationMethodTests.cs 16 Feb 2005 10:39:25 -0000 1.7
***************
*** 36,39 ****
--- 36,55 ----
_expectedMethod.Verify();
}
+ [Test]
+ [ExpectedException(typeof(AssertionException), "Failed to satisfy 'value equals (1)' on argument 0 of method call myMethod(3, 2, 1)")]
+ public void DecentErrorMessageWhenPredicateFails()
+ {
+ _expectedMethod = new ExpectationMethod("myMethod", null, new object[] { 1, 2, 3 });
+ _expectedMethod.Call("myMethod", new object[] { 3, 2, 1 });
+ _expectedMethod.Verify();
+ }
+ [Test]
+ [ExpectedException(typeof(AssertionException), "Failed to satisfy 'value equals (2)' on argument 1 of method call myMethod(1, 3, 2)")]
+ public void DecentErrorMessageWhenPredicateFailsOnSecondArgument()
+ {
+ _expectedMethod = new ExpectationMethod("myMethod", null, new object[] { 1, 2, 3 });
+ _expectedMethod.Call("myMethod", new object[] { 1, 3, 2 });
+ _expectedMethod.Verify();
+ }
}
}
Index: PredicateTests.cs
===================================================================
RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic/PredicateTests.cs,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** PredicateTests.cs 12 Feb 2005 18:10:36 -0000 1.12
--- PredicateTests.cs 16 Feb 2005 10:39:25 -0000 1.13
***************
*** 11,15 ****
{
private IPredicate p;
!
[Test]
public void IsNull()
--- 11,24 ----
{
private IPredicate p;
!
! [Test] public void IsNullToString()
! {
! Assert.AreEqual("value is null", new IsNull().ToString());
! }
! [Test] public void IsEqualToString()
! {
! Assert.AreEqual("value equals (3)", new IsEqual(3).ToString());
! Assert.AreEqual("value equals (whatever it is)", new IsEqual("whatever it is").ToString());
! }
[Test]
public void IsNull()
|