i have test code similar this:
public interface idosomething function dosomething(index integer) integer end interface <test()> public sub shoulddosomething() dim mymock 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 integer = mymock.dosomething(808) end sub this code doesn't behave expected though. variable result contains integer.minvalue not 99, expected.
if write equivalent code in c# works 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); }
the difference function(invocation) invocation.returnvalue = 99 inline function returning boolean, invocation => invocation.returnvalue = 99 inline function returning 99 , setting invocation.returnvalue 99.
if you're using late enough version of vb.net can use sub(invocation) invocation.returnvalue = 99 unless whencalled expects return value.
Comments
Post a Comment