From: Choy R. <ch...@us...> - 2005-02-20 09:26:57
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15950/DotNetMock.Tests/Dynamic Modified Files: ExpectationMethodTests.cs PredicateTests.cs Log Message: Make sure all Predicates support the ability to describe their evaluation expression through the ExpressionAsText(name) method. The name parameter is so that in the future we can include the name of the parameter that didn't satisfy the predicate in our assertion failure messages. Index: ExpectationMethodTests.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic/ExpectationMethodTests.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ExpectationMethodTests.cs 19 Feb 2005 09:06:24 -0000 1.12 --- ExpectationMethodTests.cs 20 Feb 2005 09:26:48 -0000 1.13 *************** *** 9,12 **** --- 9,13 ---- using DotNetMock.Dynamic; + using DotNetMock.Dynamic.Predicates; #endregion *************** *** 59,63 **** [ExpectedException( typeof(AssertionException), ! "Failed to satisfy 'value equals (1)' on argument[0] of method call Method2(x=3, y=2, z=1)" )] public void DecentErrorMessageWhenPredicateFails() --- 60,83 ---- [ExpectedException( typeof(AssertionException), ! "Failed to satisfy '(value is a System.Double) and (value is within 0.1 of 1)' on argument[0] of method call Method2(x=3, y=2, z=1)" ! )] ! public void ErrorMessageWhenComplexPredicateFails() ! { ! IPredicate complexPredicate = new AndPredicate( ! new IsTypeOf(typeof(double)), ! new IsCloseTo(1, 0.1) ! ); ! methodCallExpectation = new ExpectationMethod( ! method2.Name, ! null, ! new object[] { complexPredicate, 2, 3 } ! ); ! methodCallExpectation.ActualMethodCall = new MethodCall(method2, 3, 2, 1); ! methodCallExpectation.Verify(); ! } ! [Test] ! [ExpectedException( ! typeof(AssertionException), ! "Failed to satisfy 'value equals 1' on argument[0] of method call Method2(x=3, y=2, z=1)" )] public void DecentErrorMessageWhenPredicateFails() *************** *** 70,74 **** [ExpectedException( typeof(AssertionException), ! "Failed to satisfy 'value equals (2)' on argument[1] of method call Method2(x=1, y=3, z=2)" )] public void DecentErrorMessageWhenPredicateFailsOnSecondArgument() --- 90,94 ---- [ExpectedException( typeof(AssertionException), ! "Failed to satisfy 'value equals 2' on argument[1] of method call Method2(x=1, y=3, z=2)" )] public void DecentErrorMessageWhenPredicateFailsOnSecondArgument() Index: PredicateTests.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic/PredicateTests.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PredicateTests.cs 16 Feb 2005 10:39:25 -0000 1.13 --- PredicateTests.cs 20 Feb 2005 09:26:48 -0000 1.14 *************** *** 12,23 **** 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] --- 12,130 ---- private IPredicate p; + [Test] public void AndToString() + { + Assert.AreEqual( + "(value is anything) and (value is anything)", + new AndPredicate( + new IsAnything(), new IsAnything() + ).ToString() + ); + } + [Test] public void IsAnythingToString() + { + Assert.AreEqual("value is anything", new IsAnything().ToString()); + } + [Test] public void IsCloseToToString() + { + Assert.AreEqual( + "value is within 0.1 of 1", + new IsCloseTo(1, 0.1).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 IsEqualIgnoreCaseToString() + { + Assert.AreEqual( + "value equals 'abc' (ignore case)", + new IsEqualIgnoreCase("abc").ToString() + ); + Assert.AreEqual( + "value equals 'whatever' (ignore case)", + new IsEqualIgnoreCase("whatever").ToString() + ); + } + [Test] public void IsEqualIgnoreWhiteSpaceToString() + { + Assert.AreEqual( + "value equals 'a b c' (ignore whitespace)", + new IsEqualIgnoreWhiteSpace("a b c").ToString() + ); + Assert.AreEqual( + "value equals 'what ever' (ignore whitespace)", + new IsEqualIgnoreWhiteSpace("what ever").ToString() + ); + } + [Test] public void IsInToString() + { + Assert.AreEqual( + "value is in [1, 'two', 3.4]", + new IsIn(1, "two", 3.4).ToString() + ); + } + [Test] public void IsMatchToString() + { + Assert.AreEqual( + "value matches /^abc$/", + new IsMatch("^abc$").ToString() + ); + } [Test] public void IsNullToString() { Assert.AreEqual("value is null", new IsNull().ToString()); } ! [Test] public void IsTypeOfToString() { ! Assert.AreEqual( ! "value is a System.Object", ! new IsTypeOf(typeof(object)).ToString() ! ); ! } ! [Test] public void NotEqualToString() ! { ! Assert.AreEqual( ! "value is not equal to 3", ! new NotEqual(3).ToString() ! ); ! Assert.AreEqual( ! "value is not equal to 'whatever it is'", ! new NotEqual("whatever it is").ToString() ! ); ! } ! [Test] public void NotInToString() ! { ! Assert.AreEqual( ! "value is not in [1, 'two', 3.4]", ! new NotIn(1, "two", 3.4).ToString() ! ); ! } ! [Test] public void NotNullToString() ! { ! Assert.AreEqual("value is not null", new NotNull().ToString()); ! } ! [Test] public void NotToString() ! { ! Assert.AreEqual( ! "not (value is anything)", ! new NotPredicate(new IsAnything()).ToString() ! ); ! } ! [Test] public void OrToString() ! { ! Assert.AreEqual( ! "(value is anything) or (value is anything)", ! new OrPredicate( ! new IsAnything(), new IsAnything() ! ).ToString() ! ); } [Test] *************** *** 268,274 **** } ! class True : IPredicate { ! public bool Eval(object val) { return true; --- 375,381 ---- } ! class True : AbstractPredicate { ! public override bool Eval(object val) { return true; *************** *** 276,282 **** } ! class False : IPredicate { ! public bool Eval(object val) { return false; --- 383,389 ---- } ! class False : AbstractPredicate { ! public override bool Eval(object val) { return false; |