MOQ和AutoFixture有什么区别? [英] What are the differences between MOQ and AutoFixture?

查看:115
本文介绍了MOQ和AutoFixture有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有相当多的使用最小起订量的经验,而最近我偶然发现了AutoFixture.这些框架之间有什么区别?

I have a fair amount of experience using MOQ, while I've recently have stumbled into AutoFixture. What are the differences between these frameworks?

推荐答案

常见问题解答解释了差异.简而言之

The FAQ explains the difference. In short

AutoFixture使用Reflection创建公共类型的行为良好"实例.必要时,它会自动生成其他类型的实例,以填充构造函数的参数,并为公共可写属性分配值.本质上,它只是使用请求的类型的公共API实例化并填充它.作为开发人员,它不会做任何您无法手动完成的工作-它会自动为您完成操作.

AutoFixture uses Reflection to create 'well-behaved' instances of public types. It auto-generates instances of other types if necessary to fill in arguments for a constructor, and also assigns values to public writable properties. In essence, it simply uses the requested type's public API to instantiate and populate it. It doesn't do anything that you, as a developer, couldn't do manually - it just does it for you automatically.

相反,大多数Dynamic Mock库都是从已知类型派生的,以覆盖虚拟成员的行为.他们的目的是对被测系统(SUT)进行行为验证.

In contrast, most Dynamic Mock libraries derive from known types to override the behavior of virtual members. Their purpose is to perform Behavior Verification of the System Under Test (SUT).

您可以将AutoFixture与Moq结合起来,可以将其变成自动模拟容器.

这篇关于MOQ和AutoFixture有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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