我知道有几个关于起订量教程的问题。但我想知道是否有任何示例应用程序在使用 ado.net 的 n 层业务应用程序的上下文中使用 moq。
我觉得 tutes 很好,但它们似乎并没有把所有东西都放在一起。因此,我正在寻找一个能够将全貌结合在一起的示例应用程序。
另外,我认为缺少专门处理模拟和测试数据访问层中的逻辑的示例。
干杯安东尼
编辑 5/5/09:起订量已从此代码库中删除,因此您必须下载较旧的修订版 (140) 才能查看起订量内容。
试用SutekiShop - 使用 .NET 3.5、MVC、LINQ、Windsor 和 Moq。
Moq, like all unit testing frameworks, should not have much a concept of n-tier-ness about it.
One would typically use unit testing to test each individual class one-at-a-time. When a particular class is a little more complex and relies on having references to component classes and calling methods on these component classes, one might use a mocking framework such as Moq to create these constituent components, and to have the class-under-test use these mocked components instead of the real deals.
It looks like you are looking for how to use Moq in integration testing, where you bring all the components together and test the whole shebang all at once, including the data-access components. For doing whole-shebang tests, typically you need the real components, not mocked versions of them.