I have test code similar to this:
Public Interface IDoSomething
Function DoSomething(index As Integer) As Integer
End Interface
<Test()>
Public Sub ShouldDoSomething()
Dim myMock As IDoSomething = MockRepository.GenerateMock(Of IDoSomething)()
myMock.Stub(Function(d) d.DoSomething(Arg(Of Integer).Is.Anything))
.WhenCalled(Function(invocation) invocation.ReturnValue = 99)
.Return(Integer.MinValue)
Dim result As Integer = myMock.DoSomething(808)
End Sub
This code doesn't behave as expected though. The variable result
contains Integer.MinValue
not 99, as expected.
If I write the equivalent code in C# it works as anticipated: result
contains 99.
Any ideas why?
C# equivalent:
public interface IDoSomething
{
int DoSomething(int index)
}
[test()]
public void ShouldDoSomething()
{
var myMock = MockRepository.GenerateMock<IDoSomething>();
myMock.Stub(d => d.DoSomething(Arg<int>.Is.Anything))
.WhenCalled(invocation => invocation.ReturnValue = 99)
.Return(int.MinValue);
var result = myMock.DoSomething(808);
}