R – Setting expectations on Sub (not Function) in VB.NET using Rhino Mocks

mockingrhino-mockstestingvb.net

I remember that to set expectations on methods that return void in C# one has to write:

mockedRepository.Expect(() => mr.AddUser(someUser)).DoOtherStuff()

where AddUser returns void.

How to achieve the same in VB.NET?

EDIT:

I've found similar question. May be helpful: How to mock a method with Rhino Mocks in VB.NET .

Best Answer

You have to use a little trick

<test> _
Public Sub Test
  mockedRepository.Expect(Function(x) domock(x)).DoOtherStuff()
End SUb

Private Function domock(Byval x as whateverxis) as boolean
  x.AddUser(someUser)
  return false 'but actualy who cares
End Function

All this mess is solved in VB10

Related Topic