如何在VB.net中调用moq的VerifySet

时间:2010-04-10 16:42:12

标签: vb.net moq

我正在尝试测试已设置属性但是当我将其作为单元测试编写时:

moqFeed.VerifySet(Function(m) m.RowAdded = "Row Added")

moq抱怨“表达式不是属性设置器调用”

我的完整代码是

Imports Gallio.Framework
Imports MbUnit.Framework
Imports Moq

<TestFixture()> Public Class GUI_FeedPresenter_Test
    Private moqFeed As Moq.Mock(Of IFeedView)
    <SetUp()> Sub Setup()
        moqFeed = New Mock(Of IFeedView)
    End Sub
    <Test()> Public Sub New_Presenter()
        Dim pres = New FeedPresenter(moqFeed.Object)
        moqFeed.VerifySet(Function(m) m.RowAdded = "Row Added")
    End Sub
End Class

Public Interface IFeedView
    Property RowAdded() As String
End Interface

Public Class FeedPresenter
    Private _FeedView As IFeedView

    Public Sub New(ByVal feedView As IFeedView)
        _FeedView = feedView
        _FeedView.RowAdded = "Row Added"
    End Sub
End Class

我在VB中找不到moq的任何例子,我将不胜感激任何例子。

1 个答案:

答案 0 :(得分:1)

请参阅我的问题Using Moq's VerifySet in VB.NET以获得解决方法。