gpt4 book ai didi

unit-testing - 如何使用 LLBLGen 进行模拟

转载 作者:行者123 更新时间:2023-12-04 04:54:55 26 4
gpt4 key购买 nike

你怎么能模拟 LLBLGen?我看到有一个 ILinqMetaData 接口(interface),但它没有提供任何有用的方法来模拟。我假设您希望对 ILinqMetaData 接口(interface)以及生成的实体接口(interface)进行编程,以使对象与数据松散耦合。有没有人有任何简单测试/模拟的例子?

最佳答案

我认为它不仅限于 LLBLGen,也许这会有所帮助:

What's the best strategy for unit-testing database-driven applications?

就个人而言,我通常不测试我的数据库访问或存储库,只测试在实体上运行的逻辑,或在整个堆栈(包括数据库)上运行的集成测试。

更新:这有帮助吗?它允许您通过模拟 IOrderRepository 来测试您的逻辑,而无需执行任何获取/持久性逻辑:

public class MyBusinessLogic 
{
IOrderRepository orders;

public MyBusinessLogic(IOrderRepository orders)
{
this.orders = orders;
}

public DoSomethingTestable(OrderEntity order)
{
order.Total = 100;
orders.Save(order);
}
}

关于unit-testing - 如何使用 LLBLGen 进行模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11036108/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com