1 // ****************************************************************
2 // Copyright 2007, Charlie Poole
3 // This is free software licensed under the NUnit license. You may
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
5 // ****************************************************************
9 using NUnit
.Framework
.Constraints
;
14 /// Summary description for ExpectedCall.
16 public class MockCall
: ICall
18 private MethodSignature signature
;
19 private object returnVal
;
20 private Exception exception
;
21 private object[] expectedArgs
;
23 // public static object[] Any = new object[0];
25 public MockCall( MethodSignature signature
, object returnVal
, Exception exception
, params object[] args
)
27 this.signature
= signature
;
28 this.returnVal
= returnVal
;
29 this.exception
= exception
;
30 this.expectedArgs
= args
;
33 public object Call( object[] actualArgs
)
35 if ( expectedArgs
!= null )
37 Assert
.AreEqual( expectedArgs
.Length
, actualArgs
.Length
, "Invalid argument count in call to {0}", this.signature
.methodName
);
39 for( int i
= 0; i
< expectedArgs
.Length
; i
++ )
41 if ( expectedArgs
[i
] is Constraint
)
42 Assert
.That( actualArgs
[i
], (Constraint
)expectedArgs
[i
] );
44 Assert
.AreEqual( expectedArgs
[i
], actualArgs
[i
] );
48 if ( exception
!= null )