Experiences using moq with VB.Net

故事扮演 提交于 2019-12-29 08:32:31

问题


I really like the moq mocking framework. I've used it on several projects. Unfortunately, one of my customers is demanding we use VB.Net. Not my preference, but hey, .Net is .Net, right?

I've heard that moq has some trouble with VB. Is this true? Is so, what sorts of trouble? I would expect it to work fine given the language agnostic nature of .Net.

Should I look into using some other mocking framework for use with VB?


回答1:


The main problem of VB.net with regards to mocking frameworks is that, contrary to C#, VB does not have anonymous methods, only Lambda expressions (no way to declare an anonymous Action delegate).

This severely limits the possibilities. There is also a known issue with properties with parameters.

Also, the syntax of the language for lambdas does not lead to something as clean as C#, readability-wise (no flames please, I'm a VB user and I miss some C# features every day), and that's partly the attraction for Moq.

The only testing framework I know of that did something with regards to VB is TypeMock. They tried to design something that blends with the VB syntax.




回答2:


AFAIK Typemock Isolator is the only tool that can fully mock VB.NET. They made an API especially for that.



来源:https://stackoverflow.com/questions/798570/experiences-using-moq-with-vb-net

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