在VB.net中应该如何调用moq的VerifySet
我正在尝试测试一个属性是否已设置,但是当我将其编写为单元测试时:
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 的示例,我如果有任何例子,我将不胜感激。
I am trying to test that a property has been set but when I write this as a unit test:
moqFeed.VerifySet(Function(m) m.RowAdded = "Row Added")
moq complains that "Expression is not a property setter invocation"
My complete code is
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
I can't find any examples of moq in VB, I would be grateful for any examples.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅我的问题在VB.NET中使用Moq的VerifySet以获取此问题的解决方案。
See my question Using Moq's VerifySet in VB.NET for the solution to this.