From: Choy R. <ch...@us...> - 2005-02-16 10:39:42
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16618/DotNetMock/Dynamic Modified Files: ExpectationMethod.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: ExpectationMethod.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/ExpectationMethod.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ExpectationMethod.cs 5 Jan 2005 00:29:36 -0000 1.10 --- ExpectationMethod.cs 16 Feb 2005 10:39:26 -0000 1.11 *************** *** 110,123 **** if ( args != null && args.Length > 0 ) { ! string argStr = ""; ! foreach( object o in args ) { ! if( o is System.String ) ! argStr = argStr + ", \"" + o.ToString() + "\""; ! else ! argStr = argStr + ", " + o.ToString(); ! } ! return argStr.Substring(2); } return String.Empty; --- 110,131 ---- if ( args != null && args.Length > 0 ) { ! string[] argText = new string[args.Length]; ! for (int i=0; i<args.Length; ++i) { ! object arg = args[i]; ! if ( object.ReferenceEquals(arg, null) ) ! { ! argText[i] = "null"; ! } ! else if( arg is string ) ! { ! argText[i] = "\"" + arg.ToString() + "\""; ! } ! else ! { ! argText[i] = arg.ToString(); ! } } ! return String.Join(", ", argText); } return String.Empty; *************** *** 142,146 **** IPredicate predicate = PredicateUtils.ConvertFrom(argumentExpectation); ! Assertion.Assert(predicate.Eval(actualArg)); // return output expectations if specified IArgumentMutator mutator = --- 150,162 ---- IPredicate predicate = PredicateUtils.ConvertFrom(argumentExpectation); ! // wasteful but good as a first cut at better error messages ! string failureMessage = String.Format( ! "Failed to satisfy '{0}' on argument {1} of method call {2}({3})", ! predicate, ! i, ! ExpectedMethodName, ! argsToString(_methodArguments) ! ); ! Assertion.Assert(failureMessage, predicate.Eval(actualArg)); // return output expectations if specified IArgumentMutator mutator = |