From: Choy R. <ch...@us...> - 2005-02-19 08:39:28
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22599/DotNetMock.Tests/Dynamic Modified Files: ExpectationMethodTests.cs Log Message: Incorporated MethodCall into ExpectationMethod Index: ExpectationMethodTests.cs =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Dynamic/ExpectationMethodTests.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ExpectationMethodTests.cs 18 Feb 2005 02:16:08 -0000 1.10 --- ExpectationMethodTests.cs 19 Feb 2005 08:39:19 -0000 1.11 *************** *** 16,20 **** public class ExpectationMethodTests { ! private ExpectationMethod _expectedMethod = null; private interface IMethods --- 16,20 ---- public class ExpectationMethodTests { ! private ExpectationMethod methodCallExpectation = null; private interface IMethods *************** *** 22,41 **** void Method1(); void Method2(int x, int y, int z); } static readonly MethodInfo method1 = typeof(IMethods).GetMethod("Method1"); static readonly MethodInfo method2 = typeof(IMethods).GetMethod("Method2"); [TearDown] public void Destroy() { ! _expectedMethod = null; } [Test] public void ExpectationMethodVoid() { ! _expectedMethod = new ExpectationMethod(method1.Name); ! _expectedMethod.SetActualMethodCall(method1); ! _expectedMethod.Verify(); } [Test] --- 22,43 ---- void Method1(); void Method2(int x, int y, int z); + void Method3(); } static readonly MethodInfo method1 = typeof(IMethods).GetMethod("Method1"); static readonly MethodInfo method2 = typeof(IMethods).GetMethod("Method2"); + static readonly MethodInfo method3 = typeof(IMethods).GetMethod("Method3"); [TearDown] public void Destroy() { ! methodCallExpectation = null; } [Test] public void ExpectationMethodVoid() { ! methodCallExpectation = new ExpectationMethod(method1.Name); ! methodCallExpectation.SetActualMethodCall(method1); ! methodCallExpectation.Verify(); } [Test] *************** *** 43,72 **** public void ExpectationMethodVoidNoCall() { ! _expectedMethod = new ExpectationMethod(method1.Name); ! _expectedMethod.Verify(); } [Test] public void ExpectedMethodReturnValue() { ! _expectedMethod = new ExpectationMethod(method1.Name, true ); ! _expectedMethod.SetActualMethodCall(method1); ! Assert.IsTrue((bool)_expectedMethod.ReturnValue); ! _expectedMethod.Verify(); } [Test] ! [ExpectedException(typeof(AssertionException), "Failed to satisfy 'value equals (1)' on argument 0 (x) of method call Method2(3, 2, 1)")] public void DecentErrorMessageWhenPredicateFails() { ! _expectedMethod = new ExpectationMethod(method2.Name, null, new object[] { 1, 2, 3 }); ! _expectedMethod.SetActualMethodCall(method2, 3, 2, 1); ! _expectedMethod.Verify(); } [Test] ! [ExpectedException(typeof(AssertionException), "Failed to satisfy 'value equals (2)' on argument 1 (y) of method call Method2(1, 3, 2)")] public void DecentErrorMessageWhenPredicateFailsOnSecondArgument() { ! _expectedMethod = new ExpectationMethod(method2.Name, null, new object[] { 1, 2, 3 }); ! _expectedMethod.SetActualMethodCall(method2, 1, 3, 2); ! _expectedMethod.Verify(); } [Test] --- 45,80 ---- public void ExpectationMethodVoidNoCall() { ! methodCallExpectation = new ExpectationMethod(method1.Name); ! methodCallExpectation.Verify(); } [Test] public void ExpectedMethodReturnValue() { ! methodCallExpectation = new ExpectationMethod(method1.Name, true ); ! methodCallExpectation.SetActualMethodCall(method1); ! Assert.IsTrue((bool)methodCallExpectation.ReturnValue); ! 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() { ! methodCallExpectation = new ExpectationMethod(method2.Name, null, new object[] { 1, 2, 3 }); ! methodCallExpectation.SetActualMethodCall(method2, 3, 2, 1); ! methodCallExpectation.Verify(); } [Test] ! [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() { ! methodCallExpectation = new ExpectationMethod(method2.Name, null, new object[] { 1, 2, 3 }); ! methodCallExpectation.SetActualMethodCall(method2, 1, 3, 2); ! methodCallExpectation.Verify(); } [Test] *************** *** 74,87 **** public void AccessingActualMethodPropertyBeforeSetting() { ! _expectedMethod = new ExpectationMethod(method1.Name); ! MethodInfo mi = _expectedMethod.ActualMethod; } [Test] ! [ExpectedException(typeof(AssertionException), "Method1() expected, but Method2() called.")] public void WrongMethodCalled() { ! _expectedMethod = new ExpectationMethod(method1.Name); ! _expectedMethod.SetActualMethodCall(method2); ! _expectedMethod.Verify(); } [Test] --- 82,95 ---- public void AccessingActualMethodPropertyBeforeSetting() { ! methodCallExpectation = new ExpectationMethod(method1.Name); ! MethodInfo mi = methodCallExpectation.ActualMethod; } [Test] ! [ExpectedException(typeof(AssertionException), "Method1() expected, but Method3() called.")] public void WrongMethodCalled() { ! methodCallExpectation = new ExpectationMethod(method1.Name); ! methodCallExpectation.SetActualMethodCall(method3); ! methodCallExpectation.Verify(); } [Test] *************** *** 92,112 **** public void ArgumentCountontMatchMethodSignature() { ! _expectedMethod = new ExpectationMethod(method2.Name, null, new object[] { 1, 2, 3 }); ! _expectedMethod.SetActualMethodCall(method2, 1, 3); ! _expectedMethod.Verify(); } - /* [Test] [ExpectedException( typeof(AssertionException), ! "Expected 2 arguments but received 3 in method call Method2(1, 2, 3)." )] ! public void ActualArgumentLengthDoesntMatchExpected() { ! _expectedMethod = new ExpectationMethod(method2.Name, null, new object[] { 1, 2 }); ! _expectedMethod.SetActualMethodCall(method2, 1, 2, 3); ! _expectedMethod.Verify(); } - */ } } --- 100,122 ---- public void ArgumentCountontMatchMethodSignature() { ! methodCallExpectation = new ExpectationMethod(method2.Name, null, new object[] { 1, 2, 3 }); ! methodCallExpectation.SetActualMethodCall(method2, 1, 3); ! methodCallExpectation.Verify(); } [Test] [ExpectedException( typeof(AssertionException), ! "Expected 4 arguments but received 3 in method call Method2(x=1, y=2, z=3)." )] ! public void MoreExpectationsThanArguments() { ! methodCallExpectation = new ExpectationMethod( ! method2.Name, ! null, ! new object[] { 1, 2, 3, 4 } ! ); ! methodCallExpectation.SetActualMethodCall(method2, 1, 2, 3); ! methodCallExpectation.Verify(); } } } |