在 VB.Net 中使用 moq 的经验 [英] Experiences using moq with VB.Net

查看:18
本文介绍了在 VB.Net 中使用 moq 的经验的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢 moq 模拟框架.我已经在几个项目中使用过它.不幸的是,我的一位客户要求我们使用 VB.Net.不是我的偏好,但是嘿,.Net 就是 .Net,对吧?

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?

我听说 moq 与 VB 有一些问题.这是真的?是这样,什么样的麻烦?鉴于 .Net 的语言不可知性,我希望它能够正常工作.

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.

我是否应该考虑使用其他一些与 VB 一起使用的模拟框架?

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

推荐答案

VB.net 在 mocking 框架方面的主要问题是,与 C# 不同,VB 没有匿名方法,只有 Lambda 表达式(无法声明一个匿名 Action 委托).

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.

另外,lambdas 语言的语法并不像 C# 那样简洁、可读性好(请不要着火,我是 VB 用户,我每天都想念一些 C# 功能),这部分是起订量的吸引力.

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.

我所知道的唯一一个与 VB 相关的测试框架是 TypeMock.他们试图设计一些与 VB 语法相融合的东西.

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.

这篇关于在 VB.Net 中使用 moq 的经验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆