Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1535/DotNetMock/Dynamic
Modified Files:
ExpectationMethod.cs
Log Message:
BUG [ 1199222 ] Does not cast return value well
* Do a simple conversion using Convert.ChangeType on the return value if necessary. It is necessary if the return type is a value type and the return type of the method is not the same as the type of the specified return value.
Index: ExpectationMethod.cs
===================================================================
RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/ExpectationMethod.cs,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** ExpectationMethod.cs 25 Apr 2005 03:26:31 -0000 1.24
--- ExpectationMethod.cs 11 May 2005 05:17:14 -0000 1.25
***************
*** 265,268 ****
--- 265,282 ----
}
}
+ if ( _expectedReturnValue!=null )
+ {
+ // handle return values that are ValueTypes and ensure they can be casted
+ // in the IL that unboxes the return value.
+ Type expectedReturnType = _expectedReturnValue.GetType();
+ if ( expectedReturnType.IsValueType )
+ {
+ Type returnType = ActualMethod.ReturnType;
+ if ( returnType!=expectedReturnType )
+ {
+ _expectedReturnValue = Convert.ChangeType(_expectedReturnValue, returnType);
+ }
+ }
+ }
// if exception setup to be thrown, throw it
if ( _expectedException != null )
|