Scott,
Thank you again.
I have checked this and there is a problem returning Null to Nullable Types. We will fix this. Did you have a different scenario?
I created an small example to illustrate the issue with INullables (maybe this should be in a new post?):
Imports System.Data.SqlTypes
Imports MbUnit.Framework
Imports TypeMock
<TestFixture()> _
Public Class INullableTest
<TestAttribute()> _
Public Sub TestReturnSqlInt32()
Dim recorder As New RecordExpectations
Try
DummyClass.DoWork()
recorder.Return(New SqlInt32(1))
Finally
recorder.Dispose()
End Try
Dim value As SqlInt32 = DummyClass.DoWork()
Assert.IsFalse(value.IsNull)
End Sub
End Class
Public Class DummyClass
Public Shared Function DoWork() As SqlInt32
End Function
End Class
When I run the test I get an exception, this is the stack trace:
[failure] INullableTest.TestReturnSqlInt32
TestCase 'INullableTest.TestReturnSqlInt32'
failed: Index was out of range. Must be non-negative and less than the size of the collection.
Nombre del parámetro: index
System.ArgumentOutOfRangeException
Message: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source: mscorlib
StackTrace:
at System.Collections.ArrayList.get_Item(Int32 index)
at ar.a()
at TypeMock.RecorderManager.a(Object A_0, Type A_1, Boolean A_2, String A_3)
at TypeMock.RecorderManager.a(String A_0, String A_1, Object A_2, Type A_3, Boolean A_4)
at TypeMock.RecorderManager.a(String A_0, String A_1, Object A_2, Object[] A_3, MethodBase A_4, Object A_5)
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Object[] A_4)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Object p1)
at System.Data.SqlTypes.SqlInt32..ctor(Int32 value)
D:DocumentosVisual Studio ProjectsTestTypeMockINullableTest.vb(14,0): at TestTypeMock.INullableTest.TestReturnSqlInt32()
Hope this helps.
It is possible to check the arguments by using CheckArguments
It is possible to modify the arguments using Assign
Thank you, I'll try that :)