【问题标题】:Setting expectations on Sub (not Function) in VB.NET using Rhino Mocks使用 Rhino Mocks 在 VB.NET 中设置对 Sub(不是 Function)的期望
【发布时间】:2009-06-04 10:15:32
【问题描述】:

我记得要对 C# 中返回 void 的方法设置期望值,必须这样写:

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

AddUser 返回 void。

如何在 VB.NET 中实现相同的功能?

编辑:

我发现了类似的问题。可能会有所帮助:How to mock a method with Rhino Mocks in VB.NET

【问题讨论】:

    标签: vb.net testing mocking rhino-mocks


    【解决方案1】:

    你必须使用一个小技巧

    <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
    

    VB10 解决了所有这些问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多