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

标签 unit-testing mocking llblgen

你怎么能模拟 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/

相关文章:

unit-testing - 如何将 "full stack"功能分解为验收、集成和单元测试?

javascript - JS : 'this' collision in unit test for publication?

unit-testing - 在 Golang 中制作模拟 gin.Context

php - 在实例化自己对象的函数内部使用 PHP 中的模拟对象

c# - automapper 意外字段 c#

c# - llblgen 2.6 中相关字段的排序

unit-testing - 如何模拟也属于目标类本身的方法?

c# - 使用 Nunit 测试异常

python - 模拟树莓派 GPIO 信号

c# - LLBLGen - 如何使用 CatalogNameOverwriteHashtable