Using Moq's VerifySet in VB.NET

谁说我不能喝 提交于 2019-12-06 11:37:20

You want to use the following (from http://code.google.com/p/moq/wiki/QuickStart):

// or verify the setter directly mock.VerifySet(foo => foo.Name = "foo");

Right now the thing that you're feeding in is a comparison rather than an assignment, so even if Moq did process the statement without an exception, it would still not be Doing What You Mean.

Well this may be a little late, but I was facing the same problem and the solution was way simpler then using a InlineAssignHelper method.

Just change the Function to a Sub and it should work.

So try this instead:

usr.VerifySet(Sub(u) u.IsApproved = True)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!