简体   繁体   中英

What are Fakes assembly in Visual Studio 2013?

关于如何添加Fakes Assembly有很多问题,但没有关于它们是什么以及它们用于什么的问题。

Fakes are used to mock or stub code for testing purposes. Eg, instead of connecting directly to a database in a unit test you create a fake of the class that accesses the database that "fakes" just enough behavior to be used instead of the real database. This isolates the unit test from the remaining system.

You can read more about fakes in Isolating Code Under Test with Microsoft Fakes .

Microsoft Fakes framework, helps you to test your code, when you want to use some external variables whose values change randomly (like stocks) and you are using that in your code (you want to test this code, without bothering about the external factors). Another case could be testing something which i not yet complete.

So in your code you have something which you want to test + Some external factors.

Fakes would help you by replacing external factors by your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM